Enum truck_modeling::base::D1

source ·
pub enum D1 {}
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

Searches the parameter t which minimize |self(t) - point| by Newton’s method with initial guess hint. Returns None if the number of attempts exceeds trial i.e. if trial == 0, then the trial is only one time.

Examples
use truck_geometry::*;
let knot_vec = KnotVec::from(
    vec![0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0]
);
let ctrl_pts = vec![
    Point3::new(0.0, 0.0, 0.0),
    Point3::new(1.0, 0.0, 0.0),
    Point3::new(1.0, 1.0, 0.0),
    Point3::new(0.0, 1.0, 0.0),
    Point3::new(0.0, 1.0, 1.0),
];
let bspcurve = BSplineCurve::new(knot_vec, ctrl_pts);
let pt = ParametricCurve::subs(&bspcurve, 1.2);
let t = bspcurve.search_nearest_parameter(pt, Some(0.8), 100).unwrap();
assert_near!(t, 1.2);
Remarks

It may converge to a local solution depending on the hint.

use truck_geometry::*;
let knot_vec = KnotVec::from(
    vec![0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0]
);
let ctrl_pts = vec![
    Point3::new(0.0, 0.0, 0.0),
    Point3::new(1.0, 0.0, 0.0),
    Point3::new(1.0, 1.0, 0.0),
    Point3::new(0.0, 1.0, 0.0),
    Point3::new(0.0, 1.0, 1.0),
];
let bspcurve = BSplineCurve::new(knot_vec, ctrl_pts);
let pt = Point3::new(0.0, 0.5, 1.0);
let t = bspcurve.search_nearest_parameter(pt, Some(0.8), 100).unwrap();
let pt0 = ParametricCurve::subs(&bspcurve, t);
let pt1 = ParametricCurve::subs(&bspcurve, 3.0);
// the point corresponding the obtained parameter is not
// the globally nearest point in the curve.
assert!((pt0 - pt).magnitude() > (pt1 - pt).magnitude());
point
point
Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter.

Only derive from leading curve. Not precise.

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.

Searches the parameter t which minimize |self(t) - point| by Newton’s method with initial guess hint. Returns None if the number of attempts exceeds trial i.e. if trial == 0, then the trial is only one time.

Examples
use truck_geometry::*;

// Defines the half unit circle in x > 0.
let knot_vec = KnotVec::bezier_knot(2);
let ctrl_pts = vec![Vector3::new(0.0, -1.0, 1.0), Vector3::new(1.0, 0.0, 0.0), Vector3::new(0.0, 1.0, 1.0)];
let curve = NURBSCurve::new(BSplineCurve::new(knot_vec, ctrl_pts));

// search rational nearest parameter
let pt = Point2::new(1.0, 2.0);
let hint = 0.8;
let t = curve.search_nearest_parameter(pt, Some(hint), 100).unwrap();

// check the answer
let res = curve.subs(t);
let ans = Point2::from_vec(pt.to_vec().normalize());
assert_near!(res, ans);
Remarks

It may converge to a local solution depending on the hint.

use truck_geometry::*;

// Same curve and point as above example
let knot_vec = KnotVec::bezier_knot(2);
let ctrl_pts = vec![Vector3::new(0.0, -1.0, 1.0), Vector3::new(1.0, 0.0, 0.0), Vector3::new(0.0, 1.0, 1.0)];
let curve = NURBSCurve::new(BSplineCurve::new(knot_vec, ctrl_pts));
let pt = Point2::new(1.0, 2.0);

// another hint
let hint = 0.5;

// Newton's method is vibration divergent.
assert!(curve.search_nearest_parameter(pt, Some(hint), 100).is_none());
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 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 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.
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.
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.
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.