Skip to main content

Path

Trait Path 

Source
pub trait Path {
    type Scalar: Scalar;
    type Point: Point<Scalar = Self::Scalar>;
    type Error: From<PathError<Self::Scalar>>;

    // Required methods
    fn length(&self) -> Self::Scalar;
    fn sample_at(&self, s: Self::Scalar) -> Result<Self::Point, Self::Error>;

    // Provided methods
    fn start(&self) -> Result<Self::Point, Self::Error> { ... }
    fn end(&self) -> Result<Self::Point, Self::Error> { ... }
    fn domain(&self) -> RangeInclusive<Self::Scalar> { ... }
}
Expand description

A curve that can be sampled by arc-length s.

Every path has a total length, and sample_at(s) returns a Point for s ∈ [0, length]. The trait provides convenience methods start(), end(), and domain().

Required Associated Types§

Source

type Scalar: Scalar

The scalar type for arc-length, parameter, and distance computations.

Source

type Point: Point<Scalar = Self::Scalar>

The point type representing positions on the path.

Source

type Error: From<PathError<Self::Scalar>>

The error type for fallible operations. Must be convertible from PathError<Self::Scalar>.

Required Methods§

Source

fn length(&self) -> Self::Scalar

Total arc-length of the path.

Source

fn sample_at(&self, s: Self::Scalar) -> Result<Self::Point, Self::Error>

Sample the path at arc-length s ∈ [0, length].

Returns an error when s is outside the valid domain.

Provided Methods§

Source

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

The start point of the path, equivalent to sample_at(0).

Source

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

The end point of the path, equivalent to sample_at(length).

Source

fn domain(&self) -> RangeInclusive<Self::Scalar>

The valid domain for arc-length sampling: [0, length].

Implementors§

Source§

impl<A: Path, B: Path<Scalar = A::Scalar, Point = A::Point, Error = A::Error>> Path for Concat<A, B>

Source§

type Scalar = <A as Path>::Scalar

Source§

type Point = <A as Path>::Point

Source§

type Error = <A as Path>::Error

Source§

impl<P: Path + Tangent + Heading> Path for Offset<P, P::Scalar>

Source§

type Scalar = <P as Path>::Scalar

Source§

type Point = <P as Path>::Point

Source§

type Error = <P as Path>::Error

Source§

impl<P: Path> Path for Reverse<P>

Source§

type Scalar = <P as Path>::Scalar

Source§

type Point = <P as Path>::Point

Source§

type Error = <P as Path>::Error