/** @packageDocumentation * @module Bspline */ /** * B-spline curve and surface types in this library are non-periodic. But they can be created from legacy periodic data. * This enumeration lists the possible ways a B-spline object can have been created from legacy periodic data. * @public */ export declare enum BSplineWrapMode { /** No conversion performed. */ None = 0, /** * The legacy periodic B-spline data was opened up by adding `degree` wrap-around poles. * * This is typical of B-spline curves and surfaces constructed with maximum `degree - 1` continuity. * * Knots are unaffected by this conversion. */ OpenByAddingControlPoints = 1, /** * The legacy periodic B-spline data was opened up by removing `degree` exterior knots. * * This is typical of rational B-spline curves representing full circles and ellipses. * * Poles are unaffected by this conversion. */ OpenByRemovingKnots = 2 } /** * Array of non-decreasing numbers acting as a knot vector for B-spline curves and surfaces. * * * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1 * * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation * and Parasolid) demand order knots at each end for clamping. However, only order-1 are really needed. This class uses the * order-1 convention. * * A span is a single interval of the knots. * * The left knot of the span with index `k>=0` is the knot with index `k+degree-1`. * * A knot vector is clamped when the first `degree` knots are equal and the last `degree` knots are equal. * * The "active knot interval" is the subset of the knot vector sans its first and last `degree-1` knots, and serves as * the parametric domain of the associated B-spline object. * * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot. * * Callers need to distinguish core computational inputs such as left knot index, knot value, span index, and span fraction. * @public */ export declare class KnotVector { /** The simple array of knot values. */ knots: Float64Array; /** The degree of basis functions defined in these knots. */ degree: number; /** The leftmost knot value (of the active interval, ignoring unclamped leading knots). */ private _knot0; /** The rightmost knot value (of the active interval, ignoring unclamped leading knots). */ private _knot1; private _wrapMode?; /** Tolerance for considering two knots to be the same. */ static readonly knotTolerance = 1e-9; /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots). */ get leftKnot(): number; /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots). */ get rightKnot(): number; /** Return the index of the leftmost knot of the active interval. */ get leftKnotIndex(): number; /** Return the index of the rightmost knot of the active interval. */ get rightKnotIndex(): number; /** * Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used * is specified by BSplineWrapMode, and is reversed at serialization time. */ get wrappable(): BSplineWrapMode; set wrappable(value: BSplineWrapMode); /** Return the number of Bezier spans. Note that this includes zero-length spans if there are repeated knots. */ get numSpans(): number; /** * Private constructor. * * If `knots` is a number array or Float64Array, then its values are copied to the instance array. * * If `knots` is a number, the instance array is allocated to this size but left as zeros. */ private constructor(); /** Copy degree and knots to a new KnotVector. */ clone(): KnotVector; private setupFixedValues; /** * Return the length of the active knot interval. * * This is the size of (one dimension of) the parametric domain for the associated B-spline object. */ get knotLength01(): number; /** * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified * wrap mode. * @param mode optional test mode. If undefined, use this.wrappable. */ testClosable(mode?: BSplineWrapMode): boolean; /** Test matching degree and knot values. */ isAlmostEqual(other: KnotVector): boolean; /** Compute the multiplicity of the input knot, or zero if not a knot. */ getKnotMultiplicity(knot: number): number; /** Compute the multiplicity of the knot at the given index. */ getKnotMultiplicityAtIndex(knotIndex: number): number; /** * Transform knots such that the active knot range becomes [0,1]. * @returns false if and only if `this.knotLength01` is trivial. */ normalize(): boolean; /** Install knot values from an array, optionally ignoring first and last. */ setKnots(knots: number[] | Float64Array, skipFirstAndLast?: boolean): void; /** Set knots to input array (CAPTURED). */ setKnotsCapture(knots: Float64Array): void; /** * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between. * @param numPoles number of poles. * @param degree degree of polynomial. * @param a0 left knot value for active interval. * @param a1 right knot value for active interval. */ static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector; /** * Create knot vector with wraparound knots at start and end, and uniform knots between. * @param numInterval the number of intervals into which to uniformly divide the active knot interval `[a0,a1]`, * creating `numInterval-1` equally spaced interior knots between `a0` and `a1`. * This number is equal to the number of Bezier spans in the associated B-spline object. * It is _not_ the pole count. * @param degree degree of polynomial. * @param a0 left knot value for active interval. * @param a1 right knot value for active interval. */ static createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector; /** * Create knot vector with given knot values and degree. * @param knotArray knot values. * @param degree degree of polynomial. * @param skipFirstAndLast true to skip copying the first and last knot values. */ static create(knotArray: number[] | Float64Array, degree: number, skipFirstAndLast?: boolean): KnotVector; /** * Return the average of degree consecutive knots beginning at knotIndex. * * If `knotIndex` is negative, return `leftKnot`. * * If `knotIndex > rightKnotIndex` return `rightKnot`. */ grevilleKnot(knotIndex: number): number; /** Return an array of size `degree + 1`, e.g., to hold the set of relevant basis function values at a parameter. */ createBasisArray(): Float64Array; /** Convert localFraction within the interval following an indexed knot to a knot value. */ baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number; /** Convert localFraction within an indexed bezier span to a knot value. */ spanFractionToKnot(spanIndex: number, localFraction: number): number; /** Convert localFraction within an indexed bezier span to fraction of active knot range. */ spanFractionToFraction(spanIndex: number, localFraction: number): number; /** Return fraction of active knot range to knot value. */ fractionToKnot(fraction: number): number; private isKnotInValidSpan; /** * Evaluate the B-spline basis functions f[] at a parameter u in a knot span. * * This method implements the Mansfield-Cox-de Boor recurrence relation. * @param knotIndex0 index of the left knot of the span. * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1]. * @param f preallocated output array of order basis function values. * @returns true if and only if output array is sufficiently sized. */ evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array): boolean; /** * Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at a parameter u * in a knot span. * @param knotIndex0 index of the left knot of the span. * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1]. * @param f preallocated output array of order basis function values. * @param df preallocated output array of order basis derivative values. * @param ddf optional preallocated output array of order basis second derivative values. * @returns true if and only if output arrays are sufficiently sized. */ evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array): boolean; /** * Find the knot span bracketing knots[i] <= u < knots[i+1] and return i. * * If u has no such bracket, return the smaller index of the closest nontrivial bracket. * @param u value to bracket. */ knotToLeftKnotIndex(u: number): number; /** * Given a span index, return the index of the knot at its left. * @param spanIndex index of span. */ spanIndexToLeftKnotIndex(spanIndex: number): number; /** Return the knot interval length of indexed bezier span. */ spanIndexToSpanLength(spanIndex: number): number; /** * Given a span index, test if it is within range and has nonzero length. * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) * followed by more real spans * @param spanIndex index of span to test. */ isIndexOfRealSpan(spanIndex: number): boolean; /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths are reversed. */ reflectKnots(): void; /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */ static copyKnots(knots: number[] | Float64Array, degree: number, includeExtraEndKnot?: boolean, wrapMode?: BSplineWrapMode): number[]; /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */ copyKnots(includeExtraEndKnot: boolean): number[]; } //# sourceMappingURL=KnotVector.d.ts.map