Skip to main content

project

Function project 

Source
pub fn project(
    surface: &Surface,
    point: DVec3,
    tolerance: Tolerance,
) -> Result<(f64, f64), GeomError>
Expand description

Parameters of the closest point on a surface to an arbitrary point.

This is the counterpart to invert, and the distinction matters. invert names a point that is ALREADY on the surface and refuses one that is not. Projection accepts a point anywhere and answers where the surface is nearest to it.

Refinement needs projection, not inversion: the midpoint of a chord across a faceted cylinder lies strictly inside the cylinder, so inversion correctly refuses it while projection is exactly the question being asked.

Every arm here is a closed form, so the result is exact rather than the stopping point of an iteration. Where the closest point is genuinely ambiguous – a point on a cylinder’s axis is equidistant from every point of the surface – this refuses by name instead of returning one arbitrary member of the tie.

§Errors

Refuses a non-orthonormal frame, a non-finite point, a degenerate radius, an ambiguous (equidistant) configuration, and any surface with no closed-form projection.