Skip to main content

Project

Trait Project 

Source
pub trait Project: Path {
    // Required method
    fn project(&self, p: Self::Point) -> Result<Self::Scalar, Self::Error>;

    // Provided method
    fn closest_point(&self, p: Self::Point) -> Result<Self::Point, Self::Error> { ... }
}
Expand description

Project a query point onto a path to find the nearest position.

Implementers should return the arc-length parameter of the closest point. The default closest_point method combines project with sample_at to produce the actual position.

Required Methods§

Source

fn project(&self, p: Self::Point) -> Result<Self::Scalar, Self::Error>

Find the arc-length s of the point on the path closest to p.

Returns an error when the projection cannot be computed (e.g. a degenerate path).

Provided Methods§

Source

fn closest_point(&self, p: Self::Point) -> Result<Self::Point, Self::Error>

Return the closest point on the path to p.

This default implementation calls project followed by sample_at.

Implementors§