Skip to main content

sphere_fit

Function sphere_fit 

Source
pub fn sphere_fit(segs: &mut [Segment3dInstance], radius: f32) -> f32
Expand description

Centre segs on their bounding box’s centre and scale them uniformly so every endpoint lies within a sphere of radius radius about the origin, and return the sphere’s radius after the fit — radius, or 0 for an empty or degenerate set, which is left untouched.

A sphere rather than a box because the figure turns under a camera: a sphere’s extent is the same from every side, so the fit does not depend on the view. The run neighbours in prev and next move with the endpoints.