Enum truck_modeling::base::D2

source ·
pub enum D2 {}
Expand description

curve geometry

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
dimension
parameter type, curve => f64, surface => (f64, f64)
SPHintXX
point
Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter.
point
Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter.

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
point
Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter.
point
Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter.
point
Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter.
point
Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter.
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.

Search 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

Search 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
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.
point
Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.