Skip to main content

ImplicitSurface

Trait ImplicitSurface 

Source
pub trait ImplicitSurface {
    // Required method
    fn eval(&self, p: [f64; 3]) -> f64;

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

Trait for implicit surface representations (Signed Distance Functions).

Implementors define a scalar field f: ℝ³ → ℝ where:

  • f(p) < 0 means p is inside the surface
  • f(p) = 0 means p is on the surface
  • f(p) > 0 means p is outside the surface

Required Methods§

Source

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

Evaluate the signed distance (or implicit) function at point p.

Provided Methods§

Source

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

Compute the gradient ∇f at point p.

For exact SDFs this equals the outward unit normal on the surface. The default implementation uses central differences with step 1e-5.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§