Skip to main content

Curve

Enum Curve 

Source
pub enum Curve {
    Line(LineCurve),
    Circle(CircleCurve),
    Ellipse(EllipseCurve),
    Hyperbola(HyperbolaCurve),
    Parabola(ParabolaCurve),
    BSpline(BSplineCurve),
    Helix(HelixCurve),
    Trimmed(Box<TrimmedCurve>),
    Offset(Box<OffsetCurve>),
    OnSurface(Box<CurveOnSurface>),
}
Expand description

A curve in space.

Variants§

§

Line(LineCurve)

A straight line.

§

Circle(CircleCurve)

A circle or arc.

§

Ellipse(EllipseCurve)

An ellipse or arc.

§

Hyperbola(HyperbolaCurve)

One branch of a hyperbola.

§

Parabola(ParabolaCurve)

A parabola.

§

BSpline(BSplineCurve)

A polynomial or rational B-spline.

§

Helix(HelixCurve)

A helix about an axis, the one transcendental the vocabulary keeps.

§

Trimmed(Box<TrimmedCurve>)

Another curve restricted to a sub-interval.

§

Offset(Box<OffsetCurve>)

A curve at a constant distance from another, offset in the plane perpendicular to a reference direction.

§

OnSurface(Box<CurveOnSurface>)

A surface curve: a pcurve composed with the surface it is drawn on.

Implementations§

Source§

impl Curve

Source

pub fn to_bspline(&self, tol: Tolerances) -> OgeomResult<BSplineCurve>

This curve as a B-spline, exactly, over [0, 1].

Exact rather than fitted: the result passes through the same points as the original at corresponding parameters, to rounding. The correspondence is not the identity; see the module documentation for why it cannot be.

§Errors

OgeomError::Construction if the curve’s range is degenerate or its geometry cannot be evaluated.

Source

pub fn to_bspline_over( &self, range: (f64, f64), tol: Tolerances, ) -> OgeomResult<BSplineCurve>

This curve as a B-spline over part of its range.

The span is what gets converted, rather than the whole curve being converted and then trimmed. For a conic those differ: trimming a rational quadratic needs knot insertion at a parameter that has to be solved for, while building the arc directly is a closed form.

§Errors

As Curve::to_bspline.

Source§

impl Curve

A spline over [0, 1], whatever it was over.

Source

pub fn fitted_bspline_over( &self, range: (f64, f64), tolerance: f64, tol: Tolerances, ) -> OgeomResult<Fitted<BSplineCurve>>

This curve as a B-spline fitted over range to a stated tolerance, at the curve’s own parameters.

The approximation Curve::to_bspline refuses to make silently: a helix, an offset curve, a curve on a surface (anything with no exact rational form) is sampled at its own parameters and fitted through them, the fit measured against the curve between the samples as well as at them, and the sampling doubled until the tolerance is met or the budget runs out. The result is same-parameter with the curve, so every chart already speaking the curve’s parameter still does, and its error is what was measured, not what was asked.

§Errors

OgeomError::Construction if the range is empty or the tolerance is not a distance; as fit::fit_points_at.

Source§

impl Curve

Source

pub fn general_transformed( &self, t: &GeneralTransform, tol: Tolerances, ) -> OgeomResult<BSplineCurve>

This curve carried through a general affine transform.

A shear or an uneven scale is not a placement: it carries a circle to an ellipse, and an ellipse to a conic with no analytic name here. So the curve is converted to its exact B-spline form first and the control points are moved, which an affine map does exactly: a B-spline is an affine combination of its control points, so transforming them and transforming every point of the curve are the same thing.

The result is a B-spline whatever went in, and its parameterization is the converted one rather than the original. That is the price of a transform the analytic types cannot express, and it is why transformed takes only a Transform: a placement keeps the type, and only this does not.

§Errors

As Curve::to_bspline, plus OgeomError::Construction if the transform collapses the curve to a point.

Trait Implementations§

Source§

impl Clone for Curve

Source§

fn clone(&self) -> Curve

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Curve3d for Curve

Source§

fn domain(&self) -> (f64, f64)

The parameter interval over which the curve is defined.
Source§

fn point_at(&self, u: f64, tol: Tolerances) -> OgeomResult<Point>

The point at u. Read more
Source§

fn d1_at(&self, u: f64, tol: Tolerances) -> OgeomResult<Vector>

The first derivative at u. Read more
Source§

fn derivatives_at( &self, u: f64, n: usize, tol: Tolerances, ) -> OgeomResult<Vec<Vector>>

Derivatives up to order n, with result[0] the point itself. Read more
Source§

fn kind(&self) -> CurveKind

What kind of curve this is.
Source§

fn continuity(&self) -> Continuity

How smooth the curve is across its domain.
Source§

fn is_closed(&self, tol: Tolerances) -> bool

Whether the curve’s ends meet.
Source§

fn is_periodic(&self) -> bool

Whether the curve continues past its domain by repeating. Read more
Source§

fn tangent_at(&self, u: f64, tol: Tolerances) -> OgeomResult<Direction>

The unit tangent at u. Read more
Source§

fn curvature_at(&self, u: f64, tol: Tolerances) -> OgeomResult<f64>

The curvature at u. Read more
Source§

fn start(&self, tol: Tolerances) -> OgeomResult<Point>

The start point. Read more
Source§

fn end(&self, tol: Tolerances) -> OgeomResult<Point>

The end point. Read more
Source§

fn normalize_parameter(&self, u: f64, tol: Tolerances) -> OgeomResult<f64>

Bring u into the domain, wrapping if the curve is periodic. Read more
Source§

impl Debug for Curve

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<BSplineCurve> for Curve

Source§

fn from(c: BSplineCurve) -> Self

Converts to this type from the input type.
Source§

impl From<CircleCurve> for Curve

Source§

fn from(c: CircleCurve) -> Self

Converts to this type from the input type.
Source§

impl From<EllipseCurve> for Curve

Source§

fn from(c: EllipseCurve) -> Self

Converts to this type from the input type.
Source§

impl From<HelixCurve> for Curve

Source§

fn from(c: HelixCurve) -> Self

Converts to this type from the input type.
Source§

impl From<HyperbolaCurve> for Curve

Source§

fn from(c: HyperbolaCurve) -> Self

Converts to this type from the input type.
Source§

impl From<LineCurve> for Curve

Source§

fn from(c: LineCurve) -> Self

Converts to this type from the input type.
Source§

impl From<ParabolaCurve> for Curve

Source§

fn from(c: ParabolaCurve) -> Self

Converts to this type from the input type.
Source§

impl From<TrimmedCurve> for Curve

Source§

fn from(c: TrimmedCurve) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Curve

Source§

fn eq(&self, other: &Curve) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Reversible for Curve

Source§

fn reversed(&self) -> Self

This geometry with its parameter direction reversed. Read more
Source§

impl StructuralPartialEq for Curve

Source§

impl Transformable for Curve

Source§

fn transformed(&self, t: &Transform, tol: Tolerances) -> OgeomResult<Self>

This geometry moved by t. Read more

Auto Trait Implementations§

§

impl Freeze for Curve

§

impl RefUnwindSafe for Curve

§

impl Send for Curve

§

impl Sync for Curve

§

impl Unpin for Curve

§

impl UnsafeUnpin for Curve

§

impl UnwindSafe for Curve

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.