Struct truck_modeling::geometry::NURBSSurface [−][src]
pub struct NURBSSurface<V>(_);
Expand description
NURBS surface
Implementations
constructor
Returns the nurbs surface before rationalized
Returns the nurbs surface before rationalized
Returns the nurbs surface before rationalized
Returns the reference of the vector of the control points
Returns the reference of the control point corresponding to the index (idx0, idx1)
.
Apply the given transformation to all control points.
Returns the iterator over the control points in the column_idx
th row.
Examples
use truck_geometry::*;
let uknot_vec = KnotVec::bezier_knot(1);
let vknot_vec = KnotVec::bezier_knot(2);
let knot_vecs = (uknot_vec, vknot_vec);
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 0.0, 1.0), Vector3::new(2.0, 0.0, 2.0)],
vec![Vector3::new(0.0, 1.0, 0.0), Vector3::new(1.0, 1.0, 1.0), Vector3::new(2.0, 1.0, 2.0)],
];
let bspsurface = BSplineSurface::new(knot_vecs, ctrl_pts);
let mut iter = bspsurface.ctrl_pts_row_iter(1);
assert_eq!(iter.next(), Some(&Vector3::new(1.0, 0.0, 1.0)));
assert_eq!(iter.next(), Some(&Vector3::new(1.0, 1.0, 1.0)));
assert_eq!(iter.next(), None);
Returns the iterator over the control points in the row_idx
th row.
Examples
use truck_geometry::*;
let uknot_vec = KnotVec::bezier_knot(1);
let vknot_vec = KnotVec::bezier_knot(2);
let knot_vecs = (uknot_vec, vknot_vec);
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 0.0, 1.0), Vector3::new(2.0, 0.0, 2.0)],
vec![Vector3::new(0.0, 1.0, 0.0), Vector3::new(1.0, 1.0, 1.0), Vector3::new(2.0, 1.0, 2.0)],
];
let bspsurface = BSplineSurface::new(knot_vecs, ctrl_pts);
let mut iter = bspsurface.ctrl_pts_column_iter(1);
assert_eq!(iter.next(), Some(&Vector3::new(0.0, 1.0, 0.0)));
assert_eq!(iter.next(), Some(&Vector3::new(1.0, 1.0, 1.0)));
assert_eq!(iter.next(), Some(&Vector3::new(2.0, 1.0, 2.0)));
assert_eq!(iter.next(), None);
Returns the mutable reference of the control point corresponding to index (idx0, idx1)
.
Returns the iterator on all control points
Returns the degrees of B-spline surface
Examples
use truck_geometry::*;
let uknot_vec = KnotVec::from(vec![0.0, 0.0, 1.0, 1.0]);
let vknot_vec = KnotVec::from(vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0]);
let knot_vecs = (uknot_vec, vknot_vec);
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 0.0, 1.0), Vector3::new(2.0, 0.0, 2.0)],
vec![Vector3::new(0.0, 1.0, 0.0), Vector3::new(1.0, 1.0, 1.0), Vector3::new(2.0, 1.0, 2.0)],
];
let bspsurface = BSplineSurface::new(knot_vecs, ctrl_pts);
assert_eq!(bspsurface.udegree(), 1);
Returns the degrees of B-spline surface
Examples
use truck_geometry::*;
let uknot_vec = KnotVec::from(vec![0.0, 0.0, 1.0, 1.0]);
let vknot_vec = KnotVec::from(vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0]);
let knot_vecs = (uknot_vec, vknot_vec);
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 0.0, 1.0), Vector3::new(2.0, 0.0, 2.0)],
vec![Vector3::new(0.0, 1.0, 0.0), Vector3::new(1.0, 1.0, 1.0), Vector3::new(2.0, 1.0, 2.0)],
];
let bspsurface = BSplineSurface::new(knot_vecs, ctrl_pts);
assert_eq!(bspsurface.vdegree(), 2);
Returns the degrees of B-spline surface
Examples
use truck_geometry::*;
let uknot_vec = KnotVec::from(vec![0.0, 0.0, 1.0, 1.0]);
let vknot_vec = KnotVec::from(vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0]);
let knot_vecs = (uknot_vec, vknot_vec);
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 0.0, 1.0), Vector3::new(2.0, 0.0, 2.0)],
vec![Vector3::new(0.0, 1.0, 0.0), Vector3::new(1.0, 1.0, 1.0), Vector3::new(2.0, 1.0, 2.0)],
];
let bspsurface = BSplineSurface::new(knot_vecs, ctrl_pts);
assert_eq!(bspsurface.degrees(), (1, 2));
Returns whether the knot vectors are clamped or not.
Swaps two parameters.
The range of the parameter of the surface.
Creates the curve whose control points are the idx
th column control points of self
.
Creates the column sectional curve.
Substitutes to a NURBS surface.
pub fn uder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
pub fn uder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
Substitutes derived NURBS surface by the first parameter u
.
pub fn vder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
pub fn vder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
Substitutes derived NURBS surface by the first parameter v
.
pub fn uuder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
pub fn uuder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
Substitutes 2nd-ord derived NURBS surface by the first parameter u
.
pub fn vvder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
pub fn vvder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
Substitutes 2nd-ord derived NURBS surface by the first parameter v
.
pub fn uvder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
pub fn uvder(
&self,
u: f64,
v: f64
) -> <<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff
Substitutes 2nd-ord derived NURBS surface by both parameter u, v
.
Returns the closure of substitution.
impl<V> NURBSSurface<V> where
V: Homogeneous<f64> + ControlPoint<f64, Diff = V>,
<V as Homogeneous<f64>>::Point: Tolerance,
impl<V> NURBSSurface<V> where
V: Homogeneous<f64> + ControlPoint<f64, Diff = V>,
<V as Homogeneous<f64>>::Point: Tolerance,
Returns whether constant curve or not, i.e. all control points are same or not.
Examples
use truck_geometry::*;
let uknot_vec = KnotVec::bezier_knot(1);
let vknot_vec = KnotVec::bezier_knot(2);
let pt = Vector3::new(1.0, 2.0, 1.0);
// allows differences upto scalars
let ctrl_pts = vec![
vec![pt.clone(), pt.clone() * 2.0, pt.clone() * 3.0],
vec![pt.clone() * 0.5, pt.clone() * 0.25, pt.clone() * 0.125],
];
let mut surface = NURBSSurface::new(BSplineSurface::new((uknot_vec, vknot_vec), ctrl_pts));
assert!(surface.is_const());
*surface.control_point_mut(1, 2) = Vector3::new(2.0, 3.0, 1.0);
assert!(!surface.is_const());
Determines whether self
and other
is near as the B-spline rational surfaces or not.
Divides each knot domain into the number of degree equal parts,
and check |self(u, v) - other(u, v)| < TOLERANCE
for each end points (u, v)
.
Examples
use truck_geometry::*;
let knot_vecs = (KnotVec::bezier_knot(3), KnotVec::bezier_knot(2));
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 1.0), Vector3::new(0.5, -1.0, 2.0), Vector3::new(1.0, 0.0, 1.0)],
vec![Vector3::new(0.0, 1.0, 1.0), Vector3::new(0.5, 1.0, 1.0), Vector3::new(1.0, 1.0, 1.0)],
vec![Vector3::new(0.0, 2.0, 1.0), Vector3::new(0.5, 2.0, 3.0), Vector3::new(1.0, 2.0, 1.0)],
vec![Vector3::new(0.0, 3.0, 1.0), Vector3::new(0.5, 3.5, 2.0), Vector3::new(1.0, 3.0, 1.0)],
];
let surface0 = NURBSSurface::new(BSplineSurface::new(knot_vecs, ctrl_pts));
let mut surface1 = surface0.clone();
assert!(surface0.near_as_surface(&surface1));
*surface1.control_point_mut(1, 1) = Vector3::new(0.5, 1.0, 0.9);
assert!(!surface0.near_as_surface(&surface1));
Determines whether self
and other
is near in square order as the B-spline rational
surfaces or not.
Divides each knot domain into the number of degree equal parts,
and check |self(u, v) - other(u, v)| < TOLERANCE
for each end points (u, v)
.
Examples
use truck_geometry::*;
let eps = TOLERANCE;
let knot_vecs = (KnotVec::bezier_knot(3), KnotVec::bezier_knot(2));
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 1.0), Vector3::new(0.5, -1.0, 2.0), Vector3::new(1.0, 0.0, 1.0)],
vec![Vector3::new(0.0, 1.0, 1.0), Vector3::new(0.5, 1.0, 1.0), Vector3::new(1.0, 1.0, 1.0)],
vec![Vector3::new(0.0, 2.0, 1.0), Vector3::new(0.5, 2.0, 3.0), Vector3::new(1.0, 2.0, 1.0)],
vec![Vector3::new(0.0, 3.0, 1.0), Vector3::new(0.5, 3.5, 2.0), Vector3::new(1.0, 3.0, 1.0)],
];
let surface0 = NURBSSurface::new(BSplineSurface::new(knot_vecs, ctrl_pts));
let mut surface1 = surface0.clone();
assert!(surface0.near_as_surface(&surface1));
*surface1.control_point_mut(1, 1) = Vector3::new(0.5, 1.0, 1.0 - eps);
assert!(surface0.near_as_surface(&surface1));
assert!(!surface0.near2_as_surface(&surface1));
Adds a knot x
of the first parameter u
, and do not change self
as a surface.
Adds a knot x
of the first parameter u
, and do not change self
as a surface.
Removes the uknot corresponding to the indice idx
, and do not change self
as a curve.
If the knot cannot be removed, returns
Error::CannotRemoveKnot
.
Removes the uknot corresponding to the indices idx
, and do not change self
as a curve.
If cannot remove the knot, do not change self
and return self
.
Removes the uknot corresponding to the indice idx
, and do not change self
as a curve.
If the knot cannot be removed, returns
Error::CannotRemoveKnot
.
Removes the uknot corresponding to the indices idx
, and do not change self
as a curve.
If cannot remove the knot, do not change self
and return self
.
Elevates the udegree.
Elevates the vdegree.
Aligns the udegree with the same degrees.
Makes the uknot vector and the vknot vector the same knot vector.
Cuts the surface into two surfaces at the parameter u
Cuts the surface into two surfaces at the parameter v
Normalizes the knot vectors
Translates the knot vectors.
Removes knots in order from the back
Get the boundary by four splitted curves.
Example
use truck_geometry::*;
let knot_vecs = (KnotVec::bezier_knot(3), KnotVec::bezier_knot(2));
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 1.0), Vector3::new(0.5, -1.0, 2.0), Vector3::new(1.0, 0.0, 1.0)],
vec![Vector3::new(0.0, 1.0, 2.0), Vector3::new(0.5, 1.0, 3.0), Vector3::new(1.0, 1.0, 2.0)],
vec![Vector3::new(0.0, 2.0, 2.0), Vector3::new(0.5, 2.0, 3.0), Vector3::new(1.0, 2.0, 2.0)],
vec![Vector3::new(0.0, 3.0, 1.0), Vector3::new(0.5, 3.5, 2.0), Vector3::new(1.0, 3.0, 1.0)],
];
let bspsurface = NURBSSurface::new(BSplineSurface::new(knot_vecs, ctrl_pts));
let curves = bspsurface.splitted_boundary();
assert_eq!(
curves[0].control_points(),
&vec![
Vector3::new(0.0, 0.0, 1.0),
Vector3::new(0.0, 1.0, 2.0),
Vector3::new(0.0, 2.0, 2.0),
Vector3::new(0.0, 3.0, 1.0),
],
);
assert_eq!(
curves[1].control_points(),
&vec![
Vector3::new(0.0, 3.0, 1.0),
Vector3::new(0.5, 3.5, 2.0),
Vector3::new(1.0, 3.0, 1.0),
],
);
assert_eq!(
curves[2].control_points(),
&vec![
Vector3::new(1.0, 3.0, 1.0),
Vector3::new(1.0, 2.0, 2.0),
Vector3::new(1.0, 1.0, 2.0),
Vector3::new(1.0, 0.0, 1.0),
],
);
assert_eq!(
curves[3].control_points(),
&vec![
Vector3::new(1.0, 0.0, 1.0),
Vector3::new(0.5, -1.0, 2.0),
Vector3::new(0.0, 0.0, 1.0),
],
);
Extracts the boundary of surface
impl<V> NURBSSurface<V> where
V: Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace,
<V as Homogeneous<f64>>::Point: Index<usize>,
<V as Homogeneous<f64>>::Point: Bounded<f64>,
<V as Homogeneous<f64>>::Point: Copy,
<<V as Homogeneous<f64>>::Point as MetricSpace>::Metric == f64,
<<V as Homogeneous<f64>>::Point as Index<usize>>::Output == f64,
impl<V> NURBSSurface<V> where
V: Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace,
<V as Homogeneous<f64>>::Point: Index<usize>,
<V as Homogeneous<f64>>::Point: Bounded<f64>,
<V as Homogeneous<f64>>::Point: Copy,
<<V as Homogeneous<f64>>::Point as MetricSpace>::Metric == f64,
<<V as Homogeneous<f64>>::Point as Index<usize>>::Output == f64,
Returns the bounding box including all control points.
Trait Implementations
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<NURBSSurface<V>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<NURBSSurface<V>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Returns whether the curve curve
is included in the surface self
.
Returns whether the curve curve
is included in the surface self
.
Returns whether the curve curve
is included in the surface self
.
Returns the inverse.
impl<V> ParameterDivision2D for NURBSSurface<V> where
V: ControlPoint<f64, Diff = V> + Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace,
<<V as Homogeneous<f64>>::Point as MetricSpace>::Metric == f64,
impl<V> ParameterDivision2D for NURBSSurface<V> where
V: ControlPoint<f64, Diff = V> + Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace,
<<V as Homogeneous<f64>>::Point as MetricSpace>::Metric == f64,
impl<V> ParametricSurface for NURBSSurface<V> where
V: Homogeneous<f64> + ControlPoint<f64, Diff = V>,
impl<V> ParametricSurface for NURBSSurface<V> where
V: Homogeneous<f64> + ControlPoint<f64, Diff = V>,
type Point = <V as Homogeneous<f64>>::Point
type Point = <V as Homogeneous<f64>>::Point
The surface is in the space of Self::Point
.
type Vector = <V as Homogeneous<f64>>::Vector
type Vector = <V as Homogeneous<f64>>::Vector
The derivation vector of the curve.
Substitutes the parameter (u, v)
.
Returns the derivation by u
.
Returns the derivation by v
.
Returns the 2nd-order derivation by u
.
Returns the 2nd-order derivation by both u
and v
.
Returns the 2nd-order derivation by v
.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<V> SearchNearestParameter for NURBSSurface<V> where
V: Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: EuclideanSpace,
<V as Homogeneous<f64>>::Point: MetricSpace,
NURBSSurface<V>: ParametricSurface,
<V as Homogeneous<f64>>::Vector: InnerSpace,
<V as Homogeneous<f64>>::Vector: Tolerance,
<NURBSSurface<V> as ParametricSurface>::Point == <V as Homogeneous<f64>>::Point,
<NURBSSurface<V> as ParametricSurface>::Vector == <V as Homogeneous<f64>>::Vector,
<<V as Homogeneous<f64>>::Point as EuclideanSpace>::Scalar == f64,
<<V as Homogeneous<f64>>::Point as MetricSpace>::Metric == f64,
<<V as Homogeneous<f64>>::Vector as VectorSpace>::Scalar == f64,
impl<V> SearchNearestParameter for NURBSSurface<V> where
V: Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: EuclideanSpace,
<V as Homogeneous<f64>>::Point: MetricSpace,
NURBSSurface<V>: ParametricSurface,
<V as Homogeneous<f64>>::Vector: InnerSpace,
<V as Homogeneous<f64>>::Vector: Tolerance,
<NURBSSurface<V> as ParametricSurface>::Point == <V as Homogeneous<f64>>::Point,
<NURBSSurface<V> as ParametricSurface>::Vector == <V as Homogeneous<f64>>::Vector,
<<V as Homogeneous<f64>>::Point as EuclideanSpace>::Scalar == f64,
<<V as Homogeneous<f64>>::Point as MetricSpace>::Metric == f64,
<<V as Homogeneous<f64>>::Vector as VectorSpace>::Scalar == f64,
Searches the parameter (u, v)
which minimize |self(u, v) - point|
by Newton’s method
with initial guess (u0, v0)
. If the repeated trial does not converge, then returns None
.
Examples
use truck_geometry::*;
let knot_vecs = (KnotVec::bezier_knot(3), KnotVec::bezier_knot(2));
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 1.0), Vector3::new(1.0, -2.0, 2.0), Vector3::new(1.0, 0.0, 1.0)],
vec![Vector3::new(0.0, 2.0, 2.0), Vector3::new(2.0, 4.0, 4.0), Vector3::new(2.0, 2.0, 2.0)],
vec![Vector3::new(0.0, 4.0, 2.0), Vector3::new(2.0, 8.0, 4.0), Vector3::new(2.0, 4.0, 2.0)],
vec![Vector3::new(0.0, 3.0, 1.0), Vector3::new(1.0, 7.0, 2.0), Vector3::new(1.0, 3.0, 1.0)],
];
let surface = NURBSSurface::new(BSplineSurface::new(knot_vecs, ctrl_pts));
let pt = surface.subs(0.3, 0.7);
let (u, v) = surface.search_nearest_parameter(pt, Some((0.5, 0.5)), 100).unwrap();
assert!(u.near(&0.3) && v.near(&0.7));
Remarks
It may converge to a local solution depending on the hint.
cf. BSplineCurve::search_rational_nearest_parameter
type Point = <V as Homogeneous<f64>>::Point
type Point = <V as Homogeneous<f64>>::Point
point
Serach the parameter (u, v)
such that self.subs(u, v).rational_projection()
is near pt
.
If cannot find, then return None
.
Examples
use truck_geometry::*;
let knot_vec = KnotVec::uniform_knot(2, 2);
let ctrl_pts = vec![
vec![Vector4::new(0.0, 0.0, 0.0, 1.0), Vector4::new(0.1, 0.0, 0.5, 0.4), Vector4::new(1.0, 0.0, 0.6, 2.0), Vector4::new(0.4, 0.0, 0.4, 0.4)],
vec![Vector4::new(0.0, 0.2, 0.2, 2.0), Vector4::new(0.24, 0.24, 0.1, 1.2), Vector4::new(2.4, 1.8, 2.4, 0.6), Vector4::new(1.4, 0.42, 0.98, 1.4)],
vec![Vector4::new(0.0, 1.5, 1.2, 3.0), Vector4::new(1.02, 2.04, 1.7, 3.4), Vector4::new(0.42, 0.28, 0.7, 0.7), Vector4::new(0.6, 0.3, 0.0, 0.6)],
vec![Vector4::new(0.0, 1.0, 1.0, 1.0), Vector4::new(0.2, 2.0, 2.0, 2.0), Vector4::new(0.85, 1.7, 0.85, 1.7), Vector4::new(1.0, 1.0, 0.3, 1.0)],
];
let bspsurface = BSplineSurface::new((knot_vec.clone(), knot_vec), ctrl_pts);
let surface = NURBSSurface::new(bspsurface);
let pt = surface.subs(0.3, 0.7);
let (u, v) = surface.search_parameter(pt, Some((0.5, 0.5)), 100).unwrap();
assert_near!(surface.subs(u, v), pt);
Serach the parameter (u, v)
such that self.subs(u, v).rational_projection()
is near pt
.
If cannot find, then return None
.
Examples
use truck_geometry::*;
let knot_vec = KnotVec::uniform_knot(2, 2);
let ctrl_pts = vec![
vec![Vector3::new(0.0, 0.0, 1.0), Vector3::new(0.1, 0.0, 0.5), Vector3::new(0.5, 0.0, 0.3), Vector3::new(1.0, 0.0, 1.0)],
vec![Vector3::new(0.0, 0.1, 0.1), Vector3::new(0.2, 0.2, 0.1), Vector3::new(0.4, 0.3, 0.4), Vector3::new(1.0, 0.3, 0.7)],
vec![Vector3::new(0.0, 0.5, 0.4), Vector3::new(0.3, 0.6, 0.5), Vector3::new(0.6, 0.4, 1.0), Vector3::new(1.0, 0.5, 0.4)],
vec![Vector3::new(0.0, 1.0, 1.0), Vector3::new(0.1, 1.0, 1.0), Vector3::new(0.5, 1.0, 0.5), Vector3::new(1.0, 1.0, 0.3)],
];
let bspsurface = BSplineSurface::new((knot_vec.clone(), knot_vec), ctrl_pts);
let surface = NURBSSurface::new(bspsurface);
let pt = surface.subs(0.3, 0.7);
let (u, v) = surface.search_parameter(pt, Some((0.5, 0.5)), 100).unwrap();
assert_near!(surface.subs(u, v), pt);
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub 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
transform by trans
.
transformed geometry by trans
.
Auto Trait Implementations
impl<V> RefUnwindSafe for NURBSSurface<V> where
V: RefUnwindSafe,
impl<V> Send for NURBSSurface<V> where
V: Send,
impl<V> Sync for NURBSSurface<V> where
V: Sync,
impl<V> Unpin for NURBSSurface<V> where
V: Unpin,
impl<V> UnwindSafe for NURBSSurface<V> where
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more