@itwin/core-geometry 5.0.0-dev.62 → 5.0.0-dev.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/lib/cjs/bspline/BSpline1dNd.d.ts +90 -54
  2. package/lib/cjs/bspline/BSpline1dNd.d.ts.map +1 -1
  3. package/lib/cjs/bspline/BSpline1dNd.js +134 -99
  4. package/lib/cjs/bspline/BSpline1dNd.js.map +1 -1
  5. package/lib/cjs/bspline/BSplineCurve.d.ts +193 -155
  6. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  7. package/lib/cjs/bspline/BSplineCurve.js +245 -181
  8. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  9. package/lib/cjs/bspline/BezierCurve3d.d.ts +3 -1
  10. package/lib/cjs/bspline/BezierCurve3d.d.ts.map +1 -1
  11. package/lib/cjs/bspline/BezierCurve3d.js +3 -5
  12. package/lib/cjs/bspline/BezierCurve3d.js.map +1 -1
  13. package/lib/cjs/bspline/KnotVector.d.ts +74 -54
  14. package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
  15. package/lib/cjs/bspline/KnotVector.js +127 -80
  16. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  17. package/lib/cjs/curve/Arc3d.d.ts +2 -0
  18. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  19. package/lib/cjs/curve/Arc3d.js +2 -0
  20. package/lib/cjs/curve/Arc3d.js.map +1 -1
  21. package/lib/cjs/geometry3d/PointHelpers.d.ts +3 -3
  22. package/lib/cjs/geometry3d/PointHelpers.js +3 -3
  23. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  24. package/lib/cjs/geometry3d/Ray3d.d.ts +2 -2
  25. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  26. package/lib/cjs/geometry3d/Ray3d.js +8 -11
  27. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  28. package/lib/esm/bspline/BSpline1dNd.d.ts +90 -54
  29. package/lib/esm/bspline/BSpline1dNd.d.ts.map +1 -1
  30. package/lib/esm/bspline/BSpline1dNd.js +134 -99
  31. package/lib/esm/bspline/BSpline1dNd.js.map +1 -1
  32. package/lib/esm/bspline/BSplineCurve.d.ts +193 -155
  33. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  34. package/lib/esm/bspline/BSplineCurve.js +245 -181
  35. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  36. package/lib/esm/bspline/BezierCurve3d.d.ts +3 -1
  37. package/lib/esm/bspline/BezierCurve3d.d.ts.map +1 -1
  38. package/lib/esm/bspline/BezierCurve3d.js +3 -5
  39. package/lib/esm/bspline/BezierCurve3d.js.map +1 -1
  40. package/lib/esm/bspline/KnotVector.d.ts +74 -54
  41. package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
  42. package/lib/esm/bspline/KnotVector.js +127 -80
  43. package/lib/esm/bspline/KnotVector.js.map +1 -1
  44. package/lib/esm/curve/Arc3d.d.ts +2 -0
  45. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  46. package/lib/esm/curve/Arc3d.js +2 -0
  47. package/lib/esm/curve/Arc3d.js.map +1 -1
  48. package/lib/esm/geometry3d/PointHelpers.d.ts +3 -3
  49. package/lib/esm/geometry3d/PointHelpers.js +3 -3
  50. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  51. package/lib/esm/geometry3d/Ray3d.d.ts +2 -2
  52. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  53. package/lib/esm/geometry3d/Ray3d.js +8 -11
  54. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  55. package/package.json +5 -5
@@ -3,108 +3,144 @@
3
3
  */
4
4
  import { Point3d } from "../geometry3d/Point3dVector3d";
5
5
  import { BSplineWrapMode, KnotVector } from "./KnotVector";
6
- /** Bspline knots and poles for 1d-to-Nd.
6
+ /**
7
+ * Knots and poles for a B-spline function mapping R to R^n.
7
8
  * * The "pole" (aka control point) of this class is a block of `poleLength` numbers.
8
9
  * * Derived classes (not this class) assign meaning such as x,y,z,w.
9
- * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w
10
+ * * For instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or
11
+ * weighted 2D x,y,w.
10
12
  * @public
11
13
  */
12
14
  export declare class BSpline1dNd {
13
- /** knots of the bspline */
15
+ /** Knots of the bspline. */
14
16
  knots: KnotVector;
15
- /** poles, packed in blocks of `poleLength` doubles. */
17
+ /** Poles packed in blocks of `poleLength` doubles. */
16
18
  packedData: Float64Array;
17
- /** (property accessor) Return the number of numeric values per pole. */
19
+ /** The number of numeric values per pole. */
18
20
  poleLength: number;
19
21
  /** (property accessor) Return the degree of the polynomials. */
20
22
  get degree(): number;
21
- /** (property accessor) Return the number of order (one more than degree) of the polynomials */
23
+ /** (property accessor) Return the order (one more than degree) of the polynomials. */
22
24
  get order(): number;
23
- /** (property accessor) Return the number of bezier spans (including null spans at multiple knots)*/
25
+ /** (property accessor) Return the number of bezier spans (including null spans at multiple knots). */
24
26
  get numSpan(): number;
25
- /** (property accessor) Return the number of poles*/
27
+ /** (property accessor) Return the number of poles. */
26
28
  get numPoles(): number;
27
- /** copy 3 values of pole `i` into a point.
29
+ /**
30
+ * Copy 3 values of pole `i` into a point.
28
31
  * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.
29
32
  */
30
33
  getPoint3dPole(i: number, result?: Point3d): Point3d | undefined;
31
- /** preallocated array (length === `order`) used as temporary in evaluations */
34
+ /**
35
+ * Values of the `order` relevant B-spline basis functions at a parameter.
36
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
37
+ */
32
38
  basisBuffer: Float64Array;
33
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
34
- poleBuffer: Float64Array;
35
- /** preallocated array (length === `order`) used as temporary in evaluations */
39
+ /**
40
+ * Derivatives of the `order` relevant B-spline basis functions at a parameter.
41
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
42
+ */
36
43
  basisBuffer1: Float64Array;
37
- /** preallocated array (length === `order`) used as temporary in evaluations */
44
+ /**
45
+ * Second derivatives of the `order` relevant B-spline basis functions at a parameter.
46
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
47
+ */
38
48
  basisBuffer2: Float64Array;
39
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
49
+ /**
50
+ * Temporary to hold a single point.
51
+ * * Preallocated to length `poleLength` in the constructor.
52
+ */
53
+ poleBuffer: Float64Array;
54
+ /**
55
+ * Temporary to hold a single derivative vector.
56
+ * * Preallocated to length `poleLength` in the constructor.
57
+ */
40
58
  poleBuffer1: Float64Array;
41
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
59
+ /**
60
+ * Temporary to hold a single second derivative vector.
61
+ * * Preallocated to length `poleLength` in the constructor.
62
+ */
42
63
  poleBuffer2: Float64Array;
43
64
  /**
44
- * initialize arrays for given spline dimensions.
45
- * @param numPoles number of poles
46
- * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)
47
- * @param order number of poles in support for a section of the bspline
48
- * @param knots KnotVector. This is captured, not cloned.
65
+ * Initialize arrays for given spline dimensions.
66
+ * @param numPoles number of poles.
67
+ * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
68
+ * 3 for 2d weighted).
69
+ * @param order number of poles defining a Bezier segment of the B-spline function.
70
+ * @param knots the KnotVector. This is captured, not cloned.
49
71
  */
50
72
  protected constructor(numPoles: number, poleLength: number, order: number, knots: KnotVector);
51
73
  /**
52
- * create a 1Bspline1dNd`
53
- * @param numPoles number of poles
54
- * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)
55
- * @param order number of poles in support for a section of the bspline
56
- * @param knots KnotVector. This is captured, not cloned.
74
+ * Create a `BSpline1dNd`.
75
+ * @param numPoles number of poles.
76
+ * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
77
+ * 3 for 2d weighted).
78
+ * @param order number of poles defining a Bezier segment of the B-spline function.
79
+ * @param knots the KnotVector. This is captured, not cloned.
57
80
  */
58
- static create(numPoles: number, poleLength: number, order: number, knots: KnotVector): BSpline1dNd | undefined;
59
- /** Map a span index and local fraction to knot value. */
60
- spanFractionToKnot(span: number, localFraction: number): number;
81
+ static create(numPoles: number, poleLength: number, order: number, knots: KnotVector): BSpline1dNd;
82
+ /** Map a span index and span fraction to knot value. */
83
+ spanFractionToKnot(spanIndex: number, spanFraction: number): number;
61
84
  /**
62
- * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span.
63
- * @returns true if and only if output arrays are sufficiently sized
85
+ * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within
86
+ * indexed span.
87
+ * @returns true if and only if output arrays are sufficiently sized.
64
88
  */
65
89
  evaluateBasisFunctionsInSpan(spanIndex: number, spanFraction: number, f: Float64Array, df?: Float64Array, ddf?: Float64Array): boolean;
90
+ /**
91
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer`, and store this point
92
+ * in `poleBuffer`.
93
+ */
94
+ sumPoleBufferForSpan(spanIndex: number): void;
95
+ /**
96
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer1`, and store this
97
+ * derivative vector in `poleBuffer1`.
98
+ */
99
+ sumPoleBuffer1ForSpan(spanIndex: number): void;
100
+ /**
101
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer2`, and store this
102
+ * second derivative vector in `poleBuffer2`.
103
+ */
104
+ sumPoleBuffer2ForSpan(spanIndex: number): void;
66
105
  /**
67
106
  * * Evaluate the basis functions at spanIndex and fraction.
68
- * * Evaluations are stored in the preallocated `this.basisBuffer`
69
- * * Immediately do the summations of the basis values times the respective control points
107
+ * * Evaluations are stored in the preallocated `this.basisBuffer`.
108
+ * * Immediately do the summations of the basis values times the respective poles.
70
109
  * * Summations are stored in the preallocated `this.poleBuffer`
71
110
  * */
72
111
  evaluateBuffersInSpan(spanIndex: number, spanFraction: number): void;
73
112
  /**
74
113
  * * Evaluate the basis functions and one derivative at spanIndex and fraction.
75
- * * Evaluations are stored in the preallocated `this.basisBuffer`
76
- * * Immediately do the summations of the basis values times the respective control points
114
+ * * Function evaluations are stored in the preallocated `this.basisBuffer`; derivative evaluations in `this.basisBuffer1`.
115
+ * * Immediately do the summations of the basis values times the respective poles.
77
116
  * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
78
117
  * */
79
118
  evaluateBuffersInSpan1(spanIndex: number, spanFraction: number): void;
80
- /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */
81
- sumPoleBufferForSpan(spanIndex: number): void;
82
- /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */
83
- sumPoleBuffer1ForSpan(spanIndex: number): void;
84
- /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */
85
- sumPoleBuffer2ForSpan(spanIndex: number): void;
86
- /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */
87
- evaluateBuffersAtKnot(u: number, numDerivative?: number): void;
88
119
  /**
89
- * Reverse the (blocked) poles (in `this.packedData` in place.
120
+ * Evaluate the B-spline function and optional derivatives at the given parameter in knot space.
121
+ * * Function value is stored in `poleBuffer`; optional derivative vectors in `poleBuffer1` and `poleBuffer2`.
90
122
  */
123
+ evaluateBuffersAtKnot(u: number, numDerivative?: number): void;
124
+ /** Reverse the instance poles and knots in place. */
91
125
  reverseInPlace(): void;
92
126
  /**
93
- * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
94
- * to act as a normal bspline.
95
- * @returns true if `degree` leading and trailing polygon blocks match
96
- * @deprecated in 4.x. Use testClosablePolygon instead.
127
+ * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon
128
+ * which has been expanded to act as a normal bspline.
129
+ * @returns true if `degree` leading and trailing polygon blocks match.
130
+ * @deprecated in 4.x. Use `testClosablePolygon` instead.
97
131
  */
98
132
  testCloseablePolygon(mode?: BSplineWrapMode): boolean;
99
133
  /**
100
- * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
101
- * to act as a normal bspline.
102
- * @returns true if `degree` leading and trailing polygon blocks match
134
+ * Test if the leading and trailing poles are replicated in the manner of a "closed" B-spline function with wraparound
135
+ * control polygon.
136
+ * @param mode wrap mode, indicating the number of wraparound poles to check. If undefined, `knots.wrappable` is used.
137
+ * @returns true if the expected leading and trailing poles match, according to `mode`.
103
138
  */
104
139
  testClosablePolygon(mode?: BSplineWrapMode): boolean;
105
- /** Insert knot and resulting pole into the instance, optionally multiple times.
106
- * @param knot the knot to be inserted (may already exist in the KnotVector)
107
- * @param totalMultiplicity the total multiplicity of the knot on return
140
+ /**
141
+ * Insert the knot and resulting pole into the instance, optionally multiple times.
142
+ * @param knot the knot to be inserted (may already exist in the KnotVector).
143
+ * @param totalMultiplicity the total multiplicity of the knot on return.
108
144
  */
109
145
  addKnot(knot: number, totalMultiplicity: number): boolean;
110
146
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BSpline1dNd.d.ts","sourceRoot":"","sources":["../../../src/bspline/BSpline1dNd.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,2BAA2B;IACpB,KAAK,EAAE,UAAU,CAAC;IACzB,uDAAuD;IAChD,UAAU,EAAE,YAAY,CAAC;IAChC,wEAAwE;IACjE,UAAU,EAAE,MAAM,CAAC;I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IAgBjE,qDAAqD;IAC9C,cAAc,IAAI,IAAI;IAS7B;;;;;OAKG;IACI,oBAAoB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO;IAG5D;;;;;OAKG;IACI,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO;IAoB3D;;;;OAIG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO;CAqDjE"}
@@ -8,82 +8,115 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.BSpline1dNd = void 0;
11
- // import { Point2d } from "../Geometry2d";
12
11
  const Geometry_1 = require("../Geometry");
13
12
  const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
14
13
  const KnotVector_1 = require("./KnotVector");
15
- /** Bspline knots and poles for 1d-to-Nd.
14
+ /**
15
+ * Knots and poles for a B-spline function mapping R to R^n.
16
16
  * * The "pole" (aka control point) of this class is a block of `poleLength` numbers.
17
17
  * * Derived classes (not this class) assign meaning such as x,y,z,w.
18
- * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w
18
+ * * For instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or
19
+ * weighted 2D x,y,w.
19
20
  * @public
20
21
  */
21
22
  class BSpline1dNd {
22
- /** knots of the bspline */
23
+ /** Knots of the bspline. */
23
24
  knots;
24
- /** poles, packed in blocks of `poleLength` doubles. */
25
+ /** Poles packed in blocks of `poleLength` doubles. */
25
26
  packedData;
26
- /** (property accessor) Return the number of numeric values per pole. */
27
+ /** The number of numeric values per pole. */
27
28
  poleLength;
28
29
  /** (property accessor) Return the degree of the polynomials. */
29
- get degree() { return this.knots.degree; }
30
- /** (property accessor) Return the number of order (one more than degree) of the polynomials */
31
- get order() { return this.knots.degree + 1; }
32
- /** (property accessor) Return the number of bezier spans (including null spans at multiple knots)*/
33
- get numSpan() { return this.numPoles - this.knots.degree; }
34
- /** (property accessor) Return the number of poles*/
35
- get numPoles() { return this.packedData.length / this.poleLength; }
36
- /** copy 3 values of pole `i` into a point.
30
+ get degree() {
31
+ return this.knots.degree;
32
+ }
33
+ /** (property accessor) Return the order (one more than degree) of the polynomials. */
34
+ get order() {
35
+ return this.knots.degree + 1;
36
+ }
37
+ /** (property accessor) Return the number of bezier spans (including null spans at multiple knots). */
38
+ get numSpan() {
39
+ return this.numPoles - this.knots.degree;
40
+ }
41
+ /** (property accessor) Return the number of poles. */
42
+ get numPoles() {
43
+ return this.packedData.length / this.poleLength;
44
+ }
45
+ /**
46
+ * Copy 3 values of pole `i` into a point.
37
47
  * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.
38
48
  */
39
- getPoint3dPole(i, result) { return Point3dVector3d_1.Point3d.createFromPacked(this.packedData, i, result); }
40
- /** preallocated array (length === `order`) used as temporary in evaluations */
41
- basisBuffer; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
42
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
43
- poleBuffer; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
44
- /** preallocated array (length === `order`) used as temporary in evaluations */
45
- basisBuffer1; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
46
- /** preallocated array (length === `order`) used as temporary in evaluations */
47
- basisBuffer2; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
48
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
49
- poleBuffer1; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
50
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
51
- poleBuffer2; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
49
+ getPoint3dPole(i, result) {
50
+ return Point3dVector3d_1.Point3d.createFromPacked(this.packedData, i, result);
51
+ }
52
+ /**
53
+ * Values of the `order` relevant B-spline basis functions at a parameter.
54
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
55
+ */
56
+ basisBuffer;
57
+ /**
58
+ * Derivatives of the `order` relevant B-spline basis functions at a parameter.
59
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
60
+ */
61
+ basisBuffer1;
62
+ /**
63
+ * Second derivatives of the `order` relevant B-spline basis functions at a parameter.
64
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
65
+ */
66
+ basisBuffer2;
67
+ /**
68
+ * Temporary to hold a single point.
69
+ * * Preallocated to length `poleLength` in the constructor.
70
+ */
71
+ poleBuffer;
72
+ /**
73
+ * Temporary to hold a single derivative vector.
74
+ * * Preallocated to length `poleLength` in the constructor.
75
+ */
76
+ poleBuffer1;
77
+ /**
78
+ * Temporary to hold a single second derivative vector.
79
+ * * Preallocated to length `poleLength` in the constructor.
80
+ */
81
+ poleBuffer2;
52
82
  /**
53
- * initialize arrays for given spline dimensions.
54
- * @param numPoles number of poles
55
- * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)
56
- * @param order number of poles in support for a section of the bspline
57
- * @param knots KnotVector. This is captured, not cloned.
83
+ * Initialize arrays for given spline dimensions.
84
+ * @param numPoles number of poles.
85
+ * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
86
+ * 3 for 2d weighted).
87
+ * @param order number of poles defining a Bezier segment of the B-spline function.
88
+ * @param knots the KnotVector. This is captured, not cloned.
58
89
  */
59
90
  constructor(numPoles, poleLength, order, knots) {
60
91
  this.knots = knots;
61
92
  this.packedData = new Float64Array(numPoles * poleLength);
62
93
  this.poleLength = poleLength;
63
94
  this.basisBuffer = new Float64Array(order);
64
- this.poleBuffer = new Float64Array(poleLength);
65
95
  this.basisBuffer1 = new Float64Array(order);
66
96
  this.basisBuffer2 = new Float64Array(order);
97
+ this.poleBuffer = new Float64Array(poleLength);
67
98
  this.poleBuffer1 = new Float64Array(poleLength);
68
99
  this.poleBuffer2 = new Float64Array(poleLength);
69
100
  }
70
101
  /**
71
- * create a 1Bspline1dNd`
72
- * @param numPoles number of poles
73
- * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)
74
- * @param order number of poles in support for a section of the bspline
75
- * @param knots KnotVector. This is captured, not cloned.
102
+ * Create a `BSpline1dNd`.
103
+ * @param numPoles number of poles.
104
+ * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
105
+ * 3 for 2d weighted).
106
+ * @param order number of poles defining a Bezier segment of the B-spline function.
107
+ * @param knots the KnotVector. This is captured, not cloned.
76
108
  */
77
109
  static create(numPoles, poleLength, order, knots) {
78
110
  return new BSpline1dNd(numPoles, poleLength, order, knots);
79
111
  }
80
- /** Map a span index and local fraction to knot value. */
81
- spanFractionToKnot(span, localFraction) {
82
- return this.knots.spanFractionToKnot(span, localFraction);
112
+ /** Map a span index and span fraction to knot value. */
113
+ spanFractionToKnot(spanIndex, spanFraction) {
114
+ return this.knots.spanFractionToKnot(spanIndex, spanFraction);
83
115
  }
84
116
  /**
85
- * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span.
86
- * @returns true if and only if output arrays are sufficiently sized
117
+ * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within
118
+ * indexed span.
119
+ * @returns true if and only if output arrays are sufficiently sized.
87
120
  */
88
121
  evaluateBasisFunctionsInSpan(spanIndex, spanFraction, f, df, ddf) {
89
122
  if (spanIndex < 0)
@@ -97,57 +130,64 @@ class BSpline1dNd {
97
130
  this.knots.evaluateBasisFunctions(knotIndex0, globalKnot, f);
98
131
  }
99
132
  /**
100
- * * Evaluate the basis functions at spanIndex and fraction.
101
- * * Evaluations are stored in the preallocated `this.basisBuffer`
102
- * * Immediately do the summations of the basis values times the respective control points
103
- * * Summations are stored in the preallocated `this.poleBuffer`
104
- * */
105
- evaluateBuffersInSpan(spanIndex, spanFraction) {
106
- this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);
107
- this.sumPoleBufferForSpan(spanIndex);
108
- }
109
- /**
110
- * * Evaluate the basis functions and one derivative at spanIndex and fraction.
111
- * * Evaluations are stored in the preallocated `this.basisBuffer`
112
- * * Immediately do the summations of the basis values times the respective control points
113
- * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
114
- * */
115
- evaluateBuffersInSpan1(spanIndex, spanFraction) {
116
- this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);
117
- this.sumPoleBufferForSpan(spanIndex);
118
- this.sumPoleBuffer1ForSpan(spanIndex);
119
- }
120
- /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */
133
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer`, and store this point
134
+ * in `poleBuffer`.
135
+ */
121
136
  sumPoleBufferForSpan(spanIndex) {
122
137
  this.poleBuffer.fill(0);
123
138
  let k = spanIndex * this.poleLength;
124
- for (const f of this.basisBuffer) {
125
- for (let j = 0; j < this.poleLength; j++) {
139
+ for (const f of this.basisBuffer)
140
+ for (let j = 0; j < this.poleLength; j++)
126
141
  this.poleBuffer[j] += f * this.packedData[k++];
127
- }
128
- }
129
142
  }
130
- /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */
143
+ /**
144
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer1`, and store this
145
+ * derivative vector in `poleBuffer1`.
146
+ */
131
147
  sumPoleBuffer1ForSpan(spanIndex) {
132
148
  this.poleBuffer1.fill(0);
133
149
  let k = spanIndex * this.poleLength;
134
- for (const f of this.basisBuffer1) {
135
- for (let j = 0; j < this.poleLength; j++) {
150
+ for (const f of this.basisBuffer1)
151
+ for (let j = 0; j < this.poleLength; j++)
136
152
  this.poleBuffer1[j] += f * this.packedData[k++];
137
- }
138
- }
139
153
  }
140
- /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */
154
+ /**
155
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer2`, and store this
156
+ * second derivative vector in `poleBuffer2`.
157
+ */
141
158
  sumPoleBuffer2ForSpan(spanIndex) {
142
159
  this.poleBuffer2.fill(0);
143
160
  let k = spanIndex * this.poleLength;
144
161
  for (const f of this.basisBuffer2) {
145
- for (let j = 0; j < this.poleLength; j++) {
162
+ for (let j = 0; j < this.poleLength; j++)
146
163
  this.poleBuffer2[j] += f * this.packedData[k++];
147
- }
148
164
  }
149
165
  }
150
- /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */
166
+ /**
167
+ * * Evaluate the basis functions at spanIndex and fraction.
168
+ * * Evaluations are stored in the preallocated `this.basisBuffer`.
169
+ * * Immediately do the summations of the basis values times the respective poles.
170
+ * * Summations are stored in the preallocated `this.poleBuffer`
171
+ * */
172
+ evaluateBuffersInSpan(spanIndex, spanFraction) {
173
+ this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);
174
+ this.sumPoleBufferForSpan(spanIndex);
175
+ }
176
+ /**
177
+ * * Evaluate the basis functions and one derivative at spanIndex and fraction.
178
+ * * Function evaluations are stored in the preallocated `this.basisBuffer`; derivative evaluations in `this.basisBuffer1`.
179
+ * * Immediately do the summations of the basis values times the respective poles.
180
+ * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
181
+ * */
182
+ evaluateBuffersInSpan1(spanIndex, spanFraction) {
183
+ this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);
184
+ this.sumPoleBufferForSpan(spanIndex);
185
+ this.sumPoleBuffer1ForSpan(spanIndex);
186
+ }
187
+ /**
188
+ * Evaluate the B-spline function and optional derivatives at the given parameter in knot space.
189
+ * * Function value is stored in `poleBuffer`; optional derivative vectors in `poleBuffer1` and `poleBuffer2`.
190
+ */
151
191
  evaluateBuffersAtKnot(u, numDerivative = 0) {
152
192
  const knotIndex0 = this.knots.knotToLeftKnotIndex(u);
153
193
  if (numDerivative < 1) {
@@ -166,36 +206,30 @@ class BSpline1dNd {
166
206
  this.sumPoleBuffer2ForSpan(knotIndex0 - this.degree + 1);
167
207
  }
168
208
  }
169
- /**
170
- * Reverse the (blocked) poles (in `this.packedData` in place.
171
- */
209
+ /** Reverse the instance poles and knots in place. */
172
210
  reverseInPlace() {
173
- // reverse poles in blocks ...
174
- const b = this.poleLength;
211
+ const pLen = this.poleLength;
175
212
  const data = this.packedData;
176
- for (let i0 = 0, j0 = b * (this.numPoles - 1); i0 < j0; i0 += b, j0 -= b) {
177
- let t = 0;
178
- for (let i = 0; i < b; i++) {
179
- t = data[i0 + i];
180
- data[i0 + i] = data[j0 + i];
181
- data[j0 + i] = t;
182
- }
213
+ for (let i0 = 0, j0 = pLen * (this.numPoles - 1); i0 < j0; i0 += pLen, j0 -= pLen) {
214
+ for (let i = 0; i < pLen; i++)
215
+ [data[i0 + i], data[j0 + i]] = [data[j0 + i], data[i0 + i]];
183
216
  }
184
217
  this.knots.reflectKnots();
185
218
  }
186
219
  /**
187
- * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
188
- * to act as a normal bspline.
189
- * @returns true if `degree` leading and trailing polygon blocks match
190
- * @deprecated in 4.x. Use testClosablePolygon instead.
220
+ * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon
221
+ * which has been expanded to act as a normal bspline.
222
+ * @returns true if `degree` leading and trailing polygon blocks match.
223
+ * @deprecated in 4.x. Use `testClosablePolygon` instead.
191
224
  */
192
225
  testCloseablePolygon(mode) {
193
226
  return this.testClosablePolygon(mode);
194
227
  }
195
228
  /**
196
- * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
197
- * to act as a normal bspline.
198
- * @returns true if `degree` leading and trailing polygon blocks match
229
+ * Test if the leading and trailing poles are replicated in the manner of a "closed" B-spline function with wraparound
230
+ * control polygon.
231
+ * @param mode wrap mode, indicating the number of wraparound poles to check. If undefined, `knots.wrappable` is used.
232
+ * @returns true if the expected leading and trailing poles match, according to `mode`.
199
233
  */
200
234
  testClosablePolygon(mode) {
201
235
  if (mode === undefined)
@@ -217,9 +251,10 @@ class BSpline1dNd {
217
251
  }
218
252
  return true;
219
253
  }
220
- /** Insert knot and resulting pole into the instance, optionally multiple times.
221
- * @param knot the knot to be inserted (may already exist in the KnotVector)
222
- * @param totalMultiplicity the total multiplicity of the knot on return
254
+ /**
255
+ * Insert the knot and resulting pole into the instance, optionally multiple times.
256
+ * @param knot the knot to be inserted (may already exist in the KnotVector).
257
+ * @param totalMultiplicity the total multiplicity of the knot on return.
223
258
  */
224
259
  addKnot(knot, totalMultiplicity) {
225
260
  if (knot < this.knots.leftKnot || knot > this.knots.rightKnot)