Skip to main content

BSplineCurve

Struct BSplineCurve 

Source
pub struct BSplineCurve { /* private fields */ }
Expand description

A B-spline curve, polynomial or rational.

Implementations§

Source§

impl BSplineCurve

Source

pub fn restricted_to_degree( &self, max_degree: usize, tolerance: f64, tol: Tolerances, ) -> OgeomResult<Fitted<Self>>

This curve at a degree no higher than max_degree, to a stated tolerance: itself where it already is, and otherwise a fit at its own parameters: what an exchange format with a degree limit needs written. Same-parameter with the original, error measured.

§Errors

OgeomError::Construction if max_degree is zero, the curve is periodic (a ring has no ends to fit between), or the tolerance is not a distance.

Source§

impl BSplineCurve

Source

pub fn new( knots: KnotVector, control: Vec<Point>, tol: Tolerances, ) -> OgeomResult<Self>

A polynomial B-spline from a knot vector and control points.

§Errors

OgeomError::Dimension if the control point count disagrees with the knot vector.

Source

pub fn rational( knots: KnotVector, control: Vec<Weighted<Point>>, ) -> OgeomResult<Self>

A rational B-spline from a knot vector and weighted control points.

§Errors

OgeomError::Dimension if the control point count disagrees with the knot vector.

Source

pub fn periodic( control: &[Point], degree: usize, tol: Tolerances, ) -> OgeomResult<Self>

A smoothly periodic B-spline through a ring of control points.

The ring is wrapped: the first degree controls repeat past the end over a uniform knot vector, and evaluation wraps its parameter, so the loop closes with degree - 1 continuous derivatives and no clamped seam. The domain runs one knot step per ring point.

§Errors

OgeomError::Construction if the ring has no more points than the degree, or the degree is zero.

Source

pub fn periodic_from_parts( knots: KnotVector, control: Vec<Weighted<Point>>, tol: Tolerances, ) -> OgeomResult<Self>

The exact periodic representation, as a reader restores it: wrapped knots and control, with the wrap verified rather than assumed.

§Errors

As BSplineCurve::rational, and additionally if the trailing degree controls do not repeat the leading ones; an unwrapped ring evaluated periodically would tear at the seam.

Source

pub const fn knots(&self) -> &KnotVector

The knot vector.

Source

pub fn control_points(&self) -> &[Weighted<Point>]

The weighted control points.

Source

pub const fn is_rational(&self) -> bool

Whether the weights differ, so the curve is genuinely rational.

Source

pub const fn degree(&self) -> usize

The degree.

Source

pub fn with_knot_inserted( &self, u: f64, count: usize, tol: Tolerances, ) -> OgeomResult<Self>

Insert a knot without moving the curve.

§Errors

As [bspline::insert_knot].

Source

pub fn elevated(&self, tol: Tolerances) -> OgeomResult<Self>

Raise the degree without moving the curve.

§Errors

As [bspline::elevate_degree].

Source

pub fn reseamed_at(&self, u: f64, tol: Tolerances) -> OgeomResult<Self>

The same closed curve with its seam moved to u: what was the stretch from u to the end now comes first, and the stretch from the start to u follows it, joined where the old seam was. The domain keeps its length and begins at u.

§Errors

OgeomError::Construction if the curve is periodic (its seam is nowhere) or does not close, its two ends apart by more than a thousand confusions; as [bspline::split] if u is an end of the domain.

Source

pub fn extended( &self, at_end: bool, length: f64, continuity: usize, tol: Tolerances, ) -> OgeomResult<Self>

This curve continued past one end by length in space: the polynomial continuation of its own end derivatives to the order continuity, joined on. A polynomial run of degree at most that order continues as itself, and so does a rational arc’s homogeneous polynomial: a circle arc continued at order two stays on its circle.

The continuation’s parameter span is solved until its arc length is length. Extended at the start, the original run keeps its parameters and the domain grows downward.

§Errors

OgeomError::Construction if the curve is periodic (it has no end to continue from) or stands still at that end; as [bspline::extend].

Source

pub fn extended_to( &self, at_end: bool, target: Point, continuity: usize, tol: Tolerances, ) -> OgeomResult<Self>

This curve continued past one end to target: a piece carrying the curve’s end derivatives to the order continuity and ending at the point, joined on. Extended at the start, the original run keeps its parameters and the domain grows downward.

§Errors

OgeomError::Construction if the curve is periodic, stands still at that end, or already ends at target; as [bspline::extend_to].

Source

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

The piece of this curve over range, exactly and keeping its parameters: the piece at t is this curve at t.

§Errors

OgeomError::Domain if range is empty or leaves the domain.

Source

pub fn split_at(&self, u: f64, tol: Tolerances) -> OgeomResult<(Self, Self)>

Split into two curves meeting at u.

§Errors

As [bspline::split].

Trait Implementations§

Source§

impl Clone for BSplineCurve

Source§

fn clone(&self) -> BSplineCurve

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 BSplineCurve

Source§

fn continuity(&self) -> Continuity

Continuity across the whole curve.

A degree-p B-spline is C^(p - m) at an interior knot of multiplicity m, and the worst interior knot governs the curve. With no interior knots at all the curve is a single polynomial piece and so genuinely smooth to every order.

Higher orders than C2 report as C2, which is the highest Continuity names short of CInfinity. Reporting CInfinity for a merely-C3 curve would be a claim that is false, and the distinction above C2 is not one any algorithm here asks about.

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 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 BSplineCurve

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 PartialEq for BSplineCurve

Source§

fn eq(&self, other: &BSplineCurve) -> 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 StructuralPartialEq for BSplineCurve

Auto Trait Implementations§

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.