[−][src]Struct truck_geometry::NURBSSurface
NURBS surface
Implementations
impl<V> NURBSSurface<V>
[src]
pub const fn new(bspsurface: BSplineSurface<V>) -> Self
[src]
constructor
pub fn non_rationalized(&self) -> &BSplineSurface<V>
[src]
Returns the nurbs surface before rationalized
pub fn non_rationalized_mut(&mut self) -> &mut BSplineSurface<V>
[src]
Returns the nurbs surface before rationalized
pub fn into_non_rationalized(self) -> BSplineSurface<V>
[src]
Returns the nurbs surface before rationalized
pub fn knot_vecs(&self) -> &(KnotVec, KnotVec)
[src]
Returns the reference of the knot vectors
pub fn uknot_vec(&self) -> &KnotVec
[src]
Returns the u knot vector.
pub fn vknot_vec(&self) -> &KnotVec
[src]
Returns the v knot vector.
pub fn uknot(&self, idx: usize) -> f64
[src]
Returns the idx
th u knot.
pub fn vknot(&self, idx: usize) -> f64
[src]
returns the idx
th v knot.
pub fn control_points(&self) -> &Vec<Vec<V>>
[src]
Returns the reference of the vector of the control points
pub fn control_point(&self, idx0: usize, idx1: usize) -> &V
[src]
Returns the reference of the control point corresponding to the index (idx0, idx1)
.
pub fn transform_control_points<F: FnMut(&mut V)>(&mut self, f: F)
[src]
Apply the given transformation to all control points.
pub fn ctrl_pts_row_iter(&self, column_idx: usize) -> CPRowIter<'_, V>ⓘ
[src]
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);
pub fn ctrl_pts_column_iter(&self, row_idx: usize) -> CPColumnIter<'_, V>
[src]
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);
pub fn control_point_mut(&mut self, idx0: usize, idx1: usize) -> &mut V
[src]
Returns the mutable reference of the control point corresponding to index (idx0, idx1)
.
pub fn control_points_mut(&mut self) -> impl Iterator<Item = &mut V>
[src]
Returns the iterator on all control points
pub fn udegree(&self) -> usize
[src]
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);
pub fn vdegree(&self) -> usize
[src]
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);
pub fn degrees(&self) -> (usize, usize)
[src]
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));
pub fn is_clamped(&self) -> bool
[src]
Returns whether the knot vectors are clamped or not.
pub fn swap_axes(&mut self) -> &mut Self where
V: Clone,
[src]
V: Clone,
Swaps two parameters.
pub fn parameter_range(&self) -> ((f64, f64), (f64, f64))
[src]
The range of the parameter of the surface.
pub fn column_curve(&self, row_idx: usize) -> NURBSCurve<V> where
V: Clone,
[src]
V: Clone,
Creates the curve whose control points are the idx
th column control points of self
.
pub fn row_curve(&self, column_idx: usize) -> NURBSCurve<V> where
V: Clone,
[src]
V: Clone,
Creates the column sectional curve.
impl<V: Homogeneous<f64>> NURBSSurface<V>
[src]
pub fn subs(&self, u: f64, v: f64) -> V::Point
[src]
Substitutes to a NURBS surface.
pub fn uder(&self, u: f64, v: f64) -> <V::Point as EuclideanSpace>::Diff
[src]
Substitutes derived NURBS surface by the first parameter u
.
pub fn vder(&self, u: f64, v: f64) -> <V::Point as EuclideanSpace>::Diff
[src]
Substitutes derived NURBS surface by the first parameter v
.
pub fn get_closure(&self) -> impl Fn(f64, f64) -> V::Point + '_
[src]
Returns the closure of substitution.
impl<V: Homogeneous<f64>> NURBSSurface<V> where
V::Point: Tolerance,
[src]
V::Point: Tolerance,
pub fn is_const(&self) -> bool
[src]
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());
pub fn near_as_surface(&self, other: &Self) -> bool
[src]
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));
pub fn near2_as_surface(&self, other: &Self) -> bool
[src]
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));
impl<V: Homogeneous<f64> + Tolerance> NURBSSurface<V>
[src]
pub fn add_uknot(&mut self, x: f64) -> &mut Self
[src]
Adds a knot x
of the first parameter u
, and do not change self
as a surface.
pub fn add_vknot(&mut self, x: f64) -> &mut Self
[src]
Adds a knot x
of the first parameter u
, and do not change self
as a surface.
pub fn try_remove_uknot(&mut self, idx: usize) -> Result<&mut Self>
[src]
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
.
pub fn remove_uknot(&mut self, idx: usize) -> &mut Self
[src]
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
.
pub fn try_remove_vknot(&mut self, idx: usize) -> Result<&mut Self>
[src]
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
.
pub fn remove_vknot(&mut self, idx: usize) -> &mut Self
[src]
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
.
pub fn elevate_udegree(&mut self) -> &mut Self
[src]
Elevates the udegree.
pub fn elevate_vdegree(&mut self) -> &mut Self
[src]
Elevates the vdegree.
pub fn syncro_uvdegrees(&mut self) -> &mut Self
[src]
Aligns the udegree with the same degrees.
pub fn syncro_uvknots(&mut self) -> &mut Self
[src]
Makes the uknot vector and the vknot vector the same knot vector.
impl<V: Homogeneous<f64>> NURBSSurface<V> where
<V::Point as EuclideanSpace>::Diff: InnerSpace,
[src]
<V::Point as EuclideanSpace>::Diff: InnerSpace,
pub fn search_nearest_parameter(
&self,
pt: V::Point,
(u0, v0): (f64, f64)
) -> Option<(f64, f64)>
[src]
&self,
pt: V::Point,
(u0, v0): (f64, f64)
) -> Option<(f64, 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, (0.5, 0.5)).unwrap(); assert!(u.near2(&0.3) && v.near2(&0.7));
Remarks
It may converge to a local solution depending on the hint.
cf. BSplineCurve::search_rational_nearest_parameter
impl NURBSSurface<Vector3>
[src]
pub fn search_parameter(
&self,
pt: Point2,
hint: (f64, f64)
) -> Option<(f64, f64)>
[src]
&self,
pt: Point2,
hint: (f64, f64)
) -> Option<(f64, f64)>
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, (0.5, 0.5)).unwrap(); Point2::assert_near(&surface.subs(u, v), &pt);
impl NURBSSurface<Vector4>
[src]
pub fn search_parameter(
&self,
pt: Point3,
hint: (f64, f64)
) -> Option<(f64, f64)>
[src]
&self,
pt: Point3,
hint: (f64, f64)
) -> Option<(f64, f64)>
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, (0.5, 0.5)).unwrap(); Point3::assert_near(&surface.subs(u, v), &pt);
Trait Implementations
impl<V: Clone> Clone for NURBSSurface<V>
[src]
pub fn clone(&self) -> NURBSSurface<V>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<V: Debug> Debug for NURBSSurface<V>
[src]
impl<'de, V> Deserialize<'de> for NURBSSurface<V> where
V: Deserialize<'de>,
[src]
V: Deserialize<'de>,
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<V: Homogeneous<f64>> ParameterDivision2D for NURBSSurface<V> where
V::Point: MetricSpace<Metric = f64>,
[src]
V::Point: MetricSpace<Metric = f64>,
impl<V: PartialEq> PartialEq<NURBSSurface<V>> for NURBSSurface<V>
[src]
pub fn eq(&self, other: &NURBSSurface<V>) -> bool
[src]
pub fn ne(&self, other: &NURBSSurface<V>) -> bool
[src]
impl<V> Serialize for NURBSSurface<V> where
V: Serialize,
[src]
V: Serialize,
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<V> StructuralPartialEq for NURBSSurface<V>
[src]
impl Surface for NURBSSurface<Vector3>
[src]
type Point = Point2
The surface is in the space of Self::Point
.
type Vector = Vector2
The derivation vector of the curve.
type Curve = NURBSCurve<Vector3>
The boundary curve
pub fn subs(&self, u: f64, v: f64) -> Self::Point
[src]
pub fn uder(&self, u: f64, v: f64) -> Self::Vector
[src]
pub fn vder(&self, u: f64, v: f64) -> Self::Vector
[src]
pub fn normal(&self, _: f64, _: f64) -> Self::Vector
[src]
zero identity
pub fn parameter_range(&self) -> ((f64, f64), (f64, f64))
[src]
pub fn inverse(&self) -> Self
[src]
pub fn include(&self, curve: &Self::Curve) -> bool
[src]
impl Surface for NURBSSurface<Vector4>
[src]
type Point = Point3
The surface is in the space of Self::Point
.
type Vector = Vector3
The derivation vector of the curve.
type Curve = NURBSCurve<Vector4>
The boundary curve
pub fn subs(&self, u: f64, v: f64) -> Self::Point
[src]
pub fn uder(&self, u: f64, v: f64) -> Self::Vector
[src]
pub fn vder(&self, u: f64, v: f64) -> Self::Vector
[src]
pub fn normal(&self, u: f64, v: f64) -> Self::Vector
[src]
pub fn parameter_range(&self) -> ((f64, f64), (f64, f64))
[src]
pub fn inverse(&self) -> Self
[src]
pub fn include(&self, curve: &Self::Curve) -> bool
[src]
Auto Trait Implementations
impl<V> RefUnwindSafe for NURBSSurface<V> where
V: RefUnwindSafe,
[src]
V: RefUnwindSafe,
impl<V> Send for NURBSSurface<V> where
V: Send,
[src]
V: Send,
impl<V> Sync for NURBSSurface<V> where
V: Sync,
[src]
V: Sync,
impl<V> Unpin for NURBSSurface<V> where
V: Unpin,
[src]
V: Unpin,
impl<V> UnwindSafe for NURBSSurface<V> where
V: UnwindSafe,
[src]
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,