KnotVector Class

Array of non-decreasing numbers acting as a knot array for bsplines.

  • Essential identity: numKnots = numPoles + order = 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. Caller's 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 fucntions f[] at knot value u.  
fractionToKnot(fraction: number): number Return fraction of active knot range to knot value.  
grevilleKnot(spanIndex: number): number Return the average of degree consecutive knots beginning at spanIndex.  
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 Return the (highest) index of the knot less than or equal to u  
reflectKnots(): void Reflect all knots so leftKnot and rightKnot are maintained but interval lengths reverse.  
setKnots(knots: number[] | Float64Array, skipFirstAndLast?: false | true): 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?: false | true): 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 {degree-1} replicated 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 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 Return true if the bspline was created by adding poles in to "closed" structure  

Defined in

Last Updated: 08 January, 2020