Enum truck_geometry::base::traits::D1
source · pub enum D1 {}
Expand description
curve geometry
Trait Implementations§
source§impl SPDimension for D1
impl SPDimension for D1
source§impl<P> SearchNearestParameter<D1> for BSplineCurve<P>where
P: ControlPoint<f64> + EuclideanSpace<Scalar = f64, Diff = <P as ControlPoint<f64>>::Diff> + MetricSpace<Metric = f64> + Tolerance,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64> + Tolerance,
impl<P> SearchNearestParameter<D1> for BSplineCurve<P>where
P: ControlPoint<f64> + EuclideanSpace<Scalar = f64, Diff = <P as ControlPoint<f64>>::Diff> + MetricSpace<Metric = f64> + Tolerance,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64> + Tolerance,
source§fn search_nearest_parameter<H: Into<SPHint1D>>(
&self,
point: P,
hint: H,
trial: usize
) -> Option<f64>
fn search_nearest_parameter<H: Into<SPHint1D>>(
&self,
point: P,
hint: H,
trial: usize
) -> Option<f64>
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());
source§impl<C, S> SearchNearestParameter<D1> for IntersectionCurve<C, S>where
C: ParametricCurve3D + SearchNearestParameter<D1, Point = Point3>,
S: ParametricSurface3D + SearchNearestParameter<D2, Point = Point3>,
impl<C, S> SearchNearestParameter<D1> for IntersectionCurve<C, S>where
C: ParametricCurve3D + SearchNearestParameter<D1, Point = Point3>,
S: ParametricSurface3D + SearchNearestParameter<D2, Point = Point3>,
Only derive from leading curve. Not precise.
source§impl<P> SearchNearestParameter<D1> for Line<P>where
P: ControlPoint<f64>,
P::Diff: InnerSpace<Scalar = f64>,
impl<P> SearchNearestParameter<D1> for Line<P>where
P: ControlPoint<f64>,
P::Diff: InnerSpace<Scalar = f64>,
source§impl<V: Homogeneous<f64> + ControlPoint<f64, Diff = V>> SearchNearestParameter<D1> for NURBSCurve<V>where
V::Point: MetricSpace<Metric = f64>,
<V::Point as EuclideanSpace>::Diff: InnerSpace + Tolerance,
impl<V: Homogeneous<f64> + ControlPoint<f64, Diff = V>> SearchNearestParameter<D1> for NURBSCurve<V>where
V::Point: MetricSpace<Metric = f64>,
<V::Point as EuclideanSpace>::Diff: InnerSpace + Tolerance,
source§fn search_nearest_parameter<H: Into<SPHint1D>>(
&self,
point: V::Point,
hint: H,
trial: usize
) -> Option<f64>
fn search_nearest_parameter<H: Into<SPHint1D>>(
&self,
point: V::Point,
hint: H,
trial: usize
) -> Option<f64>
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());
§type Point = <V as Homogeneous<f64>>::Point
type Point = <V as Homogeneous<f64>>::Point
point