KnotVector Class
Array of non-decreasing numbers acting as a knot array for bsplines.
- Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1
- Various bspline libraries have confusion over how many "end knots" are needed. "Many" libraries (including MicroStation) incorrectly demand "order" knots at each end for clamping. But only "order - 1" are really needed.
- This class uses the "order-1" convention.
- This class provides queries to convert among spanIndex and knotIndex
- 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 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): void | Evaluate basis functions f[] at knot value u. | |
| evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array): void | 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: number[] | Float64Array, skipFirstAndLast?: boolean): void | install knot values from an array, optionally ignoring first and last. | |
| setKnotsCapture(knots: Float64Array): void | install knot values from an array, optionally ignoring first and last. | |
| 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 for "closed" knotVector with specified wrap mode | |
| create(knotArray: number[] | Float64Array, 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 StaticReadonly | "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 the bspline was created by adding poles into "closed" structure. |
Defined in
- bspline/KnotVector.ts Line 50
Last Updated: 30 November, 2023