@itwin/core-geometry 4.0.0-dev.55 → 4.0.0-dev.56
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/Geometry.d.ts +5 -1
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +5 -1
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/geometry3d/Angle.d.ts +29 -34
- package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Angle.js +31 -36
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +48 -43
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +48 -43
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +5 -8
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +5 -8
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts +3 -3
- package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
- package/lib/cjs/geometry3d/OrderedRotationAngles.js +3 -3
- package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +8 -10
- package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dArrayCarrier.js +8 -10
- package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts +37 -34
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.js +38 -35
- package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +17 -21
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js +16 -20
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +84 -67
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +84 -67
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +76 -66
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +88 -77
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts +15 -16
- package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js +14 -15
- package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts +72 -58
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +132 -108
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/Geometry.d.ts +5 -1
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +5 -1
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/geometry3d/Angle.d.ts +29 -34
- package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
- package/lib/esm/geometry3d/Angle.js +31 -36
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +48 -43
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +48 -43
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +5 -8
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +5 -8
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/OrderedRotationAngles.d.ts +3 -3
- package/lib/esm/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
- package/lib/esm/geometry3d/OrderedRotationAngles.js +3 -3
- package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +8 -10
- package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dArrayCarrier.js +8 -10
- package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.d.ts +37 -34
- package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.js +38 -35
- package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +17 -21
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.js +16 -20
- package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +84 -67
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +84 -67
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +76 -66
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +88 -77
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.d.ts +15 -16
- package/lib/esm/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js +14 -15
- package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts +72 -58
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +132 -108
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/package.json +3 -3
|
@@ -13,7 +13,8 @@ const Angle_1 = require("./Angle");
|
|
|
13
13
|
const XYZProps_1 = require("./XYZProps");
|
|
14
14
|
// cspell:words CWXY CCWXY arctan Rodrigues
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* * `XYZ` is a minimal object containing x,y,z and operations that are meaningful without change in both
|
|
17
|
+
* point and vector.
|
|
17
18
|
* * `XYZ` is not instantiable.
|
|
18
19
|
* * The derived (instantiable) classes are
|
|
19
20
|
* * `Point3d`
|
|
@@ -57,7 +58,8 @@ class XYZ {
|
|
|
57
58
|
static isXYAndZ(arg) {
|
|
58
59
|
return this.isXAndY(arg) && this.hasZ(arg);
|
|
59
60
|
}
|
|
60
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Test if arg is any of:
|
|
61
63
|
* * XAndY
|
|
62
64
|
* * XYAndZ
|
|
63
65
|
* * [number,number]
|
|
@@ -66,7 +68,8 @@ class XYZ {
|
|
|
66
68
|
static isAnyImmediatePointType(arg) {
|
|
67
69
|
return Point3d.isXAndY(arg) || Geometry_1.Geometry.isNumberArray(arg, 2);
|
|
68
70
|
}
|
|
69
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Look for (in order) an x coordinate present as:
|
|
70
73
|
* * arg.x
|
|
71
74
|
* * arg[0]
|
|
72
75
|
*/
|
|
@@ -77,7 +80,8 @@ class XYZ {
|
|
|
77
80
|
return arg[0];
|
|
78
81
|
return defaultValue;
|
|
79
82
|
}
|
|
80
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Look for (in order) an x coordinate present as:
|
|
81
85
|
* * arg.y
|
|
82
86
|
* * arg[1]
|
|
83
87
|
*/
|
|
@@ -88,7 +92,8 @@ class XYZ {
|
|
|
88
92
|
return arg[1];
|
|
89
93
|
return defaultValue;
|
|
90
94
|
}
|
|
91
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Look for (in order) an x coordinate present as:
|
|
92
97
|
* * arg.z
|
|
93
98
|
* * arg[2]
|
|
94
99
|
*/
|
|
@@ -151,7 +156,8 @@ class XYZ {
|
|
|
151
156
|
this.setZero();
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Returns true if this and other have equal x,y,z parts within Geometry.smallMetricDistance.
|
|
155
161
|
* @param other The other XYAndZ to compare
|
|
156
162
|
* @param tol The tolerance for the comparison. If undefined, use [[Geometry.smallMetricDistance]]
|
|
157
163
|
*/
|
|
@@ -232,9 +238,7 @@ class XYZ {
|
|
|
232
238
|
maxDiff(other) {
|
|
233
239
|
return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y), Math.abs(this.z - other.z));
|
|
234
240
|
}
|
|
235
|
-
/**
|
|
236
|
-
* Return the x,y, z component corresponding to 0,1,2.
|
|
237
|
-
*/
|
|
241
|
+
/** Return the x,y, z component corresponding to 0,1,2 */
|
|
238
242
|
at(index) {
|
|
239
243
|
if (index < 0.5)
|
|
240
244
|
return this.x;
|
|
@@ -242,9 +246,7 @@ class XYZ {
|
|
|
242
246
|
return this.z;
|
|
243
247
|
return this.y;
|
|
244
248
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Set value at index 0 or 1 or 2.
|
|
247
|
-
*/
|
|
249
|
+
/** Set value at index 0 or 1 or 2 */
|
|
248
250
|
setAt(index, value) {
|
|
249
251
|
if (index < 0.5)
|
|
250
252
|
this.x = value;
|
|
@@ -298,27 +300,27 @@ class XYZ {
|
|
|
298
300
|
magnitudeSquaredXY() {
|
|
299
301
|
return this.x * this.x + this.y * this.y;
|
|
300
302
|
}
|
|
301
|
-
/**
|
|
303
|
+
/** Exact equality test. */
|
|
302
304
|
isExactEqual(other) {
|
|
303
305
|
return this.x === other.x && this.y === other.y && this.z === other.z;
|
|
304
306
|
}
|
|
305
|
-
/**
|
|
307
|
+
/** Equality test with Geometry.smallMetricDistance tolerance */
|
|
306
308
|
isAlmostEqualMetric(other) {
|
|
307
309
|
return this.maxDiff(other) <= Geometry_1.Geometry.smallMetricDistance;
|
|
308
310
|
}
|
|
309
|
-
/**
|
|
311
|
+
/** Add x,y,z from other in place. */
|
|
310
312
|
addInPlace(other) {
|
|
311
313
|
this.x += other.x;
|
|
312
314
|
this.y += other.y;
|
|
313
315
|
this.z += other.z;
|
|
314
316
|
}
|
|
315
|
-
/**
|
|
317
|
+
/** Add x,y,z from other in place. */
|
|
316
318
|
subtractInPlace(other) {
|
|
317
319
|
this.x -= other.x;
|
|
318
320
|
this.y -= other.y;
|
|
319
321
|
this.z -= other.z;
|
|
320
322
|
}
|
|
321
|
-
/**
|
|
323
|
+
/** Add (in place) the scaled x,y,z of other */
|
|
322
324
|
addScaledInPlace(other, scale) {
|
|
323
325
|
this.x += scale * other.x;
|
|
324
326
|
this.y += scale * other.y;
|
|
@@ -330,7 +332,7 @@ class XYZ {
|
|
|
330
332
|
this.y *= scale;
|
|
331
333
|
this.z *= scale;
|
|
332
334
|
}
|
|
333
|
-
/**
|
|
335
|
+
/** Add to x, y, z parts */
|
|
334
336
|
addXYZInPlace(dx = 0.0, dy = 0.0, dz = 0.0) {
|
|
335
337
|
this.x += dx;
|
|
336
338
|
this.y += dy;
|
|
@@ -348,7 +350,8 @@ class XYZ {
|
|
|
348
350
|
scaledVectorTo(other, scale, result) {
|
|
349
351
|
return Vector3d.create(scale * (other.x - this.x), scale * (other.y - this.y), scale * (other.z - this.z), result);
|
|
350
352
|
}
|
|
351
|
-
/**
|
|
353
|
+
/**
|
|
354
|
+
* Return a unit vector from this vector to other. Return a 000 vector if the input is too small to normalize.
|
|
352
355
|
* @param other target of created vector.
|
|
353
356
|
* @param result optional result vector.
|
|
354
357
|
*/
|
|
@@ -359,7 +362,7 @@ class XYZ {
|
|
|
359
362
|
freeze() {
|
|
360
363
|
return Object.freeze(this);
|
|
361
364
|
}
|
|
362
|
-
/**
|
|
365
|
+
/** Access x part of XYZProps (which may be .x or [0]) */
|
|
363
366
|
static x(xyz, defaultValue = 0) {
|
|
364
367
|
if (xyz === undefined)
|
|
365
368
|
return defaultValue;
|
|
@@ -369,7 +372,7 @@ class XYZ {
|
|
|
369
372
|
return xyz.x;
|
|
370
373
|
return defaultValue;
|
|
371
374
|
}
|
|
372
|
-
/**
|
|
375
|
+
/** Access x part of XYZProps (which may be .x or [0]) */
|
|
373
376
|
static y(xyz, defaultValue = 0) {
|
|
374
377
|
if (xyz === undefined)
|
|
375
378
|
return defaultValue;
|
|
@@ -379,7 +382,7 @@ class XYZ {
|
|
|
379
382
|
return xyz.y;
|
|
380
383
|
return defaultValue;
|
|
381
384
|
}
|
|
382
|
-
/**
|
|
385
|
+
/** Access x part of XYZProps (which may be .x or [0]) */
|
|
383
386
|
static z(xyz, defaultValue = 0) {
|
|
384
387
|
if (xyz === undefined)
|
|
385
388
|
return defaultValue;
|
|
@@ -415,7 +418,8 @@ class Point3d extends XYZ {
|
|
|
415
418
|
clone(result) {
|
|
416
419
|
return Point3d.create(this.x, this.y, this.z, result);
|
|
417
420
|
}
|
|
418
|
-
/**
|
|
421
|
+
/**
|
|
422
|
+
* Create a new Point3d with given coordinates
|
|
419
423
|
* @param x x part
|
|
420
424
|
* @param y y part
|
|
421
425
|
* @param z z part
|
|
@@ -488,8 +492,8 @@ class Point3d extends XYZ {
|
|
|
488
492
|
static createZero(result) {
|
|
489
493
|
return Point3d.create(0, 0, 0, result);
|
|
490
494
|
}
|
|
491
|
-
/**
|
|
492
|
-
*
|
|
495
|
+
/**
|
|
496
|
+
* Return the cross product of the vectors from this to pointA and pointB
|
|
493
497
|
* * the result is a vector
|
|
494
498
|
* * the result is perpendicular to both vectors, with right hand orientation
|
|
495
499
|
* * the magnitude of the vector is twice the area of the triangle.
|
|
@@ -497,21 +501,20 @@ class Point3d extends XYZ {
|
|
|
497
501
|
crossProductToPoints(pointA, pointB, result) {
|
|
498
502
|
return Vector3d.createCrossProduct(pointA.x - this.x, pointA.y - this.y, pointA.z - this.z, pointB.x - this.x, pointB.y - this.y, pointB.z - this.z, result);
|
|
499
503
|
}
|
|
500
|
-
/** Return the magnitude of the cross product of the vectors from this to pointA and pointB
|
|
501
|
-
*/
|
|
504
|
+
/** Return the magnitude of the cross product of the vectors from this to pointA and pointB */
|
|
502
505
|
crossProductToPointsMagnitude(pointA, pointB) {
|
|
503
506
|
return Geometry_1.Geometry.crossProductMagnitude(pointA.x - this.x, pointA.y - this.y, pointA.z - this.z, pointB.x - this.x, pointB.y - this.y, pointB.z - this.z);
|
|
504
507
|
}
|
|
505
|
-
/**
|
|
506
|
-
*
|
|
508
|
+
/**
|
|
509
|
+
* Return the triple product of the vectors from this to pointA, pointB, pointC
|
|
507
510
|
* * This is a scalar (number)
|
|
508
511
|
* * This is 6 times the (signed) volume of the tetrahedron on the 4 points.
|
|
509
512
|
*/
|
|
510
513
|
tripleProductToPoints(pointA, pointB, pointC) {
|
|
511
514
|
return Geometry_1.Geometry.tripleProduct(pointA.x - this.x, pointA.y - this.y, pointA.z - this.z, pointB.x - this.x, pointB.y - this.y, pointB.z - this.z, pointC.x - this.x, pointC.y - this.y, pointC.z - this.z);
|
|
512
515
|
}
|
|
513
|
-
/**
|
|
514
|
-
*
|
|
516
|
+
/**
|
|
517
|
+
* Return the cross product of the vectors from this to pointA and pointB
|
|
515
518
|
* * the result is a scalar
|
|
516
519
|
* * the magnitude of the vector is twice the signed area of the triangle.
|
|
517
520
|
* * this is positive for counter-clockwise order of the points, negative for clockwise.
|
|
@@ -521,8 +524,8 @@ class Point3d extends XYZ {
|
|
|
521
524
|
}
|
|
522
525
|
/**
|
|
523
526
|
* Return a point interpolated between `this` point and the `other` point.
|
|
524
|
-
* *
|
|
525
|
-
|
|
527
|
+
* * Fraction specifies where the interpolated point is located on the line passing `this` and `other`.
|
|
528
|
+
*/
|
|
526
529
|
interpolate(fraction, other, result) {
|
|
527
530
|
if (fraction <= 0.5)
|
|
528
531
|
return Point3d.create(this.x + fraction * (other.x - this.x), this.y + fraction * (other.y - this.y), this.z + fraction * (other.z - this.z), result);
|
|
@@ -575,7 +578,8 @@ class Point3d extends XYZ {
|
|
|
575
578
|
static createScale(source, scale, result) {
|
|
576
579
|
return Point3d.create(source.x * scale, source.y * scale, source.z * scale, result);
|
|
577
580
|
}
|
|
578
|
-
/**
|
|
581
|
+
/**
|
|
582
|
+
* Create a point that is a linear combination (weighted sum) of 2 input points.
|
|
579
583
|
* @param pointA first input point
|
|
580
584
|
* @param scaleA scale factor for pointA
|
|
581
585
|
* @param pointB second input point
|
|
@@ -614,7 +618,8 @@ class Point3d extends XYZ {
|
|
|
614
618
|
}
|
|
615
619
|
}
|
|
616
620
|
exports.Point3d = Point3d;
|
|
617
|
-
/**
|
|
621
|
+
/**
|
|
622
|
+
* 3D vector with `x`,`y`,`z` as properties
|
|
618
623
|
* @public
|
|
619
624
|
*/
|
|
620
625
|
class Vector3d extends XYZ {
|
|
@@ -639,7 +644,7 @@ class Vector3d extends XYZ {
|
|
|
639
644
|
return Vector3d.create(this.x, this.y, this.z, result);
|
|
640
645
|
}
|
|
641
646
|
/**
|
|
642
|
-
*
|
|
647
|
+
* Return a Vector3d (new or reused from optional result)
|
|
643
648
|
* @param x x component
|
|
644
649
|
* @param y y component
|
|
645
650
|
* @param z z component
|
|
@@ -692,7 +697,6 @@ class Vector3d extends XYZ {
|
|
|
692
697
|
}
|
|
693
698
|
/**
|
|
694
699
|
* Return the cross product of the vectors from origin to pointA and pointB.
|
|
695
|
-
*
|
|
696
700
|
* * the result is a vector
|
|
697
701
|
* * the result is perpendicular to both vectors, with right hand orientation
|
|
698
702
|
* * the magnitude of the vector is twice the area of the triangle.
|
|
@@ -869,7 +873,8 @@ class Vector3d extends XYZ {
|
|
|
869
873
|
this.z *= a;
|
|
870
874
|
return true;
|
|
871
875
|
}
|
|
872
|
-
/**
|
|
876
|
+
/**
|
|
877
|
+
* Create a normalized vector from the inputs.
|
|
873
878
|
* @param result optional result
|
|
874
879
|
* @returns undefined if and only if normalization fails
|
|
875
880
|
*/
|
|
@@ -903,7 +908,8 @@ class Vector3d extends XYZ {
|
|
|
903
908
|
return defaultFraction;
|
|
904
909
|
return numerator / denominator;
|
|
905
910
|
}
|
|
906
|
-
/**
|
|
911
|
+
/**
|
|
912
|
+
* Return a new vector with components negated from the calling instance.
|
|
907
913
|
* @param result optional result vector.
|
|
908
914
|
*/
|
|
909
915
|
negate(result) {
|
|
@@ -985,7 +991,8 @@ class Vector3d extends XYZ {
|
|
|
985
991
|
const normal = this.crossProduct(target).normalize();
|
|
986
992
|
return normal ? normal.crossProduct(this, result) : undefined;
|
|
987
993
|
}
|
|
988
|
-
/**
|
|
994
|
+
/**
|
|
995
|
+
* Rotate this vector 90 degrees around an axis vector.
|
|
989
996
|
* * Note that simple cross is in the plane perpendicular to axis -- it loses the part
|
|
990
997
|
* of "this" that is along the axis. The unit and scale is supposed to fix that.
|
|
991
998
|
* This matches with Rodrigues' rotation formula because cos(theta) = 0 and sin(theta) = 1
|
|
@@ -1074,8 +1081,10 @@ class Vector3d extends XYZ {
|
|
|
1074
1081
|
static createAdd2Scaled(vectorA, scaleA, vectorB, scaleB, result) {
|
|
1075
1082
|
return Vector3d.create(vectorA.x * scaleA + vectorB.x * scaleB, vectorA.y * scaleA + vectorB.y * scaleB, vectorA.z * scaleA + vectorB.z * scaleB, result);
|
|
1076
1083
|
}
|
|
1077
|
-
/**
|
|
1078
|
-
*
|
|
1084
|
+
/**
|
|
1085
|
+
* Return the (strongly typed Vector3d) `thisVector3d + vectorA * scalarA + vectorB * scalarB`
|
|
1086
|
+
* with all components presented as numbers
|
|
1087
|
+
*/
|
|
1079
1088
|
static createAdd2ScaledXYZ(ax, ay, az, scaleA, bx, by, bz, scaleB, result) {
|
|
1080
1089
|
return Vector3d.create(ax * scaleA + bx * scaleB, ay * scaleA + by * scaleB, az * scaleA + bz * scaleB, result);
|
|
1081
1090
|
}
|
|
@@ -1102,7 +1111,8 @@ class Vector3d extends XYZ {
|
|
|
1102
1111
|
return undefined;
|
|
1103
1112
|
return this.scale(length / mag, result);
|
|
1104
1113
|
}
|
|
1105
|
-
/**
|
|
1114
|
+
/**
|
|
1115
|
+
* Compute the cross product of this vector with `vectorB`. Immediately pass it to `normalize`.
|
|
1106
1116
|
* @param vectorB second vector for cross product.
|
|
1107
1117
|
* @returns see `Vector3d` method `normalize()` for error condition.
|
|
1108
1118
|
*/
|
|
@@ -1189,7 +1199,8 @@ class Vector3d extends XYZ {
|
|
|
1189
1199
|
crossProductMagnitude(vectorB) {
|
|
1190
1200
|
return Math.sqrt(this.crossProductMagnitudeSquared(vectorB));
|
|
1191
1201
|
}
|
|
1192
|
-
/**
|
|
1202
|
+
/**
|
|
1203
|
+
* Return the dot product of this vector with vectorB.
|
|
1193
1204
|
* @param vectorB second vector of cross product
|
|
1194
1205
|
* @returns the dot product of this instance with vectorB
|
|
1195
1206
|
*/
|
|
@@ -1245,7 +1256,8 @@ class Vector3d extends XYZ {
|
|
|
1245
1256
|
return this.x * (pointB.x - pointA.x)
|
|
1246
1257
|
+ this.y * (pointB.y - pointA.y);
|
|
1247
1258
|
}
|
|
1248
|
-
/**
|
|
1259
|
+
/**
|
|
1260
|
+
* Dot product with vector from pointA to pointB, with pointB given as (weighted) wx,wy,wz,w
|
|
1249
1261
|
* * We need to unweight pointB (which is a homogeneous point) to be able to participate in the
|
|
1250
1262
|
* vector dot product
|
|
1251
1263
|
* * if the weight is near zero metric, the return is zero.
|
|
@@ -1289,7 +1301,7 @@ class Vector3d extends XYZ {
|
|
|
1289
1301
|
return Vector3d.createCrossProduct(this.x, this.y, this.z, vectorB.x, vectorB.y, vectorB.z, result);
|
|
1290
1302
|
}
|
|
1291
1303
|
/**
|
|
1292
|
-
*
|
|
1304
|
+
* Return cross product of `this` with the vector `(x, y, z)`
|
|
1293
1305
|
* @param x x component of second vector
|
|
1294
1306
|
* @param y y component of second vector
|
|
1295
1307
|
* @param z z component of second vector
|
|
@@ -1299,12 +1311,12 @@ class Vector3d extends XYZ {
|
|
|
1299
1311
|
return Vector3d.createCrossProduct(this.x, this.y, this.z, x, y, z, result);
|
|
1300
1312
|
}
|
|
1301
1313
|
/**
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1314
|
+
* Return the angle in radians (not as strongly typed Angle) from this vector to vectorB.
|
|
1315
|
+
* * The returned angle is between 0 and `Math.PI`.
|
|
1316
|
+
* * The returned angle is measured in the plane containing the two vectors.
|
|
1317
|
+
* * Use `planarRadiansTo` and `signedRadiansTo` to return an angle measured in a specific plane.
|
|
1318
|
+
* @param vectorB target vector.
|
|
1319
|
+
*/
|
|
1308
1320
|
radiansTo(vectorB) {
|
|
1309
1321
|
// ||axb|| = ||a|| ||b|| |sin(t)| and a.b = ||a|| ||b|| cos(t) ==>
|
|
1310
1322
|
// ||axb|| / a.b = sin(t)/cos(t) = tan(t) ==> t = arctan(||axb|| / a.b).
|
|
@@ -1340,16 +1352,16 @@ class Vector3d extends XYZ {
|
|
|
1340
1352
|
return Angle_1.Angle.createAtan2(this.crossProductXY(vectorB), this.dotProductXY(vectorB));
|
|
1341
1353
|
}
|
|
1342
1354
|
/**
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1355
|
+
* Return the angle in radians (not as strongly-typed Angle) from this vector to vectorB, measured
|
|
1356
|
+
* in their containing plane whose normal lies in the same half-space as vectorW.
|
|
1357
|
+
* * The returned angle is between `-Math.PI` and `Math.PI`.
|
|
1358
|
+
* * If the cross product of this vector and vectorB lies on the same side of the plane as vectorW,
|
|
1359
|
+
* this function returns `radiansTo(vectorB)`; otherwise, it returns `-radiansTo(vectorB)`.
|
|
1360
|
+
* * `vectorW` does not have to be perpendicular to the plane.
|
|
1361
|
+
* * Use `planarRadiansTo` to measure the angle between vectors that are projected to another plane.
|
|
1362
|
+
* @param vectorB target vector.
|
|
1363
|
+
* @param vectorW determines the side of the plane in which the returned angle is measured
|
|
1364
|
+
*/
|
|
1353
1365
|
signedRadiansTo(vectorB, vectorW) {
|
|
1354
1366
|
const p = this.crossProduct(vectorB);
|
|
1355
1367
|
const theta = Math.atan2(p.magnitude(), this.dotProduct(vectorB));
|
|
@@ -1358,7 +1370,8 @@ class Vector3d extends XYZ {
|
|
|
1358
1370
|
else
|
|
1359
1371
|
return theta;
|
|
1360
1372
|
}
|
|
1361
|
-
/**
|
|
1373
|
+
/**
|
|
1374
|
+
* Return the (strongly-typed) angle from this vector to vectorB, measured
|
|
1362
1375
|
* in their containing plane whose normal lies in the same half-space as vectorW.
|
|
1363
1376
|
* * The returned angle is between -180 and 180 degrees.
|
|
1364
1377
|
* * If the cross product of this vector and vectorB lies on the same side of the plane as vectorW,
|
|
@@ -1401,15 +1414,19 @@ class Vector3d extends XYZ {
|
|
|
1401
1414
|
planarAngleTo(vectorB, planeNormal) {
|
|
1402
1415
|
return Angle_1.Angle.createRadians(this.planarRadiansTo(vectorB, planeNormal));
|
|
1403
1416
|
}
|
|
1404
|
-
/**
|
|
1405
|
-
|
|
1417
|
+
/**
|
|
1418
|
+
* Return the smallest angle (in radians) from the (bidirectional) line containing `this`
|
|
1419
|
+
* to the (bidirectional) line containing `vectorB`
|
|
1420
|
+
*/
|
|
1406
1421
|
smallerUnorientedRadiansTo(vectorB) {
|
|
1407
1422
|
const c = this.dotProduct(vectorB);
|
|
1408
1423
|
const s = this.crossProductMagnitude(vectorB);
|
|
1409
1424
|
return Math.atan2(Math.abs(s), Math.abs(c));
|
|
1410
1425
|
}
|
|
1411
|
-
/**
|
|
1412
|
-
*
|
|
1426
|
+
/**
|
|
1427
|
+
* Return the smallest (strongly typed) angle from the (bidirectional) line containing `this`
|
|
1428
|
+
* to the (bidirectional) line containing `vectorB`
|
|
1429
|
+
*/
|
|
1413
1430
|
smallerUnorientedAngleTo(vectorB) {
|
|
1414
1431
|
return Angle_1.Angle.createRadians(this.smallerUnorientedRadiansTo(vectorB));
|
|
1415
1432
|
}
|