Skip to main content

Module implicit_surfaces

Module implicit_surfaces 

Source
Expand description

Implicit surface representations and operations.

This module provides Signed Distance Functions (SDFs) for common geometric primitives, Constructive Solid Geometry (CSG) boolean operations, smooth blending, isosurface extraction via Marching Cubes, Radial Basis Function (RBF) implicit surfaces, and sphere-tracing ray marching.

§Quick start

use oxiphysics_geometry::implicit_surfaces::{ImplicitSurface, SphereSDF};

let sphere = SphereSDF::new([0.0, 0.0, 0.0], 1.0);
assert!(sphere.eval([0.0, 0.0, 0.0]) < 0.0); // inside
assert!(sphere.eval([2.0, 0.0, 0.0]) > 0.0); // outside

Structs§

BoxSDF
Axis-aligned box SDF centred at the origin.
CylinderSDF
Infinite cylinder SDF along the Y axis centred at the origin.
DifferenceSDF
CSG difference of two implicit surfaces: f = max(A, −B).
IntersectionSDF
CSG intersection of two implicit surfaces: f = max(A, B).
OffsetSDF
Offset (shell) SDF: expands or shrinks a shape by a fixed distance.
RBFImplicit
Radial Basis Function (RBF) implicit surface.
SmoothUnionSDF
Smooth (C¹) union of two implicit surfaces using polynomial blending.
SphereSDF
Sphere SDF: f(p) = |p − center| − radius.
TorusSDF
Torus SDF centred at the origin, lying in the XZ plane.
UnionSDF
CSG union of two implicit surfaces: f = min(A, B).

Traits§

ImplicitSurface
Trait for implicit surface representations (Signed Distance Functions).

Functions§

is_inside
Test whether a point is inside a closed implicit surface.
marching_cubes
Extract an isosurface from an implicit SDF using the Marching Cubes algorithm.
ray_march
Sphere-trace a ray against an implicit surface.
surface_bbox
Compute the axis-aligned bounding box of a level-set surface by sampling.
surface_normal
Estimate the outward unit normal of an implicit surface at p using central differences with step size eps.