[−][src]Trait sdfu::SDF
The core trait of this crate; an implementor of this trait is able to take in a vector and return the min distance from that vector to a distance field.
Required methods
fn dist(&self, p: V) -> T
Get distance from p
to this SDF.
Provided methods
fn normals(self, eps: T) -> EstimateNormalDefault<T, V, Self> where
CentralDifferenceEstimator<T, V, <V as Vec<T>>::Dimension>: NormalEstimator<T, V>,
CentralDifferenceEstimator<T, V, <V as Vec<T>>::Dimension>: NormalEstimator<T, V>,
Estimate the normals of this SDF using the default NormalEstimator
.
eps
is the amount to change the point by for each sample.
0.001 is a good default value to try; you will ideally vary this based on distance.
fn normals_fast(self, eps: T) -> EstimateNormalFast<T, V, Self> where
TetrahedralEstimator<T, V>: NormalEstimator<T, V>,
TetrahedralEstimator<T, V>: NormalEstimator<T, V>,
Estimate the normals of this SDF using a fast, TetrahedralEstimator
. Only
works for 3d SDFs.
eps
is the amount to change the point by for each sample.
0.001 is a good default value to try; you will ideally vary this based on distance.
fn normals_with<E: NormalEstimator<T, V>>(
self,
estimator: E
) -> EstimateNormal<T, V, Self, E>
self,
estimator: E
) -> EstimateNormal<T, V, Self, E>
Estimate the normals of this SDF using a provided NormalEstimator
.
fn union<O: SDF<T, V>>(self, other: O) -> Union<T, Self, O, HardMin<T>>
Get the union of this SDF and another one()using a standard hard minimum, creating a sharp crease at the boundary between the two fields.
fn union_smooth<O: SDF<T, V>>(
self,
other: O,
softness: T
) -> Union<T, Self, O, PolySmoothMin<T>>
self,
other: O,
softness: T
) -> Union<T, Self, O, PolySmoothMin<T>>
Get the union of this SDF and another one, blended together
with a smooth minimum function. This uses a polynomial smooth min
function by default, and the smoothing factor is controlled by the
smoothness
parameter. For even more control, see union_with
.
fn union_with<O: SDF<T, V>, M: MinFunction<T>>(
self,
other: O,
min_function: M
) -> Union<T, Self, O, M>
self,
other: O,
min_function: M
) -> Union<T, Self, O, M>
Get the union of this SDF and another one()using a provided
minimum function. See the documentation of MinFunction
for more.
fn subtract<O: SDF<T, V>>(self, other: O) -> Subtraction<O, Self>
Get the subtracion of another SDF from this one. Note that this operation is not commutative,
i.e. a.subtraction(b) =/= b.subtraction(a)
.
fn intersection<O: SDF<T, V>>(self, other: O) -> Intersection<Self, O>
Get the intersection of this SDF and another one.
fn round(self, radius: T) -> Round<T, Self>
Round the corners of this SDF with a radius.
fn elongate(
self,
axis: Axis,
elongation: T
) -> Elongate<T, Self, <V as Vec<T>>::Dimension> where
Elongate<T, Self, <V as Vec<T>>::Dimension>: SDF<T, V>,
self,
axis: Axis,
elongation: T
) -> Elongate<T, Self, <V as Vec<T>>::Dimension> where
Elongate<T, Self, <V as Vec<T>>::Dimension>: SDF<T, V>,
Elongate this SDF along one()axis. The elongation is symmetrical about the origin.
fn elongate_multi_axis(
self,
elongation: V
) -> ElongateMulti<V, Self, <V as Vec<T>>::Dimension> where
ElongateMulti<V, Self, <V as Vec<T>>::Dimension>: SDF<T, V>,
self,
elongation: V
) -> ElongateMulti<V, Self, <V as Vec<T>>::Dimension> where
ElongateMulti<V, Self, <V as Vec<T>>::Dimension>: SDF<T, V>,
Elongate this SDF along one()axis. The elongation is symmetrical about the origin.
fn translate(self, translation: V) -> Translate<V, Self>
Translate the SDF by a vector.
fn rotate<R: Rotation<V>>(self, rotation: R) -> Rotate<R, Self>
Rotate the SDF by a rotation.
fn scale(self, scaling: T) -> Scale<T, Self>
Scale the SDF by a uniform scaling factor.
Implementors
impl<T, V> SDF<T, V> for Box<V, Dim2D> where
T: Add<T, Output = T> + MaxMin + Zero + Copy,
V: Vec2<T> + Copy,
[src]
T: Add<T, Output = T> + MaxMin + Zero + Copy,
V: Vec2<T> + Copy,
impl<T, V> SDF<T, V> for Box<V, Dim3D> where
T: Add<T, Output = T> + MaxMin + Zero + Copy,
V: Vec3<T> + Copy,
[src]
T: Add<T, Output = T> + MaxMin + Zero + Copy,
V: Vec3<T> + Copy,
impl<T, V> SDF<T, V> for CappedCylinder<T> where
T: Sub<T, Output = T> + Add<T, Output = T> + Zero + MaxMin + Copy,
V: Vec3<T>,
[src]
T: Sub<T, Output = T> + Add<T, Output = T> + Zero + MaxMin + Copy,
V: Vec3<T>,
impl<T, V> SDF<T, V> for Circle<T> where
T: Sub<T, Output = T> + Copy,
V: Vec2<T>,
[src]
T: Sub<T, Output = T> + Copy,
V: Vec2<T>,
impl<T, V> SDF<T, V> for Cylinder<T> where
T: Sub<T, Output = T> + Copy,
V: Vec3<T>,
[src]
T: Sub<T, Output = T> + Copy,
V: Vec3<T>,
impl<T, V> SDF<T, V> for Line<T, V> where
T: Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Zero + One + Clamp + Copy,
V: Vec<T> + Copy,
[src]
T: Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Zero + One + Clamp + Copy,
V: Vec<T> + Copy,
impl<T, V> SDF<T, V> for Sphere<T> where
T: Sub<T, Output = T> + Copy,
V: Vec3<T>,
[src]
T: Sub<T, Output = T> + Copy,
V: Vec3<T>,
impl<T, V> SDF<T, V> for Torus<T> where
T: Sub<T, Output = T> + Copy,
V: Vec3<T>,
[src]
T: Sub<T, Output = T> + Copy,
V: Vec3<T>,
impl<T, V, R, S> SDF<T, V> for Rotate<R, S> where
T: Copy,
V: Vec<T>,
S: SDF<T, V>,
R: Rotation<V> + Copy,
[src]
T: Copy,
V: Vec<T>,
S: SDF<T, V>,
R: Rotation<V> + Copy,
impl<T, V, S1, S2> SDF<T, V> for Intersection<S1, S2> where
T: Copy + MaxMin,
V: Vec<T>,
S1: SDF<T, V>,
S2: SDF<T, V>,
[src]
T: Copy + MaxMin,
V: Vec<T>,
S1: SDF<T, V>,
S2: SDF<T, V>,
impl<T, V, S1, S2> SDF<T, V> for Subtraction<S1, S2> where
T: Copy + Neg<Output = T> + MaxMin,
V: Vec<T>,
S1: SDF<T, V>,
S2: SDF<T, V>,
[src]
T: Copy + Neg<Output = T> + MaxMin,
V: Vec<T>,
S1: SDF<T, V>,
S2: SDF<T, V>,
impl<T, V, S1, S2, M> SDF<T, V> for Union<T, S1, S2, M> where
T: Copy,
V: Vec<T>,
S1: SDF<T, V>,
S2: SDF<T, V>,
M: MinFunction<T> + Copy,
[src]
T: Copy,
V: Vec<T>,
S1: SDF<T, V>,
S2: SDF<T, V>,
M: MinFunction<T> + Copy,
impl<T, V, S> SDF<T, V> for Elongate<T, S, Dim2D> where
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero,
V: Vec2<T>,
S: SDF<T, V>,
[src]
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero,
V: Vec2<T>,
S: SDF<T, V>,
impl<T, V, S> SDF<T, V> for Elongate<T, S, Dim3D> where
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero,
V: Vec3<T>,
S: SDF<T, V>,
[src]
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero,
V: Vec3<T>,
S: SDF<T, V>,
impl<T, V, S> SDF<T, V> for ElongateMulti<V, S, Dim2D> where
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero + MaxMin,
V: Vec2<T>,
S: SDF<T, V>,
[src]
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero + MaxMin,
V: Vec2<T>,
S: SDF<T, V>,
impl<T, V, S> SDF<T, V> for ElongateMulti<V, S, Dim3D> where
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero + MaxMin,
V: Vec3<T>,
S: SDF<T, V>,
[src]
T: Copy + Add<T, Output = T> + Sub<T, Output = T> + Zero + MaxMin,
V: Vec3<T>,
S: SDF<T, V>,
impl<T, V, S> SDF<T, V> for Round<T, S> where
T: Copy + Sub<T, Output = T>,
V: Vec<T>,
S: SDF<T, V>,
[src]
T: Copy + Sub<T, Output = T>,
V: Vec<T>,
S: SDF<T, V>,
impl<T, V, S> SDF<T, V> for Scale<T, S> where
T: Copy + Mul<T, Output = T>,
V: Vec<T>,
S: SDF<T, V>,
[src]
T: Copy + Mul<T, Output = T>,
V: Vec<T>,
S: SDF<T, V>,
impl<T, V, S> SDF<T, V> for Translate<V, S> where
T: Copy,
V: Vec<T>,
S: SDF<T, V>,
[src]
T: Copy,
V: Vec<T>,
S: SDF<T, V>,