Struct truck_modeling::geometry::Processor
source · pub struct Processor<E, T> { /* private fields */ }
Expand description
invertible and transformable geometric element
Examples
Curve processing example
use truck_geometry::*;
let curve: BSplineCurve<Point3> = BSplineCurve::new(
KnotVec::bezier_knot(2),
vec![
Point3::new(0.0, 0.0, 0.0),
Point3::new(0.0, 0.0, 1.0),
Point3::new(1.0, 0.0, 0.0),
],
);
let mut processed = Processor::<_, Matrix4>::new(curve.clone());
// both curves are the same curve
const N: usize = 100;
for i in 0..=N {
let t = i as f64 / N as f64;
assert_eq!(curve.subs(t), processed.subs(t));
}
// Processed curve can inverted!
processed.invert();
for i in 0..=N {
let t = i as f64 / N as f64;
assert_eq!(curve.subs(1.0 - t), processed.subs(t));
}
Surface processing example
use truck_geometry::*;
use std::f64::consts::PI;
let sphere = Sphere::new(Point3::new(1.0, 2.0, 3.0), 2.45);
let mut processed = Processor::<_, Matrix4>::new(sphere);
// both surfaces are the same surface
const N: usize = 100;
for i in 0..=N {
for j in 0..=N {
let u = PI * i as f64 / N as f64;
let v = 2.0 * PI * j as f64 / N as f64;
assert_eq!(sphere.subs(u, v), processed.subs(u, v));
}
}
// Processed surface can be inverted!
// Here, "invert surface" means swap (u, v)-axes.
processed.invert();
for i in 0..=N {
for j in 0..=N {
let u = PI * i as f64 / N as f64;
let v = 2.0 * PI * j as f64 / N as f64;
assert_eq!(sphere.subs(u, v), processed.subs(v, u));
}
}
Implementations§
source§impl<E, T> Processor<E, T>where
T: One,
impl<E, T> Processor<E, T>where
T: One,
sourcepub fn map<G, F>(self, f: F) -> Processor<G, T>where
F: FnOnce(E) -> G,
pub fn map<G, F>(self, f: F) -> Processor<G, T>where
F: FnOnce(E) -> G,
apply the function to the entity geometry
sourcepub fn map_ref<G, F>(&self, f: F) -> Processor<G, T>where
F: FnOnce(&E) -> G,
T: Copy,
pub fn map_ref<G, F>(&self, f: F) -> Processor<G, T>where
F: FnOnce(&E) -> G,
T: Copy,
apply the function to the entity geometry
sourcepub fn constract(self) -> Ewhere
E: Transformed<T> + Invertible,
pub fn constract(self) -> Ewhere
E: Transformed<T> + Invertible,
apply the transform and inverse
Trait Implementations§
source§impl<C, T> BoundedCurve for Processor<C, T>where
C: BoundedCurve,
<C as ParametricCurve>::Point: EuclideanSpace<Diff = <C as ParametricCurve>::Vector>,
<C as ParametricCurve>::Vector: VectorSpace<Scalar = f64>,
T: Transform<<C as ParametricCurve>::Point> + Clone,
impl<C, T> BoundedCurve for Processor<C, T>where
C: BoundedCurve,
<C as ParametricCurve>::Point: EuclideanSpace<Diff = <C as ParametricCurve>::Vector>,
<C as ParametricCurve>::Vector: VectorSpace<Scalar = f64>,
T: Transform<<C as ParametricCurve>::Point> + Clone,
source§impl<S, T> BoundedSurface for Processor<S, T>where
T: Transform<<S as ParametricSurface>::Point> + SquareMatrix<Scalar = f64> + Clone,
S: BoundedSurface<Point = Point3<f64>, Vector = Vector3<f64>>,
impl<S, T> BoundedSurface for Processor<S, T>where
T: Transform<<S as ParametricSurface>::Point> + SquareMatrix<Scalar = f64> + Clone,
S: BoundedSurface<Point = Point3<f64>, Vector = Vector3<f64>>,
source§impl<'de, E, T> Deserialize<'de> for Processor<E, T>where
E: Deserialize<'de>,
T: Deserialize<'de>,
impl<'de, E, T> Deserialize<'de> for Processor<E, T>where
E: Deserialize<'de>,
T: Deserialize<'de>,
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Processor<E, T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Processor<E, T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<E, T, C> IncludeCurve<C> for Processor<E, T>where
C: ParametricCurve + Transformed<T> + Clone,
<C as ParametricCurve>::Point: EuclideanSpace,
E: IncludeCurve<C>,
T: Transform<<C as ParametricCurve>::Point>,
impl<E, T, C> IncludeCurve<C> for Processor<E, T>where
C: ParametricCurve + Transformed<T> + Clone,
<C as ParametricCurve>::Point: EuclideanSpace,
E: IncludeCurve<C>,
T: Transform<<C as ParametricCurve>::Point>,
source§impl<C> ParameterDivision1D for Processor<C, Matrix3<f64>>where
C: ParameterDivision1D,
impl<C> ParameterDivision1D for Processor<C, Matrix3<f64>>where
C: ParameterDivision1D,
§type Point = <C as ParameterDivision1D>::Point
type Point = <C as ParameterDivision1D>::Point
The curve is in the space of
Self::Point
.source§impl<C> ParameterDivision1D for Processor<C, Matrix4<f64>>where
C: ParameterDivision1D,
impl<C> ParameterDivision1D for Processor<C, Matrix4<f64>>where
C: ParameterDivision1D,
§type Point = <C as ParameterDivision1D>::Point
type Point = <C as ParameterDivision1D>::Point
The curve is in the space of
Self::Point
.source§impl<S> ParameterDivision2D for Processor<S, Matrix3<f64>>where
S: ParameterDivision2D,
impl<S> ParameterDivision2D for Processor<S, Matrix3<f64>>where
S: ParameterDivision2D,
source§impl<S> ParameterDivision2D for Processor<S, Matrix4<f64>>where
S: ParameterDivision2D,
impl<S> ParameterDivision2D for Processor<S, Matrix4<f64>>where
S: ParameterDivision2D,
source§impl<C, T> ParametricCurve for Processor<C, T>where
C: BoundedCurve,
<C as ParametricCurve>::Point: EuclideanSpace<Diff = <C as ParametricCurve>::Vector>,
<C as ParametricCurve>::Vector: VectorSpace<Scalar = f64>,
T: Transform<<C as ParametricCurve>::Point> + Clone,
impl<C, T> ParametricCurve for Processor<C, T>where
C: BoundedCurve,
<C as ParametricCurve>::Point: EuclideanSpace<Diff = <C as ParametricCurve>::Vector>,
<C as ParametricCurve>::Vector: VectorSpace<Scalar = f64>,
T: Transform<<C as ParametricCurve>::Point> + Clone,
§type Point = <C as ParametricCurve>::Point
type Point = <C as ParametricCurve>::Point
The curve is in the space of
Self::Point
.§type Vector = <C as ParametricCurve>::Vector
type Vector = <C as ParametricCurve>::Vector
The derivation vector of the curve.
source§impl<S, T> ParametricSurface for Processor<S, T>where
<S as ParametricSurface>::Point: EuclideanSpace<Scalar = f64, Diff = <S as ParametricSurface>::Vector>,
T: Transform<<S as ParametricSurface>::Point> + SquareMatrix<Scalar = f64> + Clone,
S: ParametricSurface,
impl<S, T> ParametricSurface for Processor<S, T>where
<S as ParametricSurface>::Point: EuclideanSpace<Scalar = f64, Diff = <S as ParametricSurface>::Vector>,
T: Transform<<S as ParametricSurface>::Point> + SquareMatrix<Scalar = f64> + Clone,
S: ParametricSurface,
§type Point = <S as ParametricSurface>::Point
type Point = <S as ParametricSurface>::Point
The surface is in the space of
Self::Point
.§type Vector = <S as ParametricSurface>::Vector
type Vector = <S as ParametricSurface>::Vector
The derivation vector of the curve.
source§fn subs(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Point
fn subs(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Point
Substitutes the parameter
(u, v)
.source§fn uder(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Vector
fn uder(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Vector
Returns the derivation by
u
.source§fn vder(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Vector
fn vder(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Vector
Returns the derivation by
v
.source§fn uuder(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Vector
fn uuder(&self, u: f64, v: f64) -> <Processor<S, T> as ParametricSurface>::Vector
Returns the 2nd-order derivation by
u
.source§impl<S, T> ParametricSurface3D for Processor<S, T>where
S: ParametricSurface3D,
T: Transform<Point3<f64>> + SquareMatrix<Scalar = f64> + Clone,
impl<S, T> ParametricSurface3D for Processor<S, T>where
S: ParametricSurface3D,
T: Transform<Point3<f64>> + SquareMatrix<Scalar = f64> + Clone,
source§impl<E, D, T> SearchParameter<D> for Processor<E, T>where
D: SPDimension,
E: SearchParameter<D>,
<E as SearchParameter<D>>::Point: EuclideanSpace,
T: Transform<<E as SearchParameter<D>>::Point>,
impl<E, D, T> SearchParameter<D> for Processor<E, T>where
D: SPDimension,
E: SearchParameter<D>,
<E as SearchParameter<D>>::Point: EuclideanSpace,
T: Transform<<E as SearchParameter<D>>::Point>,
§type Point = <E as SearchParameter<D>>::Point
type Point = <E as SearchParameter<D>>::Point
point
source§fn search_parameter<H>(
&self,
point: <E as SearchParameter<D>>::Point,
hint: H,
trials: usize
) -> Option<<D as SPDimension>::Parameter>where
H: Into<<D as SPDimension>::Hint>,
fn search_parameter<H>(
&self,
point: <E as SearchParameter<D>>::Point,
hint: H,
trials: usize
) -> Option<<D as SPDimension>::Parameter>where
H: Into<<D as SPDimension>::Hint>,
Search parameter
Returns
t
such that self.subs(t)
is near point.Returns
None
if could not find such parameter.source§impl<E, T> Serialize for Processor<E, T>where
E: Serialize,
T: Serialize,
impl<E, T> Serialize for Processor<E, T>where
E: Serialize,
T: Serialize,
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl<E, T> Transformed<T> for Processor<E, T>where
T: Mul<T, Output = T> + Copy,
E: Clone,
impl<E, T> Transformed<T> for Processor<E, T>where
T: Mul<T, Output = T> + Copy,
E: Clone,
source§fn transform_by(&mut self, trans: T)
fn transform_by(&mut self, trans: T)
transform by
trans
.source§fn transformed(&self, trans: T) -> Processor<E, T>
fn transformed(&self, trans: T) -> Processor<E, T>
transformed geometry by
trans
.