@itwin/core-geometry 4.0.0-dev.55 → 4.0.0-dev.58
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
|
@@ -10,7 +10,8 @@ import { Angle } from "./Angle";
|
|
|
10
10
|
import { XYAndZ } from "./XYZProps";
|
|
11
11
|
// cspell:words CWXY CCWXY arctan Rodrigues
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* * `XYZ` is a minimal object containing x,y,z and operations that are meaningful without change in both
|
|
14
|
+
* point and vector.
|
|
14
15
|
* * `XYZ` is not instantiable.
|
|
15
16
|
* * The derived (instantiable) classes are
|
|
16
17
|
* * `Point3d`
|
|
@@ -54,7 +55,8 @@ export class XYZ {
|
|
|
54
55
|
static isXYAndZ(arg) {
|
|
55
56
|
return this.isXAndY(arg) && this.hasZ(arg);
|
|
56
57
|
}
|
|
57
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Test if arg is any of:
|
|
58
60
|
* * XAndY
|
|
59
61
|
* * XYAndZ
|
|
60
62
|
* * [number,number]
|
|
@@ -63,7 +65,8 @@ export class XYZ {
|
|
|
63
65
|
static isAnyImmediatePointType(arg) {
|
|
64
66
|
return Point3d.isXAndY(arg) || Geometry.isNumberArray(arg, 2);
|
|
65
67
|
}
|
|
66
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Look for (in order) an x coordinate present as:
|
|
67
70
|
* * arg.x
|
|
68
71
|
* * arg[0]
|
|
69
72
|
*/
|
|
@@ -74,7 +77,8 @@ export class XYZ {
|
|
|
74
77
|
return arg[0];
|
|
75
78
|
return defaultValue;
|
|
76
79
|
}
|
|
77
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Look for (in order) an x coordinate present as:
|
|
78
82
|
* * arg.y
|
|
79
83
|
* * arg[1]
|
|
80
84
|
*/
|
|
@@ -85,7 +89,8 @@ export class XYZ {
|
|
|
85
89
|
return arg[1];
|
|
86
90
|
return defaultValue;
|
|
87
91
|
}
|
|
88
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Look for (in order) an x coordinate present as:
|
|
89
94
|
* * arg.z
|
|
90
95
|
* * arg[2]
|
|
91
96
|
*/
|
|
@@ -148,7 +153,8 @@ export class XYZ {
|
|
|
148
153
|
this.setZero();
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Returns true if this and other have equal x,y,z parts within Geometry.smallMetricDistance.
|
|
152
158
|
* @param other The other XYAndZ to compare
|
|
153
159
|
* @param tol The tolerance for the comparison. If undefined, use [[Geometry.smallMetricDistance]]
|
|
154
160
|
*/
|
|
@@ -229,9 +235,7 @@ export class XYZ {
|
|
|
229
235
|
maxDiff(other) {
|
|
230
236
|
return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y), Math.abs(this.z - other.z));
|
|
231
237
|
}
|
|
232
|
-
/**
|
|
233
|
-
* Return the x,y, z component corresponding to 0,1,2.
|
|
234
|
-
*/
|
|
238
|
+
/** Return the x,y, z component corresponding to 0,1,2 */
|
|
235
239
|
at(index) {
|
|
236
240
|
if (index < 0.5)
|
|
237
241
|
return this.x;
|
|
@@ -239,9 +243,7 @@ export class XYZ {
|
|
|
239
243
|
return this.z;
|
|
240
244
|
return this.y;
|
|
241
245
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Set value at index 0 or 1 or 2.
|
|
244
|
-
*/
|
|
246
|
+
/** Set value at index 0 or 1 or 2 */
|
|
245
247
|
setAt(index, value) {
|
|
246
248
|
if (index < 0.5)
|
|
247
249
|
this.x = value;
|
|
@@ -295,27 +297,27 @@ export class XYZ {
|
|
|
295
297
|
magnitudeSquaredXY() {
|
|
296
298
|
return this.x * this.x + this.y * this.y;
|
|
297
299
|
}
|
|
298
|
-
/**
|
|
300
|
+
/** Exact equality test. */
|
|
299
301
|
isExactEqual(other) {
|
|
300
302
|
return this.x === other.x && this.y === other.y && this.z === other.z;
|
|
301
303
|
}
|
|
302
|
-
/**
|
|
304
|
+
/** Equality test with Geometry.smallMetricDistance tolerance */
|
|
303
305
|
isAlmostEqualMetric(other) {
|
|
304
306
|
return this.maxDiff(other) <= Geometry.smallMetricDistance;
|
|
305
307
|
}
|
|
306
|
-
/**
|
|
308
|
+
/** Add x,y,z from other in place. */
|
|
307
309
|
addInPlace(other) {
|
|
308
310
|
this.x += other.x;
|
|
309
311
|
this.y += other.y;
|
|
310
312
|
this.z += other.z;
|
|
311
313
|
}
|
|
312
|
-
/**
|
|
314
|
+
/** Add x,y,z from other in place. */
|
|
313
315
|
subtractInPlace(other) {
|
|
314
316
|
this.x -= other.x;
|
|
315
317
|
this.y -= other.y;
|
|
316
318
|
this.z -= other.z;
|
|
317
319
|
}
|
|
318
|
-
/**
|
|
320
|
+
/** Add (in place) the scaled x,y,z of other */
|
|
319
321
|
addScaledInPlace(other, scale) {
|
|
320
322
|
this.x += scale * other.x;
|
|
321
323
|
this.y += scale * other.y;
|
|
@@ -327,7 +329,7 @@ export class XYZ {
|
|
|
327
329
|
this.y *= scale;
|
|
328
330
|
this.z *= scale;
|
|
329
331
|
}
|
|
330
|
-
/**
|
|
332
|
+
/** Add to x, y, z parts */
|
|
331
333
|
addXYZInPlace(dx = 0.0, dy = 0.0, dz = 0.0) {
|
|
332
334
|
this.x += dx;
|
|
333
335
|
this.y += dy;
|
|
@@ -345,7 +347,8 @@ export class XYZ {
|
|
|
345
347
|
scaledVectorTo(other, scale, result) {
|
|
346
348
|
return Vector3d.create(scale * (other.x - this.x), scale * (other.y - this.y), scale * (other.z - this.z), result);
|
|
347
349
|
}
|
|
348
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Return a unit vector from this vector to other. Return a 000 vector if the input is too small to normalize.
|
|
349
352
|
* @param other target of created vector.
|
|
350
353
|
* @param result optional result vector.
|
|
351
354
|
*/
|
|
@@ -356,7 +359,7 @@ export class XYZ {
|
|
|
356
359
|
freeze() {
|
|
357
360
|
return Object.freeze(this);
|
|
358
361
|
}
|
|
359
|
-
/**
|
|
362
|
+
/** Access x part of XYZProps (which may be .x or [0]) */
|
|
360
363
|
static x(xyz, defaultValue = 0) {
|
|
361
364
|
if (xyz === undefined)
|
|
362
365
|
return defaultValue;
|
|
@@ -366,7 +369,7 @@ export class XYZ {
|
|
|
366
369
|
return xyz.x;
|
|
367
370
|
return defaultValue;
|
|
368
371
|
}
|
|
369
|
-
/**
|
|
372
|
+
/** Access x part of XYZProps (which may be .x or [0]) */
|
|
370
373
|
static y(xyz, defaultValue = 0) {
|
|
371
374
|
if (xyz === undefined)
|
|
372
375
|
return defaultValue;
|
|
@@ -376,7 +379,7 @@ export class XYZ {
|
|
|
376
379
|
return xyz.y;
|
|
377
380
|
return defaultValue;
|
|
378
381
|
}
|
|
379
|
-
/**
|
|
382
|
+
/** Access x part of XYZProps (which may be .x or [0]) */
|
|
380
383
|
static z(xyz, defaultValue = 0) {
|
|
381
384
|
if (xyz === undefined)
|
|
382
385
|
return defaultValue;
|
|
@@ -411,7 +414,8 @@ export class Point3d extends XYZ {
|
|
|
411
414
|
clone(result) {
|
|
412
415
|
return Point3d.create(this.x, this.y, this.z, result);
|
|
413
416
|
}
|
|
414
|
-
/**
|
|
417
|
+
/**
|
|
418
|
+
* Create a new Point3d with given coordinates
|
|
415
419
|
* @param x x part
|
|
416
420
|
* @param y y part
|
|
417
421
|
* @param z z part
|
|
@@ -484,8 +488,8 @@ export class Point3d extends XYZ {
|
|
|
484
488
|
static createZero(result) {
|
|
485
489
|
return Point3d.create(0, 0, 0, result);
|
|
486
490
|
}
|
|
487
|
-
/**
|
|
488
|
-
*
|
|
491
|
+
/**
|
|
492
|
+
* Return the cross product of the vectors from this to pointA and pointB
|
|
489
493
|
* * the result is a vector
|
|
490
494
|
* * the result is perpendicular to both vectors, with right hand orientation
|
|
491
495
|
* * the magnitude of the vector is twice the area of the triangle.
|
|
@@ -493,21 +497,20 @@ export class Point3d extends XYZ {
|
|
|
493
497
|
crossProductToPoints(pointA, pointB, result) {
|
|
494
498
|
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);
|
|
495
499
|
}
|
|
496
|
-
/** Return the magnitude of the cross product of the vectors from this to pointA and pointB
|
|
497
|
-
*/
|
|
500
|
+
/** Return the magnitude of the cross product of the vectors from this to pointA and pointB */
|
|
498
501
|
crossProductToPointsMagnitude(pointA, pointB) {
|
|
499
502
|
return 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);
|
|
500
503
|
}
|
|
501
|
-
/**
|
|
502
|
-
*
|
|
504
|
+
/**
|
|
505
|
+
* Return the triple product of the vectors from this to pointA, pointB, pointC
|
|
503
506
|
* * This is a scalar (number)
|
|
504
507
|
* * This is 6 times the (signed) volume of the tetrahedron on the 4 points.
|
|
505
508
|
*/
|
|
506
509
|
tripleProductToPoints(pointA, pointB, pointC) {
|
|
507
510
|
return 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);
|
|
508
511
|
}
|
|
509
|
-
/**
|
|
510
|
-
*
|
|
512
|
+
/**
|
|
513
|
+
* Return the cross product of the vectors from this to pointA and pointB
|
|
511
514
|
* * the result is a scalar
|
|
512
515
|
* * the magnitude of the vector is twice the signed area of the triangle.
|
|
513
516
|
* * this is positive for counter-clockwise order of the points, negative for clockwise.
|
|
@@ -517,8 +520,8 @@ export class Point3d extends XYZ {
|
|
|
517
520
|
}
|
|
518
521
|
/**
|
|
519
522
|
* Return a point interpolated between `this` point and the `other` point.
|
|
520
|
-
* *
|
|
521
|
-
|
|
523
|
+
* * Fraction specifies where the interpolated point is located on the line passing `this` and `other`.
|
|
524
|
+
*/
|
|
522
525
|
interpolate(fraction, other, result) {
|
|
523
526
|
if (fraction <= 0.5)
|
|
524
527
|
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);
|
|
@@ -571,7 +574,8 @@ export class Point3d extends XYZ {
|
|
|
571
574
|
static createScale(source, scale, result) {
|
|
572
575
|
return Point3d.create(source.x * scale, source.y * scale, source.z * scale, result);
|
|
573
576
|
}
|
|
574
|
-
/**
|
|
577
|
+
/**
|
|
578
|
+
* Create a point that is a linear combination (weighted sum) of 2 input points.
|
|
575
579
|
* @param pointA first input point
|
|
576
580
|
* @param scaleA scale factor for pointA
|
|
577
581
|
* @param pointB second input point
|
|
@@ -609,7 +613,8 @@ export class Point3d extends XYZ {
|
|
|
609
613
|
return startPoint.dotVectorsToTargets(endPoint, this) / denominator;
|
|
610
614
|
}
|
|
611
615
|
}
|
|
612
|
-
/**
|
|
616
|
+
/**
|
|
617
|
+
* 3D vector with `x`,`y`,`z` as properties
|
|
613
618
|
* @public
|
|
614
619
|
*/
|
|
615
620
|
export class Vector3d extends XYZ {
|
|
@@ -634,7 +639,7 @@ export class Vector3d extends XYZ {
|
|
|
634
639
|
return Vector3d.create(this.x, this.y, this.z, result);
|
|
635
640
|
}
|
|
636
641
|
/**
|
|
637
|
-
*
|
|
642
|
+
* Return a Vector3d (new or reused from optional result)
|
|
638
643
|
* @param x x component
|
|
639
644
|
* @param y y component
|
|
640
645
|
* @param z z component
|
|
@@ -687,7 +692,6 @@ export class Vector3d extends XYZ {
|
|
|
687
692
|
}
|
|
688
693
|
/**
|
|
689
694
|
* Return the cross product of the vectors from origin to pointA and pointB.
|
|
690
|
-
*
|
|
691
695
|
* * the result is a vector
|
|
692
696
|
* * the result is perpendicular to both vectors, with right hand orientation
|
|
693
697
|
* * the magnitude of the vector is twice the area of the triangle.
|
|
@@ -864,7 +868,8 @@ export class Vector3d extends XYZ {
|
|
|
864
868
|
this.z *= a;
|
|
865
869
|
return true;
|
|
866
870
|
}
|
|
867
|
-
/**
|
|
871
|
+
/**
|
|
872
|
+
* Create a normalized vector from the inputs.
|
|
868
873
|
* @param result optional result
|
|
869
874
|
* @returns undefined if and only if normalization fails
|
|
870
875
|
*/
|
|
@@ -898,7 +903,8 @@ export class Vector3d extends XYZ {
|
|
|
898
903
|
return defaultFraction;
|
|
899
904
|
return numerator / denominator;
|
|
900
905
|
}
|
|
901
|
-
/**
|
|
906
|
+
/**
|
|
907
|
+
* Return a new vector with components negated from the calling instance.
|
|
902
908
|
* @param result optional result vector.
|
|
903
909
|
*/
|
|
904
910
|
negate(result) {
|
|
@@ -980,7 +986,8 @@ export class Vector3d extends XYZ {
|
|
|
980
986
|
const normal = this.crossProduct(target).normalize();
|
|
981
987
|
return normal ? normal.crossProduct(this, result) : undefined;
|
|
982
988
|
}
|
|
983
|
-
/**
|
|
989
|
+
/**
|
|
990
|
+
* Rotate this vector 90 degrees around an axis vector.
|
|
984
991
|
* * Note that simple cross is in the plane perpendicular to axis -- it loses the part
|
|
985
992
|
* of "this" that is along the axis. The unit and scale is supposed to fix that.
|
|
986
993
|
* This matches with Rodrigues' rotation formula because cos(theta) = 0 and sin(theta) = 1
|
|
@@ -1069,8 +1076,10 @@ export class Vector3d extends XYZ {
|
|
|
1069
1076
|
static createAdd2Scaled(vectorA, scaleA, vectorB, scaleB, result) {
|
|
1070
1077
|
return Vector3d.create(vectorA.x * scaleA + vectorB.x * scaleB, vectorA.y * scaleA + vectorB.y * scaleB, vectorA.z * scaleA + vectorB.z * scaleB, result);
|
|
1071
1078
|
}
|
|
1072
|
-
/**
|
|
1073
|
-
*
|
|
1079
|
+
/**
|
|
1080
|
+
* Return the (strongly typed Vector3d) `thisVector3d + vectorA * scalarA + vectorB * scalarB`
|
|
1081
|
+
* with all components presented as numbers
|
|
1082
|
+
*/
|
|
1074
1083
|
static createAdd2ScaledXYZ(ax, ay, az, scaleA, bx, by, bz, scaleB, result) {
|
|
1075
1084
|
return Vector3d.create(ax * scaleA + bx * scaleB, ay * scaleA + by * scaleB, az * scaleA + bz * scaleB, result);
|
|
1076
1085
|
}
|
|
@@ -1097,7 +1106,8 @@ export class Vector3d extends XYZ {
|
|
|
1097
1106
|
return undefined;
|
|
1098
1107
|
return this.scale(length / mag, result);
|
|
1099
1108
|
}
|
|
1100
|
-
/**
|
|
1109
|
+
/**
|
|
1110
|
+
* Compute the cross product of this vector with `vectorB`. Immediately pass it to `normalize`.
|
|
1101
1111
|
* @param vectorB second vector for cross product.
|
|
1102
1112
|
* @returns see `Vector3d` method `normalize()` for error condition.
|
|
1103
1113
|
*/
|
|
@@ -1184,7 +1194,8 @@ export class Vector3d extends XYZ {
|
|
|
1184
1194
|
crossProductMagnitude(vectorB) {
|
|
1185
1195
|
return Math.sqrt(this.crossProductMagnitudeSquared(vectorB));
|
|
1186
1196
|
}
|
|
1187
|
-
/**
|
|
1197
|
+
/**
|
|
1198
|
+
* Return the dot product of this vector with vectorB.
|
|
1188
1199
|
* @param vectorB second vector of cross product
|
|
1189
1200
|
* @returns the dot product of this instance with vectorB
|
|
1190
1201
|
*/
|
|
@@ -1240,7 +1251,8 @@ export class Vector3d extends XYZ {
|
|
|
1240
1251
|
return this.x * (pointB.x - pointA.x)
|
|
1241
1252
|
+ this.y * (pointB.y - pointA.y);
|
|
1242
1253
|
}
|
|
1243
|
-
/**
|
|
1254
|
+
/**
|
|
1255
|
+
* Dot product with vector from pointA to pointB, with pointB given as (weighted) wx,wy,wz,w
|
|
1244
1256
|
* * We need to unweight pointB (which is a homogeneous point) to be able to participate in the
|
|
1245
1257
|
* vector dot product
|
|
1246
1258
|
* * if the weight is near zero metric, the return is zero.
|
|
@@ -1284,7 +1296,7 @@ export class Vector3d extends XYZ {
|
|
|
1284
1296
|
return Vector3d.createCrossProduct(this.x, this.y, this.z, vectorB.x, vectorB.y, vectorB.z, result);
|
|
1285
1297
|
}
|
|
1286
1298
|
/**
|
|
1287
|
-
*
|
|
1299
|
+
* Return cross product of `this` with the vector `(x, y, z)`
|
|
1288
1300
|
* @param x x component of second vector
|
|
1289
1301
|
* @param y y component of second vector
|
|
1290
1302
|
* @param z z component of second vector
|
|
@@ -1294,12 +1306,12 @@ export class Vector3d extends XYZ {
|
|
|
1294
1306
|
return Vector3d.createCrossProduct(this.x, this.y, this.z, x, y, z, result);
|
|
1295
1307
|
}
|
|
1296
1308
|
/**
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1309
|
+
* Return the angle in radians (not as strongly typed Angle) from this vector to vectorB.
|
|
1310
|
+
* * The returned angle is between 0 and `Math.PI`.
|
|
1311
|
+
* * The returned angle is measured in the plane containing the two vectors.
|
|
1312
|
+
* * Use `planarRadiansTo` and `signedRadiansTo` to return an angle measured in a specific plane.
|
|
1313
|
+
* @param vectorB target vector.
|
|
1314
|
+
*/
|
|
1303
1315
|
radiansTo(vectorB) {
|
|
1304
1316
|
// ||axb|| = ||a|| ||b|| |sin(t)| and a.b = ||a|| ||b|| cos(t) ==>
|
|
1305
1317
|
// ||axb|| / a.b = sin(t)/cos(t) = tan(t) ==> t = arctan(||axb|| / a.b).
|
|
@@ -1335,16 +1347,16 @@ export class Vector3d extends XYZ {
|
|
|
1335
1347
|
return Angle.createAtan2(this.crossProductXY(vectorB), this.dotProductXY(vectorB));
|
|
1336
1348
|
}
|
|
1337
1349
|
/**
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1350
|
+
* Return the angle in radians (not as strongly-typed Angle) from this vector to vectorB, measured
|
|
1351
|
+
* in their containing plane whose normal lies in the same half-space as vectorW.
|
|
1352
|
+
* * The returned angle is between `-Math.PI` and `Math.PI`.
|
|
1353
|
+
* * If the cross product of this vector and vectorB lies on the same side of the plane as vectorW,
|
|
1354
|
+
* this function returns `radiansTo(vectorB)`; otherwise, it returns `-radiansTo(vectorB)`.
|
|
1355
|
+
* * `vectorW` does not have to be perpendicular to the plane.
|
|
1356
|
+
* * Use `planarRadiansTo` to measure the angle between vectors that are projected to another plane.
|
|
1357
|
+
* @param vectorB target vector.
|
|
1358
|
+
* @param vectorW determines the side of the plane in which the returned angle is measured
|
|
1359
|
+
*/
|
|
1348
1360
|
signedRadiansTo(vectorB, vectorW) {
|
|
1349
1361
|
const p = this.crossProduct(vectorB);
|
|
1350
1362
|
const theta = Math.atan2(p.magnitude(), this.dotProduct(vectorB));
|
|
@@ -1353,7 +1365,8 @@ export class Vector3d extends XYZ {
|
|
|
1353
1365
|
else
|
|
1354
1366
|
return theta;
|
|
1355
1367
|
}
|
|
1356
|
-
/**
|
|
1368
|
+
/**
|
|
1369
|
+
* Return the (strongly-typed) angle from this vector to vectorB, measured
|
|
1357
1370
|
* in their containing plane whose normal lies in the same half-space as vectorW.
|
|
1358
1371
|
* * The returned angle is between -180 and 180 degrees.
|
|
1359
1372
|
* * If the cross product of this vector and vectorB lies on the same side of the plane as vectorW,
|
|
@@ -1396,15 +1409,19 @@ export class Vector3d extends XYZ {
|
|
|
1396
1409
|
planarAngleTo(vectorB, planeNormal) {
|
|
1397
1410
|
return Angle.createRadians(this.planarRadiansTo(vectorB, planeNormal));
|
|
1398
1411
|
}
|
|
1399
|
-
/**
|
|
1400
|
-
|
|
1412
|
+
/**
|
|
1413
|
+
* Return the smallest angle (in radians) from the (bidirectional) line containing `this`
|
|
1414
|
+
* to the (bidirectional) line containing `vectorB`
|
|
1415
|
+
*/
|
|
1401
1416
|
smallerUnorientedRadiansTo(vectorB) {
|
|
1402
1417
|
const c = this.dotProduct(vectorB);
|
|
1403
1418
|
const s = this.crossProductMagnitude(vectorB);
|
|
1404
1419
|
return Math.atan2(Math.abs(s), Math.abs(c));
|
|
1405
1420
|
}
|
|
1406
|
-
/**
|
|
1407
|
-
*
|
|
1421
|
+
/**
|
|
1422
|
+
* Return the smallest (strongly typed) angle from the (bidirectional) line containing `this`
|
|
1423
|
+
* to the (bidirectional) line containing `vectorB`
|
|
1424
|
+
*/
|
|
1408
1425
|
smallerUnorientedAngleTo(vectorB) {
|
|
1409
1426
|
return Angle.createRadians(this.smallerUnorientedRadiansTo(vectorB));
|
|
1410
1427
|
}
|