pub struct SdfGrid3D {
pub nx: usize,
pub ny: usize,
pub nz: usize,
pub min_corner: [f64; 3],
pub voxel_size: f64,
pub data: Vec<f64>,
}Expand description
3D voxel grid storing signed distance values.
Supports construction from analytic SDFs, trilinear interpolation, and gradient estimation.
Fields§
§nx: usizeGrid resolution along X.
ny: usizeGrid resolution along Y.
nz: usizeGrid resolution along Z.
min_corner: [f64; 3]Minimum corner of the grid bounding box.
voxel_size: f64Voxel size.
data: Vec<f64>Flat (x, y, z) storage: index = x + nx*(y + ny*z).
Implementations§
Source§impl SdfGrid3D
impl SdfGrid3D
Sourcepub fn new(
nx: usize,
ny: usize,
nz: usize,
min_corner: [f64; 3],
voxel_size: f64,
) -> Self
pub fn new( nx: usize, ny: usize, nz: usize, min_corner: [f64; 3], voxel_size: f64, ) -> Self
Create an empty SDF grid.
Sourcepub fn from_sdf<F: Fn([f64; 3]) -> f64>(
nx: usize,
ny: usize,
nz: usize,
min_corner: [f64; 3],
voxel_size: f64,
f: F,
) -> Self
pub fn from_sdf<F: Fn([f64; 3]) -> f64>( nx: usize, ny: usize, nz: usize, min_corner: [f64; 3], voxel_size: f64, f: F, ) -> Self
Fill the grid from an analytic SDF function.
Sourcepub fn voxel_center(&self, ix: usize, iy: usize, iz: usize) -> [f64; 3]
pub fn voxel_center(&self, ix: usize, iy: usize, iz: usize) -> [f64; 3]
World position of voxel center (ix, iy, iz).
Sourcepub fn interpolate(&self, p: [f64; 3]) -> f64
pub fn interpolate(&self, p: [f64; 3]) -> f64
Trilinear interpolation of SDF value at world position p.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SdfGrid3D
impl RefUnwindSafe for SdfGrid3D
impl Send for SdfGrid3D
impl Sync for SdfGrid3D
impl Unpin for SdfGrid3D
impl UnsafeUnpin for SdfGrid3D
impl UnwindSafe for SdfGrid3D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.