Enum truck_modeling::base::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> + MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <P as ControlPoint<f64>>::Diff> + Tolerance,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64> + Tolerance,
impl<P> SearchNearestParameter<D1> for BSplineCurve<P>where
P: ControlPoint<f64> + MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <P as ControlPoint<f64>>::Diff> + Tolerance,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64> + Tolerance,
source§fn search_nearest_parameter<H>(
&self,
point: P,
hint: H,
trial: usize
) -> Option<f64>where
H: Into<SPHint1D>,
fn search_nearest_parameter<H>(
&self,
point: P,
hint: H,
trial: usize
) -> Option<f64>where
H: Into<SPHint1D>,
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 SearchNearestParameter<D1> for Curve
impl SearchNearestParameter<D1> for Curve
source§impl<C, S> SearchNearestParameter<D1> for IntersectionCurve<C, S>where
C: ParametricCurve3D + SearchNearestParameter<D1, Point = Point3<f64>>,
S: ParametricSurface3D + SearchNearestParameter<D2, Point = Point3<f64>>,
impl<C, S> SearchNearestParameter<D1> for IntersectionCurve<C, S>where
C: ParametricCurve3D + SearchNearestParameter<D1, Point = Point3<f64>>,
S: ParametricSurface3D + SearchNearestParameter<D2, Point = Point3<f64>>,
Only derive from leading curve. Not precise.
source§impl SearchNearestParameter<D1> for Leader
impl SearchNearestParameter<D1> for Leader
§type Point = <PolylineCurve<Point3<f64>> as SearchNearestParameter<D1>>::Point
type Point = <PolylineCurve<Point3<f64>> as SearchNearestParameter<D1>>::Point
point
source§impl<P> SearchNearestParameter<D1> for Line<P>where
P: ControlPoint<f64>,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64>,
impl<P> SearchNearestParameter<D1> for Line<P>where
P: ControlPoint<f64>,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64>,
source§impl<V> SearchNearestParameter<D1> for NURBSCurve<V>where
V: ControlPoint<f64, Diff = V> + Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace<Metric = f64>,
<<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff: InnerSpace + Tolerance,
impl<V> SearchNearestParameter<D1> for NURBSCurve<V>where
V: ControlPoint<f64, Diff = V> + Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace<Metric = f64>,
<<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff: InnerSpace + Tolerance,
source§fn search_nearest_parameter<H>(
&self,
point: <V as Homogeneous<f64>>::Point,
hint: H,
trial: usize
) -> Option<f64>where
H: Into<SPHint1D>,
fn search_nearest_parameter<H>(
&self,
point: <V as Homogeneous<f64>>::Point,
hint: H,
trial: usize
) -> Option<f64>where
H: Into<SPHint1D>,
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
source§impl<C, S> SearchNearestParameter<D1> for PCurve<C, S>where
<PCurve<C, S> as ParametricCurve>::Point: MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <PCurve<C, S> as ParametricCurve>::Vector>,
PCurve<C, S>: BoundedCurve,
<PCurve<C, S> as ParametricCurve>::Vector: InnerSpace<Scalar = f64> + Tolerance,
impl<C, S> SearchNearestParameter<D1> for PCurve<C, S>where
<PCurve<C, S> as ParametricCurve>::Point: MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <PCurve<C, S> as ParametricCurve>::Vector>,
PCurve<C, S>: BoundedCurve,
<PCurve<C, S> as ParametricCurve>::Vector: InnerSpace<Scalar = f64> + Tolerance,
§type Point = <PCurve<C, S> as ParametricCurve>::Point
type Point = <PCurve<C, S> as ParametricCurve>::Point
point
source§impl<P> SearchNearestParameter<D1> for PolylineCurve<P>where
P: ControlPoint<f64>,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64>,
impl<P> SearchNearestParameter<D1> for PolylineCurve<P>where
P: ControlPoint<f64>,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64>,
source§impl<C> SearchNearestParameter<D1> for TrimmedCurve<C>where
C: SearchNearestParameter<D1>,
impl<C> SearchNearestParameter<D1> for TrimmedCurve<C>where
C: SearchNearestParameter<D1>,
§type Point = <C as SearchNearestParameter<D1>>::Point
type Point = <C as SearchNearestParameter<D1>>::Point
point
source§impl SearchNearestParameter<D1> for UnitCircle<Point2<f64>>
impl SearchNearestParameter<D1> for UnitCircle<Point2<f64>>
source§impl SearchNearestParameter<D1> for UnitCircle<Point3<f64>>
impl SearchNearestParameter<D1> for UnitCircle<Point3<f64>>
source§impl SearchNearestParameter<D1> for UnitHyperbola<Point2<f64>>
impl SearchNearestParameter<D1> for UnitHyperbola<Point2<f64>>
source§impl SearchNearestParameter<D1> for UnitHyperbola<Point3<f64>>
impl SearchNearestParameter<D1> for UnitHyperbola<Point3<f64>>
source§impl SearchNearestParameter<D1> for UnitParabola<Point2<f64>>
impl SearchNearestParameter<D1> for UnitParabola<Point2<f64>>
source§impl SearchNearestParameter<D1> for UnitParabola<Point3<f64>>
impl SearchNearestParameter<D1> for UnitParabola<Point3<f64>>
source§impl<P> SearchParameter<D1> for BSplineCurve<P>where
P: ControlPoint<f64> + MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <P as ControlPoint<f64>>::Diff>,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64> + Tolerance,
impl<P> SearchParameter<D1> for BSplineCurve<P>where
P: ControlPoint<f64> + MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <P as ControlPoint<f64>>::Diff>,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64> + Tolerance,
source§impl SearchParameter<D1> for Curve
impl SearchParameter<D1> for Curve
source§impl<C, S> SearchParameter<D1> for IntersectionCurve<C, S>where
C: ParametricCurve3D + SearchNearestParameter<D1, Point = Point3<f64>>,
S: ParametricSurface3D + SearchNearestParameter<D2, Point = Point3<f64>>,
impl<C, S> SearchParameter<D1> for IntersectionCurve<C, S>where
C: ParametricCurve3D + SearchNearestParameter<D1, Point = Point3<f64>>,
S: ParametricSurface3D + SearchNearestParameter<D2, Point = Point3<f64>>,
source§impl SearchParameter<D1> for Leader
impl SearchParameter<D1> for Leader
source§impl<P> SearchParameter<D1> for Line<P>where
P: ControlPoint<f64> + Tolerance,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64>,
impl<P> SearchParameter<D1> for Line<P>where
P: ControlPoint<f64> + Tolerance,
<P as ControlPoint<f64>>::Diff: InnerSpace<Scalar = f64>,
source§impl<V> SearchParameter<D1> for NURBSCurve<V>where
V: ControlPoint<f64, Diff = V> + Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace<Metric = f64>,
<<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff: InnerSpace + Tolerance,
impl<V> SearchParameter<D1> for NURBSCurve<V>where
V: ControlPoint<f64, Diff = V> + Homogeneous<f64>,
<V as Homogeneous<f64>>::Point: MetricSpace<Metric = f64>,
<<V as Homogeneous<f64>>::Point as EuclideanSpace>::Diff: InnerSpace + Tolerance,
source§impl<C, S> SearchParameter<D1> for PCurve<C, S>where
<PCurve<C, S> as ParametricCurve>::Point: MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <PCurve<C, S> as ParametricCurve>::Vector>,
PCurve<C, S>: BoundedCurve,
<PCurve<C, S> as ParametricCurve>::Vector: InnerSpace<Scalar = f64> + Tolerance,
impl<C, S> SearchParameter<D1> for PCurve<C, S>where
<PCurve<C, S> as ParametricCurve>::Point: MetricSpace<Metric = f64> + EuclideanSpace<Scalar = f64, Diff = <PCurve<C, S> as ParametricCurve>::Vector>,
PCurve<C, S>: BoundedCurve,
<PCurve<C, S> as ParametricCurve>::Vector: InnerSpace<Scalar = f64> + Tolerance,
§type Point = <PCurve<C, S> as ParametricCurve>::Point
type Point = <PCurve<C, S> as ParametricCurve>::Point
point