KnotVector Class
Array of non-decreasing numbers acting as a knot array for B-splines.
- 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. But 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 span {k} is knot {k+degree-1}.
- This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.
- Core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Callers need to know their primary values (global knot, spanFraction).
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 sized for a set of the basis function values. | |
evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array): boolean | Evaluate basis functions f[] at knot value u. | |
evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array): boolean | Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at knot value 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 to span [0,1]. | |
reflectKnots(): void | Reflect all knots so leftKnot and rightKnot are maintained but interval lengths reverse. |
|
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 wrap mode. | |
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 | Return the degree of basis functions defined in these knots. | |
knotLength01 Accessor ReadOnly | number | Return the total knot distance from beginning to end. | |
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 44
Last Updated: 21 November, 2024
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.