Struct truck_geometry::nurbs::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 knot vectors

Returns the u knot vector.

Returns the v knot vector.

Returns the idxth u knot.

returns the idxth v knot.

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_idxth 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_idxth 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 idxth column control points of self.

Creates the column sectional curve.

Substitutes to a NURBS surface.

Substitutes derived NURBS surface by the first parameter u.

Substitutes derived NURBS surface by the first parameter v.

Substitutes 2nd-ord derived NURBS surface by the first parameter u.

Substitutes 2nd-ord derived NURBS surface by the first parameter v.

Substitutes 2nd-ord derived NURBS surface by both parameter u, v.

Returns the closure of substitution.

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

Returns the bounding box including all control points.

Trait Implementations

The range of the parameter of the surface.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

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.

Inverts self

Returns the inverse.

Creates the surface division Read more

The surface is in the space of Self::Point.

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.

Returns the normal vector at (u, v).

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

point

curve => f64, surface => (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, Some((0.5, 0.5)), 100).unwrap();
assert_near!(surface.subs(u, v), pt);

point

curve => f64, surface => (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, Some((0.5, 0.5)), 100).unwrap();
assert_near!(surface.subs(u, v), pt);

point

curve => f64, surface => (f64, f64)

Serialize this value into the given Serde serializer. Read more

transform by trans.

transformed geometry by trans.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.