KnotVector Class
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 indexk+degree-1
. - A knot vector is clamped when the first
degree
knots are equal and the lastdegree
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.
Methods
Name | Description | |
---|---|---|
baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number | Convert localFraction within the interval following an indexed knot to a knot value. | |
clone(): KnotVector | Copy degree and knots to a new KnotVector. | |
copyKnots(includeExtraEndKnot: boolean): number[] | Return a simple array form of the knots. | |
createBasisArray(): Float64Array | Return an array of size degree + 1 , e.g., to hold the set of relevant basis function values at a parameter. |
|
evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array): boolean | Evaluate the B-spline basis functions f[] at a parameter u in a knot span. | |
evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array): boolean | Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at a parameter u | |
fractionToKnot(fraction: number): number | Return fraction of active knot range to knot value. | |
getKnotMultiplicity(knot: number): number | Compute the multiplicity of the input knot, or zero if not a knot. | |
getKnotMultiplicityAtIndex(knotIndex: number): number | Compute the multiplicity of the knot at the given index. | |
grevilleKnot(knotIndex: number): number | Return the average of degree consecutive knots beginning at knotIndex. | |
isAlmostEqual(other: KnotVector): boolean | Test matching degree and knot values. | |
isIndexOfRealSpan(spanIndex: number): boolean | Given a span index, test if it is within range and has nonzero length. | |
knotToLeftKnotIndex(u: number): number | Find the knot span bracketing knots[i] <= u < knots[i+1] and return i. | |
normalize(): boolean | Transform knots such that the active knot range becomes [0,1]. | |
reflectKnots(): void | Reflect all knots so leftKnot and rightKnot are maintained but interval lengths are reversed. |
|
setKnots(knots: Float64Array | number[], skipFirstAndLast?: boolean): void | Install knot values from an array, optionally ignoring first and last. | |
setKnotsCapture(knots: Float64Array): void | Set knots to input array (CAPTURED). | |
spanFractionToFraction(spanIndex: number, localFraction: number): number | Convert localFraction within an indexed bezier span to fraction of active knot range. | |
spanFractionToKnot(spanIndex: number, localFraction: number): number | Convert localFraction within an indexed bezier span to a knot value. | |
spanIndexToLeftKnotIndex(spanIndex: number): number | Given a span index, return the index of the knot at its left. | |
spanIndexToSpanLength(spanIndex: number): number | Return the knot interval length of indexed bezier span. | |
testClosable(mode?: BSplineWrapMode): boolean | Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified | |
copyKnots(knots: Float64Array | number[], degree: number, includeExtraEndKnot?: boolean, wrapMode?: BSplineWrapMode): number[] Static | Return a simple array form of the knots. | |
create(knotArray: Float64Array | number[], degree: number, skipFirstAndLast?: boolean): KnotVector Static | Create knot vector with given knot values and degree. | |
createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector Static | Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between. | |
createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector Static | Create knot vector with wraparound knots at start and end, and uniform knots between. |
Properties
Name | Type | Description | |
---|---|---|---|
degree | number | The degree of basis functions defined in these knots. | |
knotLength01 Accessor ReadOnly | number | Return the length of the active knot interval. | |
knots | Float64Array | The simple array of knot values. | |
knotTolerance Static Readonly | "1e-9" | Tolerance for considering two knots to be the same. | |
leftKnot Accessor ReadOnly | number | Return the leftmost knot value (of the active interval, ignoring unclamped leading knots). | |
leftKnotIndex Accessor ReadOnly | number | Return the index of the leftmost knot of the active interval. | |
numSpans Accessor ReadOnly | number | Return the number of Bezier spans. | |
rightKnot Accessor ReadOnly | number | Return the rightmost knot value (of the active interval, ignoring unclamped leading knots). | |
rightKnotIndex Accessor ReadOnly | number | Return the index of the rightmost knot of the active interval. | |
wrappable Accessor | BSplineWrapMode | Whether this KnotVector was created by converting legacy periodic data during deserialization. |
Defined in
- bspline/KnotVector.ts Line 50
Last Updated: 21 February, 2025
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.