Skip to main content

Curve

Trait Curve 

Source
pub trait Curve: Send + Sync {
    // Required method
    fn sample(&self, t: f32) -> Vec3;

    // Provided methods
    fn tangent(&self, t: f32) -> Vec3 { ... }
    fn unit_tangent(&self, t: f32) -> Vec3 { ... }
    fn normal_2d(&self, t: f32) -> Vec3 { ... }
    fn arc_length(&self, n: u32) -> f32 { ... }
    fn build_arc_table(&self, n: u32) -> ArcTable { ... }
    fn sample_uniform(&self, n: usize) -> Vec<Vec3> { ... }
    fn sample_arc_uniform(&self, n: usize, table_resolution: u32) -> Vec<Vec3> { ... }
    fn bounding_box(&self, resolution: u32) -> (Vec3, Vec3) { ... }
    fn closest_point(&self, query: Vec3, resolution: u32) -> (f32, Vec3) { ... }
}
Expand description

Common interface for parametric curves.

Required Methods§

Source

fn sample(&self, t: f32) -> Vec3

Sample position at parameter t ∈ [0, 1].

Provided Methods§

Source

fn tangent(&self, t: f32) -> Vec3

Sample tangent (unnormalized derivative) at t.

Source

fn unit_tangent(&self, t: f32) -> Vec3

Sample unit tangent at t.

Source

fn normal_2d(&self, t: f32) -> Vec3

Sample the normal (perpendicular to tangent) at t, in the XY plane.

Source

fn arc_length(&self, n: u32) -> f32

Approximate arc length using n segments.

Source

fn build_arc_table(&self, n: u32) -> ArcTable

Build an arc-length table with n segments for uniform-speed queries.

Source

fn sample_uniform(&self, n: usize) -> Vec<Vec3>

Sample n evenly-spaced points along the curve (by parameter).

Source

fn sample_arc_uniform(&self, n: usize, table_resolution: u32) -> Vec<Vec3>

Sample n points at equal arc-length intervals.

Source

fn bounding_box(&self, resolution: u32) -> (Vec3, Vec3)

Bounding box as (min, max).

Source

fn closest_point(&self, query: Vec3, resolution: u32) -> (f32, Vec3)

Find the closest point on the curve to query, returning (t, point).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§