@itwin/core-geometry 3.3.0-dev.72 → 3.3.0-dev.77
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.
- package/lib/cjs/curve/spiral/DirectSpiral3d.js +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableBlockedArray.d.ts +32 -3
- package/lib/cjs/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableBlockedArray.js +63 -14
- package/lib/cjs/geometry3d/GrowableBlockedArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts +24 -8
- package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.js +72 -54
- package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +51 -26
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +136 -116
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +35 -21
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +124 -137
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.js +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/esm/geometry3d/GrowableBlockedArray.d.ts +32 -3
- package/lib/esm/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableBlockedArray.js +63 -14
- package/lib/esm/geometry3d/GrowableBlockedArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.d.ts +24 -8
- package/lib/esm/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.js +72 -54
- package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +51 -26
- package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +136 -116
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +35 -21
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +124 -137
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/package.json +4 -4
|
@@ -19,27 +19,51 @@ const PointStreaming_1 = require("./PointStreaming");
|
|
|
19
19
|
*/
|
|
20
20
|
class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
21
21
|
/** Construct a new GrowablePoint2d array.
|
|
22
|
-
* @param numPoints
|
|
22
|
+
* @param numPoints initial capacity in xy tuples (default 8)
|
|
23
|
+
* @param growthFactor used by ensureCapacity to expand requested reallocation size (default 1.5)
|
|
23
24
|
*/
|
|
24
|
-
constructor(numPoints = 8) {
|
|
25
|
+
constructor(numPoints = 8, growthFactor) {
|
|
25
26
|
super();
|
|
26
|
-
this._data = new Float64Array(numPoints * 2); //
|
|
27
|
+
this._data = new Float64Array(numPoints * 2); // 2 values per point
|
|
27
28
|
this._xyInUse = 0;
|
|
28
|
-
this.
|
|
29
|
+
this._xyCapacity = numPoints;
|
|
30
|
+
this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;
|
|
31
|
+
}
|
|
32
|
+
/** Copy xy points from source array. Does not reallocate or change active point count.
|
|
33
|
+
* @param source array to copy from
|
|
34
|
+
* @param sourceCount copy the first sourceCount points; all points if undefined
|
|
35
|
+
* @param destOffset copy to instance array starting at this point index; zero if undefined
|
|
36
|
+
* @return count and offset of points copied
|
|
37
|
+
*/
|
|
38
|
+
copyData(source, sourceCount, destOffset) {
|
|
39
|
+
// validate inputs and convert from points to entries
|
|
40
|
+
let myOffset = (undefined !== destOffset) ? destOffset * 2 : 0;
|
|
41
|
+
if (myOffset < 0)
|
|
42
|
+
myOffset = 0;
|
|
43
|
+
if (myOffset >= this._data.length)
|
|
44
|
+
return { count: 0, offset: 0 };
|
|
45
|
+
let myCount = (undefined !== sourceCount) ? sourceCount * 2 : source.length;
|
|
46
|
+
if (myCount > 0) {
|
|
47
|
+
if (myCount > source.length)
|
|
48
|
+
myCount = source.length;
|
|
49
|
+
if (myOffset + myCount > this._data.length)
|
|
50
|
+
myCount = this._data.length - myOffset;
|
|
51
|
+
if (myCount % 2 !== 0)
|
|
52
|
+
myCount -= myCount % 2;
|
|
53
|
+
}
|
|
54
|
+
if (myCount <= 0)
|
|
55
|
+
return { count: 0, offset: 0 };
|
|
56
|
+
if (myCount === source.length)
|
|
57
|
+
this._data.set(source, myOffset);
|
|
58
|
+
else if (source instanceof Float64Array)
|
|
59
|
+
this._data.set(source.subarray(0, myCount), myOffset);
|
|
60
|
+
else
|
|
61
|
+
this._data.set(source.slice(0, myCount), myOffset);
|
|
62
|
+
return { count: myCount / 2, offset: myOffset / 2 };
|
|
29
63
|
}
|
|
30
64
|
/** The number of points in use. When the length is increased, the array is padded with zeroes. */
|
|
31
65
|
get length() { return this._xyInUse; }
|
|
32
|
-
set length(newLength) {
|
|
33
|
-
let oldLength = this.length;
|
|
34
|
-
if (newLength < oldLength) {
|
|
35
|
-
this._xyInUse = newLength;
|
|
36
|
-
}
|
|
37
|
-
else if (newLength > oldLength) {
|
|
38
|
-
this.ensureCapacity(newLength);
|
|
39
|
-
while (oldLength++ < newLength)
|
|
40
|
-
this.pushXY(0, 0);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
66
|
+
set length(newLength) { this.resize(newLength, true); }
|
|
43
67
|
/** Return the number of float64 in use. */
|
|
44
68
|
get float64Length() { return this._xyInUse * 2; }
|
|
45
69
|
/** Return the raw packed data.
|
|
@@ -47,31 +71,29 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
47
71
|
*/
|
|
48
72
|
float64Data() { return this._data; }
|
|
49
73
|
/** If necessary, increase the capacity to a new pointCount. Current coordinates and point count (length) are unchanged. */
|
|
50
|
-
ensureCapacity(pointCapacity) {
|
|
51
|
-
if (pointCapacity > this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this._data = newArray;
|
|
74
|
-
this._xyzCapacity = pointCount;
|
|
74
|
+
ensureCapacity(pointCapacity, applyGrowthFactor = true) {
|
|
75
|
+
if (pointCapacity > this._xyCapacity) {
|
|
76
|
+
if (applyGrowthFactor)
|
|
77
|
+
pointCapacity *= this._growthFactor;
|
|
78
|
+
const prevData = this._data;
|
|
79
|
+
this._data = new Float64Array(pointCapacity * 2);
|
|
80
|
+
this.copyData(prevData, this._xyInUse);
|
|
81
|
+
this._xyCapacity = pointCapacity;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* * If pointCount is less than current length, just reset current length to pointCount, effectively trimming active points but preserving original capacity.
|
|
86
|
+
* * If pointCount is greater than current length, reallocate to exactly pointCount, copy existing points, and optionally pad excess with zero.
|
|
87
|
+
* @param pointCount new number of active points in array
|
|
88
|
+
* @param padWithZero when increasing point count, whether to zero out new points (default false)
|
|
89
|
+
*/
|
|
90
|
+
resize(pointCount, padWithZero) {
|
|
91
|
+
if (pointCount >= 0 && pointCount < this._xyInUse)
|
|
92
|
+
this._xyInUse = pointCount;
|
|
93
|
+
else if (pointCount > this._xyInUse) {
|
|
94
|
+
this.ensureCapacity(pointCount, false);
|
|
95
|
+
if (padWithZero !== null && padWithZero !== void 0 ? padWithZero : false)
|
|
96
|
+
this._data.fill(0, this._xyInUse * 2);
|
|
75
97
|
this._xyInUse = pointCount;
|
|
76
98
|
}
|
|
77
99
|
}
|
|
@@ -81,11 +103,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
81
103
|
*/
|
|
82
104
|
clone() {
|
|
83
105
|
const newPoints = new GrowableXYArray(this.length);
|
|
84
|
-
|
|
85
|
-
const newData = newPoints._data;
|
|
86
|
-
const data = this._data;
|
|
87
|
-
for (let i = 0; i < numValue; i++)
|
|
88
|
-
newData[i] = data[i];
|
|
106
|
+
newPoints.copyData(this._data, this.length);
|
|
89
107
|
newPoints._xyInUse = this.length;
|
|
90
108
|
return newPoints;
|
|
91
109
|
}
|
|
@@ -117,17 +135,18 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
117
135
|
}
|
|
118
136
|
/** push all points of an array */
|
|
119
137
|
pushAll(points) {
|
|
138
|
+
this.ensureCapacity(this._xyInUse + points.length, false);
|
|
120
139
|
for (const p of points)
|
|
121
140
|
this.push(p);
|
|
122
141
|
}
|
|
123
142
|
/** push all points of an array */
|
|
124
143
|
pushAllXYAndZ(points) {
|
|
144
|
+
this.ensureCapacity(this._xyInUse + points.length, false);
|
|
125
145
|
if (points instanceof GrowableXYZArray_1.GrowableXYZArray) {
|
|
126
146
|
const xyzBuffer = points.float64Data();
|
|
127
147
|
const n = points.length * 3;
|
|
128
|
-
for (let i = 0; i + 2 < n; i += 3)
|
|
148
|
+
for (let i = 0; i + 2 < n; i += 3)
|
|
129
149
|
this.pushXY(xyzBuffer[i], xyzBuffer[i + 1]);
|
|
130
|
-
}
|
|
131
150
|
}
|
|
132
151
|
else {
|
|
133
152
|
for (const p of points)
|
|
@@ -135,38 +154,37 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
156
|
/**
|
|
138
|
-
* Replicate numWrap
|
|
139
|
-
* @param numWrap number of
|
|
157
|
+
* Replicate numWrap xy values from the front of the array as new values at the end.
|
|
158
|
+
* @param numWrap number of xy values to replicate
|
|
140
159
|
*/
|
|
141
160
|
pushWrap(numWrap) {
|
|
142
|
-
if (this._xyInUse
|
|
143
|
-
|
|
161
|
+
if (this._xyInUse >= numWrap) {
|
|
162
|
+
this.ensureCapacity(this._xyInUse + numWrap, false);
|
|
144
163
|
for (let i = 0; i < numWrap; i++) {
|
|
145
|
-
k = 2 * i;
|
|
164
|
+
const k = 2 * i;
|
|
146
165
|
this.pushXY(this._data[k], this._data[k + 1]);
|
|
147
166
|
}
|
|
148
167
|
}
|
|
149
168
|
}
|
|
150
169
|
/** push a point given by x,y coordinates */
|
|
151
170
|
pushXY(x, y) {
|
|
171
|
+
this.ensureCapacity(this._xyInUse + 1);
|
|
152
172
|
const index = this._xyInUse * 2;
|
|
153
|
-
if (index >= this._data.length)
|
|
154
|
-
this.ensureCapacity(this.length === 0 ? 4 : this.length * 2);
|
|
155
173
|
this._data[index] = x;
|
|
156
174
|
this._data[index + 1] = y;
|
|
157
175
|
this._xyInUse++;
|
|
158
176
|
}
|
|
159
177
|
/** Remove one point from the back.
|
|
160
178
|
* * NOTE that (in the manner of std::vector native) this is "just" removing the point -- no point is NOT returned.
|
|
161
|
-
* * Use `back ()` to get the last x,y
|
|
179
|
+
* * Use `back ()` to get the last x,y assembled into a `Point2d `
|
|
162
180
|
*/
|
|
163
181
|
pop() {
|
|
164
182
|
if (this._xyInUse > 0)
|
|
165
183
|
this._xyInUse--;
|
|
166
184
|
}
|
|
167
185
|
/**
|
|
168
|
-
* Test if index is valid for an
|
|
169
|
-
* @param index
|
|
186
|
+
* Test if index is valid for an xy (point or vector) within this array
|
|
187
|
+
* @param index xy index to test.
|
|
170
188
|
*/
|
|
171
189
|
isIndexValid(index) {
|
|
172
190
|
if (index >= this._xyInUse || index < 0)
|
|
@@ -174,7 +192,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
174
192
|
return true;
|
|
175
193
|
}
|
|
176
194
|
/**
|
|
177
|
-
* Clear all
|
|
195
|
+
* Clear all xy data, but leave capacity unchanged.
|
|
178
196
|
*/
|
|
179
197
|
clear() {
|
|
180
198
|
this._xyInUse = 0;
|
|
@@ -213,18 +231,18 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
213
231
|
result.push(Point2dVector2d_1.Point2d.create(data[i], data[i + 1]));
|
|
214
232
|
return result;
|
|
215
233
|
}
|
|
216
|
-
/** copy
|
|
234
|
+
/** copy xy into strongly typed Point2d */
|
|
217
235
|
getPoint2dAtCheckedPointIndex(pointIndex, result) {
|
|
218
|
-
const index = 2 * pointIndex;
|
|
219
236
|
if (this.isIndexValid(pointIndex)) {
|
|
237
|
+
const index = 2 * pointIndex;
|
|
220
238
|
return Point2dVector2d_1.Point2d.create(this._data[index], this._data[index + 1], result);
|
|
221
239
|
}
|
|
222
240
|
return undefined;
|
|
223
241
|
}
|
|
224
|
-
/** copy
|
|
242
|
+
/** copy xy into strongly typed Vector2d */
|
|
225
243
|
getVector2dAtCheckedVectorIndex(vectorIndex, result) {
|
|
226
|
-
const index = 2 * vectorIndex;
|
|
227
244
|
if (this.isIndexValid(vectorIndex)) {
|
|
245
|
+
const index = 2 * vectorIndex;
|
|
228
246
|
return Point2dVector2d_1.Vector2d.create(this._data[index], this._data[index + 1], result);
|
|
229
247
|
}
|
|
230
248
|
return undefined;
|
|
@@ -242,7 +260,6 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
242
260
|
const j = sourceIndex * 2;
|
|
243
261
|
this._data[i] = source._data[j];
|
|
244
262
|
this._data[i + 1] = source._data[j + 1];
|
|
245
|
-
this._data[i + 2] = source._data[j + 2];
|
|
246
263
|
return true;
|
|
247
264
|
}
|
|
248
265
|
return false;
|
|
@@ -250,21 +267,19 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
250
267
|
/**
|
|
251
268
|
* push coordinates from the source array to the end of this array.
|
|
252
269
|
* @param source source array
|
|
253
|
-
* @param sourceIndex
|
|
254
|
-
* @returns
|
|
270
|
+
* @param sourceIndex xy index within the source. If undefined, push entire contents of source
|
|
271
|
+
* @returns number of points pushed.
|
|
255
272
|
*/
|
|
256
273
|
pushFromGrowableXYArray(source, sourceIndex) {
|
|
274
|
+
// full array push . . .
|
|
257
275
|
if (sourceIndex === undefined) {
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
this.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
for (let i = 0; i < numFloatAdd; i++)
|
|
264
|
-
this._data[numFloatPresent + i] = source._data[i];
|
|
265
|
-
this._xyInUse += numPush;
|
|
266
|
-
return numPush;
|
|
276
|
+
const numXYAdd = source.length;
|
|
277
|
+
this.ensureCapacity(this.length + numXYAdd, false);
|
|
278
|
+
this.copyData(source._data, numXYAdd, this.length);
|
|
279
|
+
this._xyInUse += numXYAdd;
|
|
280
|
+
return numXYAdd;
|
|
267
281
|
}
|
|
282
|
+
// single point push . . .
|
|
268
283
|
if (source.isIndexValid(sourceIndex)) {
|
|
269
284
|
const j = sourceIndex * 2;
|
|
270
285
|
this.pushXY(source._data[j], source._data[j + 1]);
|
|
@@ -278,29 +293,31 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
278
293
|
*/
|
|
279
294
|
pushInterpolatedFromGrowableXYArray(source, i, fraction, j) {
|
|
280
295
|
if (source.isIndexValid(i) && source.isIndexValid(j)) {
|
|
296
|
+
const fraction0 = 1.0 - fraction;
|
|
281
297
|
const data = source._data;
|
|
282
|
-
i =
|
|
283
|
-
j =
|
|
284
|
-
this.pushXY(
|
|
298
|
+
i = 2 * i;
|
|
299
|
+
j = 2 * j;
|
|
300
|
+
this.pushXY(fraction0 * data[i] + fraction * data[j], fraction0 * data[i + 1] + fraction * data[j + 1]);
|
|
285
301
|
}
|
|
286
302
|
}
|
|
287
303
|
/**
|
|
288
|
-
*
|
|
289
|
-
* @param source source array
|
|
290
|
-
* @param transform optional transform to apply to points.
|
|
304
|
+
* Create an array of xy points from source xyz points.
|
|
305
|
+
* @param source source array of xyz
|
|
306
|
+
* @param transform optional transform to apply to xyz points.
|
|
291
307
|
* @param dest optional result.
|
|
292
308
|
*/
|
|
293
309
|
static createFromGrowableXYZArray(source, transform, dest) {
|
|
294
|
-
const
|
|
295
|
-
const numXYZ = source.length; // this is in xyz points
|
|
296
|
-
const nDouble = 3 * numXYZ;
|
|
310
|
+
const numPoints = source.length;
|
|
297
311
|
if (!dest)
|
|
298
|
-
dest = new GrowableXYArray(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
312
|
+
dest = new GrowableXYArray(numPoints);
|
|
313
|
+
else {
|
|
314
|
+
dest.ensureCapacity(numPoints, false);
|
|
315
|
+
dest.clear();
|
|
316
|
+
}
|
|
303
317
|
if (transform) {
|
|
318
|
+
const packedXYZ = source.float64Data();
|
|
319
|
+
const nDouble = 3 * numPoints;
|
|
320
|
+
let x, y, z;
|
|
304
321
|
for (let i = 0; i < nDouble; i += 3) {
|
|
305
322
|
x = packedXYZ[i];
|
|
306
323
|
y = packedXYZ[i + 1];
|
|
@@ -309,11 +326,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
309
326
|
}
|
|
310
327
|
}
|
|
311
328
|
else {
|
|
312
|
-
|
|
313
|
-
x = packedXYZ[i];
|
|
314
|
-
y = packedXYZ[i + 1];
|
|
315
|
-
dest.pushXY(x, y);
|
|
316
|
-
}
|
|
329
|
+
dest.pushAllXYAndZ(source);
|
|
317
330
|
}
|
|
318
331
|
return dest;
|
|
319
332
|
}
|
|
@@ -352,7 +365,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
352
365
|
* @param x x coordinate
|
|
353
366
|
* @param y y coordinate
|
|
354
367
|
*/
|
|
355
|
-
|
|
368
|
+
setXYAtCheckedPointIndex(pointIndex, x, y) {
|
|
356
369
|
if (!this.isIndexValid(pointIndex))
|
|
357
370
|
return false;
|
|
358
371
|
const index = pointIndex * 2;
|
|
@@ -361,15 +374,21 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
361
374
|
return true;
|
|
362
375
|
}
|
|
363
376
|
/**
|
|
364
|
-
*
|
|
377
|
+
* Set the coordinates of a single point given as coordinates.
|
|
378
|
+
* @deprecated Use setXYAtCheckedPointIndex instead
|
|
379
|
+
*/
|
|
380
|
+
setXYZAtCheckedPointIndex(pointIndex, x, y) {
|
|
381
|
+
return this.setXYAtCheckedPointIndex(pointIndex, x, y);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Copy all points into a simple array of Point3d with given z.
|
|
365
385
|
*/
|
|
366
386
|
getPoint3dArray(z = 0) {
|
|
387
|
+
const n = 2 * this._xyInUse;
|
|
367
388
|
const result = [];
|
|
368
389
|
const data = this._data;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
result.push(Point3dVector3d_1.Point3d.create(data[i * 2], data[i * 2 + 1], z));
|
|
372
|
-
}
|
|
390
|
+
for (let i = 0; i < n; i += 2)
|
|
391
|
+
result.push(Point3dVector3d_1.Point3d.create(data[i], data[i + 1], z));
|
|
373
392
|
return result;
|
|
374
393
|
}
|
|
375
394
|
/** reverse the order of points. */
|
|
@@ -401,21 +420,21 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
401
420
|
const y0 = origin.y;
|
|
402
421
|
let x = 0;
|
|
403
422
|
let y = 0;
|
|
404
|
-
for (let i = 0; i +
|
|
423
|
+
for (let i = 0; i + 1 < nDouble; i += 2) {
|
|
405
424
|
x = data[i];
|
|
406
425
|
y = data[i + 1];
|
|
407
426
|
data[i] = coffs[0] * x + coffs[1] * y + x0;
|
|
408
427
|
data[i + 1] = coffs[3] * x + coffs[4] * y + y0;
|
|
409
428
|
}
|
|
410
429
|
}
|
|
411
|
-
/** multiply each
|
|
430
|
+
/** multiply each xy (as a vector) by matrix, replace values. */
|
|
412
431
|
multiplyMatrix3dInPlace(matrix) {
|
|
413
432
|
const data = this._data;
|
|
414
433
|
const nDouble = this.float64Length;
|
|
415
434
|
const coffs = matrix.coffs;
|
|
416
435
|
let x = 0;
|
|
417
436
|
let y = 0;
|
|
418
|
-
for (let i = 0; i +
|
|
437
|
+
for (let i = 0; i + 1 < nDouble; i += 2) {
|
|
419
438
|
x = data[i];
|
|
420
439
|
y = data[i + 1];
|
|
421
440
|
data[i] = coffs[0] * x + coffs[1] * y;
|
|
@@ -436,12 +455,11 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
436
455
|
const y0 = origin.y;
|
|
437
456
|
let x = 0;
|
|
438
457
|
let y = 0;
|
|
439
|
-
for (let i = 0; i +
|
|
458
|
+
for (let i = 0; i + 1 < nDouble; i += 2) {
|
|
440
459
|
x = data[i] - x0;
|
|
441
460
|
y = data[i + 1] - y0;
|
|
442
461
|
data[i] = coffs[0] * x + coffs[1] * y;
|
|
443
462
|
data[i + 1] = coffs[3] * x + coffs[4] * y;
|
|
444
|
-
data[i + 2] = coffs[6] * x + coffs[7] * y;
|
|
445
463
|
}
|
|
446
464
|
return true;
|
|
447
465
|
}
|
|
@@ -450,11 +468,11 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
450
468
|
const numDouble = this.float64Length;
|
|
451
469
|
const data = this._data;
|
|
452
470
|
if (transform) {
|
|
453
|
-
for (let i = 0; i +
|
|
471
|
+
for (let i = 0; i + 1 < numDouble; i += 2)
|
|
454
472
|
rangeToExtend.extendTransformedXY(transform, data[i], data[i + 1]);
|
|
455
473
|
}
|
|
456
474
|
else {
|
|
457
|
-
for (let i = 0; i +
|
|
475
|
+
for (let i = 0; i + 1 < numDouble; i += 2)
|
|
458
476
|
rangeToExtend.extendXY(data[i], data[i + 1]);
|
|
459
477
|
}
|
|
460
478
|
}
|
|
@@ -468,7 +486,7 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
468
486
|
return sum;
|
|
469
487
|
}
|
|
470
488
|
/**
|
|
471
|
-
* Multiply each x,y
|
|
489
|
+
* Multiply each x,y by the scale factor.
|
|
472
490
|
* @param factor
|
|
473
491
|
*/
|
|
474
492
|
scaleInPlace(factor) {
|
|
@@ -528,21 +546,23 @@ class GrowableXYArray extends IndexedXYCollection_1.IndexedXYCollection {
|
|
|
528
546
|
}
|
|
529
547
|
/** Compute the cross product of vectors from from indexed origin to indexed targets i and j */
|
|
530
548
|
crossProductIndexIndexIndex(originIndex, targetAIndex, targetBIndex) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
549
|
+
if (this.isIndexValid(originIndex) && this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
550
|
+
const i = originIndex * 2;
|
|
551
|
+
const j = targetAIndex * 2;
|
|
552
|
+
const k = targetBIndex * 2;
|
|
553
|
+
const data = this._data;
|
|
536
554
|
return Geometry_1.Geometry.crossProductXYXY(data[j] - data[i], data[j + 1] - data[i + 1], data[k] - data[i], data[k + 1] - data[i + 1]);
|
|
555
|
+
}
|
|
537
556
|
return undefined;
|
|
538
557
|
}
|
|
539
558
|
/** Compute the cross product of vectors from from origin to indexed targets i and j */
|
|
540
559
|
crossProductXAndYIndexIndex(origin, targetAIndex, targetBIndex) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
560
|
+
if (this.isIndexValid(targetAIndex) && this.isIndexValid(targetBIndex)) {
|
|
561
|
+
const j = targetAIndex * 2;
|
|
562
|
+
const k = targetBIndex * 2;
|
|
563
|
+
const data = this._data;
|
|
545
564
|
return Geometry_1.Geometry.crossProductXYXY(data[j] - origin.x, data[j + 1] - origin.y, data[k] - origin.x, data[k + 1] - origin.y);
|
|
565
|
+
}
|
|
546
566
|
return undefined;
|
|
547
567
|
}
|
|
548
568
|
/** Return the distance between two points in the array. */
|