Skip to main content

Sdf

Trait Sdf 

Source
pub trait Sdf: Send + Sync {
    // Required method
    fn distance(&self, p: [f64; 3]) -> f64;

    // Provided methods
    fn gradient(&self, p: [f64; 3]) -> [f64; 3] { ... }
    fn normal(&self, p: [f64; 3]) -> [f64; 3] { ... }
}
Expand description

Signed distance function: negative inside the shape, positive outside.

Required Methods§

Source

fn distance(&self, p: [f64; 3]) -> f64

Signed distance from point p to the surface.

Provided Methods§

Source

fn gradient(&self, p: [f64; 3]) -> [f64; 3]

Gradient of the SDF at p (numerical central differences by default).

Source

fn normal(&self, p: [f64; 3]) -> [f64; 3]

Outward unit normal at p (normalised gradient).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§