@itwin/core-geometry 3.6.0-dev.7 → 4.0.0-dev.1
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/CHANGELOG.md +28 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/Geometry.d.ts +25 -14
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +25 -14
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +10 -6
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +10 -19
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/geometry3d/Angle.d.ts +1 -0
- package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Angle.js +1 -0
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -0
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +1 -0
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +221 -159
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +365 -249
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts +71 -14
- package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
- package/lib/cjs/geometry3d/OrderedRotationAngles.js +204 -114
- package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts +1 -0
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.js +1 -0
- package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +4 -3
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +6 -5
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts +49 -25
- package/lib/cjs/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js +146 -50
- package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +4 -4
- package/lib/cjs/polyface/PolyfaceBuilder.js +4 -4
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +28 -0
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +79 -0
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/Geometry.d.ts +25 -14
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +25 -14
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +10 -6
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +10 -19
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/geometry3d/Angle.d.ts +1 -0
- package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
- package/lib/esm/geometry3d/Angle.js +1 -0
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +1 -0
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +1 -0
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +221 -159
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +365 -249
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/OrderedRotationAngles.d.ts +71 -14
- package/lib/esm/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
- package/lib/esm/geometry3d/OrderedRotationAngles.js +205 -115
- package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.d.ts +1 -0
- package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.js +1 -0
- package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +4 -3
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +6 -5
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.d.ts +49 -25
- package/lib/esm/geometry3d/YawPitchRollAngles.d.ts.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js +146 -50
- package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +4 -4
- package/lib/esm/polyface/PolyfaceBuilder.js +4 -4
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +28 -0
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +79 -0
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/package.json +4 -4
|
@@ -5,19 +5,28 @@ import { AxisOrder } from "../Geometry";
|
|
|
5
5
|
import { Angle } from "./Angle";
|
|
6
6
|
import { Matrix3d } from "./Matrix3d";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* * This class accommodates application-specific interpretation of "
|
|
8
|
+
* represents a non-trivial rotation using three simple axis rotation angles and an order in which to apply them.
|
|
9
|
+
* * This class accommodates application-specific interpretation of "multiplying 3 rotation matrices" with regard to
|
|
10
10
|
* * Whether a "vector" is a "row" or a "column"
|
|
11
|
-
* * The order in which the X,Y,
|
|
11
|
+
* * The order in which the X,Y,Z rotations are applied.
|
|
12
|
+
* * This class bakes in angle rotation directions via create functions (i.e., createRadians, createDegrees, and
|
|
13
|
+
* createAngles) so you can define each of the 3 rotations to be clockwise or counterclockwise. The default
|
|
14
|
+
* rotation is counterclockwise.
|
|
12
15
|
* * Within the imodel geometry library, the preferred rotation order is encapsulated in `YawPitchRollAngles`.
|
|
13
16
|
* @alpha
|
|
14
17
|
*/
|
|
15
18
|
export declare class OrderedRotationAngles {
|
|
19
|
+
/** rotation around x */
|
|
16
20
|
private _x;
|
|
21
|
+
/** rotation around y */
|
|
17
22
|
private _y;
|
|
23
|
+
/** rotation around z */
|
|
18
24
|
private _z;
|
|
25
|
+
/** rotation order. For example XYZ means to rotate around x axis first, then y axis, and finally Z axis */
|
|
19
26
|
private _order;
|
|
27
|
+
/** treat vectors as matrix columns */
|
|
20
28
|
private static _sTreatVectorsAsColumns;
|
|
29
|
+
/** constructor */
|
|
21
30
|
private constructor();
|
|
22
31
|
/** (Property accessor) Return the `AxisOrder` controlling matrix multiplication order. */
|
|
23
32
|
get order(): AxisOrder;
|
|
@@ -39,23 +48,71 @@ export declare class OrderedRotationAngles {
|
|
|
39
48
|
get zDegrees(): number;
|
|
40
49
|
/** (Property accessor) Return the angle of rotation around z, in radians */
|
|
41
50
|
get zRadians(): number;
|
|
42
|
-
/**
|
|
51
|
+
/** the flag controlling whether vectors are treated as rows or as columns */
|
|
43
52
|
static get treatVectorsAsColumns(): boolean;
|
|
44
53
|
static set treatVectorsAsColumns(value: boolean);
|
|
45
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Create an OrderedRotationAngles from three angles (in radians), an ordering in which to apply them when
|
|
56
|
+
* rotating, and a flag triple controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
57
|
+
* @param xRadians rotation around x
|
|
58
|
+
* @param yRadians rotation around y
|
|
59
|
+
* @param zRadians rotation around z
|
|
60
|
+
* @param order left to right order of axis names identifies the order that rotations are applied.
|
|
61
|
+
* For example XYZ means to rotate around x axis first, then y axis, and finally Z axis.
|
|
62
|
+
* * Note that rotation order is reverse of rotation matrix multiplication so for XYZ the rotation
|
|
63
|
+
* matrix multiplication would be zRot*yRot*xRot
|
|
64
|
+
* @param xyzRotationIsClockwise the flags controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
65
|
+
* rotation direction of x,y,z: true ---> clockwise - false ---> counterclockwise.
|
|
66
|
+
* * if xyzRotationIsClockwise is undefined it's set to [false, false, false].
|
|
67
|
+
* @param result caller-allocated OrderedRotationAngles
|
|
68
|
+
*/
|
|
69
|
+
static createRadians(xRadians: number, yRadians: number, zRadians: number, order: AxisOrder, xyzRotationIsClockwise?: [boolean, boolean, boolean], result?: OrderedRotationAngles): OrderedRotationAngles;
|
|
70
|
+
/**
|
|
71
|
+
* Create an OrderedRotationAngles from three angles (in degrees) and an ordering in which to apply
|
|
72
|
+
* them when rotating.
|
|
73
|
+
* @param xDegrees rotation around x
|
|
74
|
+
* @param yDegrees rotation around y
|
|
75
|
+
* @param zDegrees rotation around z
|
|
76
|
+
* @param order left to right order of axis names identifies the order that rotations are applied.
|
|
77
|
+
* For example XYZ means to rotate around x axis first, then y axis, and finally Z axis.
|
|
78
|
+
* * Note that rotation order is reverse of rotation matrix multiplication so for XYZ the rotation
|
|
79
|
+
* matrix multiplication would be zRot*yRot*xRot
|
|
80
|
+
* @param xyzRotationIsClockwise the flags controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
81
|
+
* rotation direction of x,y,z: true ---> clockwise - false ---> counterclockwise.
|
|
82
|
+
* * if xyzRotationIsClockwise is undefined it's set to [false, false, false].
|
|
83
|
+
* @param result caller-allocated OrderedRotationAngles
|
|
84
|
+
*/
|
|
85
|
+
static createDegrees(xDegrees: number, yDegrees: number, zDegrees: number, order: AxisOrder, xyzRotationIsClockwise?: [boolean, boolean, boolean], result?: OrderedRotationAngles): OrderedRotationAngles;
|
|
86
|
+
/**
|
|
87
|
+
* Create an OrderedRotationAngles from three angles, an ordering in which to apply them when rotating,
|
|
88
|
+
* and a flag triple controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
46
89
|
* @param xRotation rotation around x
|
|
47
90
|
* @param yRotation rotation around y
|
|
48
91
|
* @param zRotation rotation around z
|
|
49
|
-
* @param
|
|
92
|
+
* @param order left to right order of axis names identifies the order that rotations are applied
|
|
93
|
+
* For example XYZ means to rotate around x axis first, then y axis, and finally Z axis.
|
|
94
|
+
* * Note that rotation order is reverse of rotation matrix multiplication so for XYZ the rotation
|
|
95
|
+
* matrix multiplication would be zRot*yRot*xRot
|
|
96
|
+
* @param xyzRotationIsClockwise the flags controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
97
|
+
* rotation direction of x,y,z: true ---> clockwise - false ---> counterclockwise.
|
|
98
|
+
* * if xyzRotationIsClockwise is undefined it's set to [false, false, false].
|
|
99
|
+
* @param result caller-allocated OrderedRotationAngles
|
|
50
100
|
*/
|
|
51
|
-
static createAngles(xRotation: Angle, yRotation: Angle, zRotation: Angle, order: AxisOrder, result?: OrderedRotationAngles): OrderedRotationAngles;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
101
|
+
static createAngles(xRotation: Angle, yRotation: Angle, zRotation: Angle, order: AxisOrder, xyzRotationIsClockwise?: [boolean, boolean, boolean], result?: OrderedRotationAngles): OrderedRotationAngles;
|
|
102
|
+
/**
|
|
103
|
+
* Create an OrderedRotationAngles from a 3x3 rotational matrix, given the ordering of axis rotations
|
|
104
|
+
* that the matrix derives from.
|
|
105
|
+
* * This function creates an OrderedRotationAngles with default angle rotation directions, i.e.,
|
|
106
|
+
* it assumes all x, y, and z rotations are counterclockwise.
|
|
107
|
+
* * In the failure case the method's return value is `undefined`.
|
|
108
|
+
* * In the failure case, if the optional result was supplied, that result will nonetheless be filled with
|
|
109
|
+
* a set of angles.
|
|
110
|
+
* */
|
|
111
|
+
static createFromMatrix3d(matrix: Matrix3d, order: AxisOrder, result?: OrderedRotationAngles): OrderedRotationAngles | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Create a 3x3 rotational matrix from this OrderedRotationAngles.
|
|
114
|
+
** math details can be found at docs/learning/geometry/Angle.md
|
|
115
|
+
**/
|
|
59
116
|
toMatrix3d(result?: Matrix3d): Matrix3d;
|
|
60
117
|
}
|
|
61
118
|
//# sourceMappingURL=OrderedRotationAngles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedRotationAngles.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/OrderedRotationAngles.ts"],"names":[],"mappings":"AAKA;;GAEG;
|
|
1
|
+
{"version":3,"file":"OrderedRotationAngles.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/OrderedRotationAngles.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC;;;;;;;;;;GAUG;AACH,qBAAa,qBAAqB;IAChC,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAQ;IAClB,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAQ;IAClB,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAQ;IAClB,2GAA2G;IAC3G,OAAO,CAAC,MAAM,CAAY;IAC1B,sCAAsC;IACtC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAkB;IACxD,kBAAkB;IAClB,OAAO;IAMP,0FAA0F;IAC1F,IAAW,KAAK,IAAI,SAAS,CAE5B;IACD,gFAAgF;IAChF,IAAW,MAAM,IAAI,KAAK,CAEzB;IACD,gFAAgF;IAChF,IAAW,MAAM,IAAI,KAAK,CAEzB;IACD,gFAAgF;IAChF,IAAW,MAAM,IAAI,KAAK,CAEzB;IACD,4EAA4E;IAC5E,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,4EAA4E;IAC5E,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,4EAA4E;IAC5E,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,4EAA4E;IAC5E,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,4EAA4E;IAC5E,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,4EAA4E;IAC5E,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,6EAA6E;IAC7E,WAAkB,qBAAqB,IAAI,OAAO,CAEjD;IACD,WAAkB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAErD;IACD;;;;;;;;;;;;;;OAcG;WACW,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAChG,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,qBAAqB,GAAG,qBAAqB;IAqB9G;;;;;;;;;;;;;;OAcG;WACW,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAChG,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,qBAAqB,GAAG,qBAAqB;IAU9G;;;;;;;;;;;;;;OAcG;WACW,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAC/F,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,qBAAqB,GAAG,qBAAqB;IAU9G;;;;;;;;SAQK;WACS,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,qBAAqB,GACjG,qBAAqB,GAAG,SAAS;IAoHnC;;;QAGI;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ;CA2D/C"}
|
|
@@ -5,18 +5,23 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module CartesianGeometry
|
|
7
7
|
*/
|
|
8
|
-
import { AxisOrder } from "../Geometry";
|
|
8
|
+
import { AxisOrder, Geometry } from "../Geometry";
|
|
9
9
|
import { Angle } from "./Angle";
|
|
10
10
|
import { Matrix3d } from "./Matrix3d";
|
|
11
|
+
/* cspell:word cxcz, cxsz, cxcy, cxsy, sxcz, sxsz, sxcy, sxsy, cycz, cysz, sycz, sysz */
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
* * This class accommodates application-specific interpretation of "
|
|
13
|
+
* represents a non-trivial rotation using three simple axis rotation angles and an order in which to apply them.
|
|
14
|
+
* * This class accommodates application-specific interpretation of "multiplying 3 rotation matrices" with regard to
|
|
14
15
|
* * Whether a "vector" is a "row" or a "column"
|
|
15
|
-
* * The order in which the X,Y,
|
|
16
|
+
* * The order in which the X,Y,Z rotations are applied.
|
|
17
|
+
* * This class bakes in angle rotation directions via create functions (i.e., createRadians, createDegrees, and
|
|
18
|
+
* createAngles) so you can define each of the 3 rotations to be clockwise or counterclockwise. The default
|
|
19
|
+
* rotation is counterclockwise.
|
|
16
20
|
* * Within the imodel geometry library, the preferred rotation order is encapsulated in `YawPitchRollAngles`.
|
|
17
21
|
* @alpha
|
|
18
22
|
*/
|
|
19
23
|
export class OrderedRotationAngles {
|
|
24
|
+
/** constructor */
|
|
20
25
|
constructor(x, y, z, axisOrder) {
|
|
21
26
|
this._x = x;
|
|
22
27
|
this._y = y;
|
|
@@ -24,149 +29,224 @@ export class OrderedRotationAngles {
|
|
|
24
29
|
this._order = axisOrder;
|
|
25
30
|
}
|
|
26
31
|
/** (Property accessor) Return the `AxisOrder` controlling matrix multiplication order. */
|
|
27
|
-
get order() {
|
|
32
|
+
get order() {
|
|
33
|
+
return this._order;
|
|
34
|
+
}
|
|
28
35
|
/** (Property accessor) Return the strongly typed angle of rotation around x. */
|
|
29
|
-
get xAngle() {
|
|
36
|
+
get xAngle() {
|
|
37
|
+
return this._x.clone();
|
|
38
|
+
}
|
|
30
39
|
/** (Property accessor) Return the strongly typed angle of rotation around y. */
|
|
31
|
-
get yAngle() {
|
|
40
|
+
get yAngle() {
|
|
41
|
+
return this._y.clone();
|
|
42
|
+
}
|
|
32
43
|
/** (Property accessor) Return the strongly typed angle of rotation around z. */
|
|
33
|
-
get zAngle() {
|
|
44
|
+
get zAngle() {
|
|
45
|
+
return this._z.clone();
|
|
46
|
+
}
|
|
34
47
|
/** (Property accessor) Return the angle of rotation around x, in degrees */
|
|
35
|
-
get xDegrees() {
|
|
48
|
+
get xDegrees() {
|
|
49
|
+
return this._x.degrees;
|
|
50
|
+
}
|
|
36
51
|
/** (Property accessor) Return the angle of rotation around y, in degrees */
|
|
37
|
-
get xRadians() {
|
|
52
|
+
get xRadians() {
|
|
53
|
+
return this._x.radians;
|
|
54
|
+
}
|
|
38
55
|
/** (Property accessor) Return the angle of rotation around z, in degrees */
|
|
39
|
-
get yDegrees() {
|
|
56
|
+
get yDegrees() {
|
|
57
|
+
return this._y.degrees;
|
|
58
|
+
}
|
|
40
59
|
/** (Property accessor) Return the angle of rotation around x, in radians */
|
|
41
|
-
get yRadians() {
|
|
60
|
+
get yRadians() {
|
|
61
|
+
return this._y.radians;
|
|
62
|
+
}
|
|
42
63
|
/** (Property accessor) Return the angle of rotation around y, in radians */
|
|
43
|
-
get zDegrees() {
|
|
64
|
+
get zDegrees() {
|
|
65
|
+
return this._z.degrees;
|
|
66
|
+
}
|
|
44
67
|
/** (Property accessor) Return the angle of rotation around z, in radians */
|
|
45
|
-
get zRadians() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
get zRadians() {
|
|
69
|
+
return this._z.radians;
|
|
70
|
+
}
|
|
71
|
+
/** the flag controlling whether vectors are treated as rows or as columns */
|
|
72
|
+
static get treatVectorsAsColumns() {
|
|
73
|
+
return OrderedRotationAngles._sTreatVectorsAsColumns;
|
|
74
|
+
}
|
|
75
|
+
static set treatVectorsAsColumns(value) {
|
|
76
|
+
OrderedRotationAngles._sTreatVectorsAsColumns = value;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create an OrderedRotationAngles from three angles (in radians), an ordering in which to apply them when
|
|
80
|
+
* rotating, and a flag triple controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
81
|
+
* @param xRadians rotation around x
|
|
82
|
+
* @param yRadians rotation around y
|
|
83
|
+
* @param zRadians rotation around z
|
|
84
|
+
* @param order left to right order of axis names identifies the order that rotations are applied.
|
|
85
|
+
* For example XYZ means to rotate around x axis first, then y axis, and finally Z axis.
|
|
86
|
+
* * Note that rotation order is reverse of rotation matrix multiplication so for XYZ the rotation
|
|
87
|
+
* matrix multiplication would be zRot*yRot*xRot
|
|
88
|
+
* @param xyzRotationIsClockwise the flags controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
89
|
+
* rotation direction of x,y,z: true ---> clockwise - false ---> counterclockwise.
|
|
90
|
+
* * if xyzRotationIsClockwise is undefined it's set to [false, false, false].
|
|
91
|
+
* @param result caller-allocated OrderedRotationAngles
|
|
54
92
|
*/
|
|
55
|
-
static
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
result._y.setFrom(yRotation);
|
|
59
|
-
result._z.setFrom(zRotation);
|
|
60
|
-
result._order = order;
|
|
61
|
-
return result;
|
|
93
|
+
static createRadians(xRadians, yRadians, zRadians, order, xyzRotationIsClockwise, result) {
|
|
94
|
+
if (!xyzRotationIsClockwise) {
|
|
95
|
+
xyzRotationIsClockwise = [false, false, false];
|
|
62
96
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
static createRadians(xRadians, yRadians, zRadians, order, result) {
|
|
97
|
+
const xRadian = xyzRotationIsClockwise[0] ? -xRadians : xRadians;
|
|
98
|
+
const yRadian = xyzRotationIsClockwise[1] ? -yRadians : yRadians;
|
|
99
|
+
const zRadian = xyzRotationIsClockwise[2] ? -zRadians : zRadians;
|
|
67
100
|
if (result) {
|
|
68
|
-
result._x.setRadians(
|
|
69
|
-
result._y.setRadians(
|
|
70
|
-
result._z.setRadians(
|
|
101
|
+
result._x.setRadians(xRadian);
|
|
102
|
+
result._y.setRadians(yRadian);
|
|
103
|
+
result._z.setRadians(zRadian);
|
|
71
104
|
result._order = order;
|
|
72
105
|
return result;
|
|
73
106
|
}
|
|
74
|
-
return new OrderedRotationAngles(Angle.createRadians(
|
|
107
|
+
return new OrderedRotationAngles(Angle.createRadians(xRadian), Angle.createRadians(yRadian), Angle.createRadians(zRadian), order);
|
|
75
108
|
}
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Create an OrderedRotationAngles from three angles (in degrees) and an ordering in which to apply
|
|
111
|
+
* them when rotating.
|
|
112
|
+
* @param xDegrees rotation around x
|
|
113
|
+
* @param yDegrees rotation around y
|
|
114
|
+
* @param zDegrees rotation around z
|
|
115
|
+
* @param order left to right order of axis names identifies the order that rotations are applied.
|
|
116
|
+
* For example XYZ means to rotate around x axis first, then y axis, and finally Z axis.
|
|
117
|
+
* * Note that rotation order is reverse of rotation matrix multiplication so for XYZ the rotation
|
|
118
|
+
* matrix multiplication would be zRot*yRot*xRot
|
|
119
|
+
* @param xyzRotationIsClockwise the flags controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
120
|
+
* rotation direction of x,y,z: true ---> clockwise - false ---> counterclockwise.
|
|
121
|
+
* * if xyzRotationIsClockwise is undefined it's set to [false, false, false].
|
|
122
|
+
* @param result caller-allocated OrderedRotationAngles
|
|
123
|
+
*/
|
|
124
|
+
static createDegrees(xDegrees, yDegrees, zDegrees, order, xyzRotationIsClockwise, result) {
|
|
125
|
+
return OrderedRotationAngles.createRadians(Angle.degreesToRadians(xDegrees), Angle.degreesToRadians(yDegrees), Angle.degreesToRadians(zDegrees), order, xyzRotationIsClockwise, result);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create an OrderedRotationAngles from three angles, an ordering in which to apply them when rotating,
|
|
129
|
+
* and a flag triple controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
130
|
+
* @param xRotation rotation around x
|
|
131
|
+
* @param yRotation rotation around y
|
|
132
|
+
* @param zRotation rotation around z
|
|
133
|
+
* @param order left to right order of axis names identifies the order that rotations are applied
|
|
134
|
+
* For example XYZ means to rotate around x axis first, then y axis, and finally Z axis.
|
|
135
|
+
* * Note that rotation order is reverse of rotation matrix multiplication so for XYZ the rotation
|
|
136
|
+
* matrix multiplication would be zRot*yRot*xRot
|
|
137
|
+
* @param xyzRotationIsClockwise the flags controlling whether direction of x,y,z is clockwise or counterclockwise.
|
|
138
|
+
* rotation direction of x,y,z: true ---> clockwise - false ---> counterclockwise.
|
|
139
|
+
* * if xyzRotationIsClockwise is undefined it's set to [false, false, false].
|
|
140
|
+
* @param result caller-allocated OrderedRotationAngles
|
|
141
|
+
*/
|
|
142
|
+
static createAngles(xRotation, yRotation, zRotation, order, xyzRotationIsClockwise, result) {
|
|
143
|
+
return OrderedRotationAngles.createRadians(xRotation.radians, yRotation.radians, zRotation.radians, order, xyzRotationIsClockwise, result);
|
|
86
144
|
}
|
|
87
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* Create an OrderedRotationAngles from a 3x3 rotational matrix, given the ordering of axis rotations
|
|
147
|
+
* that the matrix derives from.
|
|
148
|
+
* * This function creates an OrderedRotationAngles with default angle rotation directions, i.e.,
|
|
149
|
+
* it assumes all x, y, and z rotations are counterclockwise.
|
|
150
|
+
* * In the failure case the method's return value is `undefined`.
|
|
151
|
+
* * In the failure case, if the optional result was supplied, that result will nonetheless be filled with
|
|
152
|
+
* a set of angles.
|
|
153
|
+
* */
|
|
88
154
|
static createFromMatrix3d(matrix, order, result) {
|
|
89
|
-
|
|
90
|
-
let
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
155
|
+
// treat vector as columns
|
|
156
|
+
let m11 = matrix.coffs[0], m12 = matrix.coffs[1], m13 = matrix.coffs[2];
|
|
157
|
+
let m21 = matrix.coffs[3], m22 = matrix.coffs[4], m23 = matrix.coffs[5];
|
|
158
|
+
let m31 = matrix.coffs[6], m32 = matrix.coffs[7], m33 = matrix.coffs[8];
|
|
159
|
+
// treat vector as rows
|
|
160
|
+
if (!OrderedRotationAngles.treatVectorsAsColumns) {
|
|
161
|
+
m11 = matrix.coffs[0], m12 = matrix.coffs[3], m13 = matrix.coffs[6];
|
|
162
|
+
m21 = matrix.coffs[1], m22 = matrix.coffs[4], m23 = matrix.coffs[7];
|
|
163
|
+
m31 = matrix.coffs[2], m32 = matrix.coffs[5], m33 = matrix.coffs[8];
|
|
97
164
|
}
|
|
98
165
|
let xRad;
|
|
99
166
|
let yRad;
|
|
100
167
|
let zRad;
|
|
101
168
|
switch (order) {
|
|
102
169
|
case AxisOrder.XYZ: {
|
|
103
|
-
yRad = Math.asin(Math.max(-1, Math.min(1,
|
|
104
|
-
if (Math.abs(
|
|
105
|
-
xRad = Math.atan2(
|
|
106
|
-
zRad = Math.atan2(
|
|
170
|
+
yRad = Math.asin(Math.max(-1, Math.min(1, -m31))); // limit asin domain to [-1,1]
|
|
171
|
+
if (Math.abs(m31) < 0.99999) {
|
|
172
|
+
xRad = Math.atan2(m32, m33);
|
|
173
|
+
zRad = Math.atan2(m21, m11);
|
|
107
174
|
}
|
|
108
175
|
else {
|
|
109
|
-
|
|
176
|
+
/**
|
|
177
|
+
* If Math.abs(m31) = 1 then yRad = +-90 degrees and therefore, we have a gimbal lock.
|
|
178
|
+
* This means xRad and zRad can be anything as long as their sum xRad + zRad is constant.
|
|
179
|
+
* so we can pick zRad = 0 and calculate xRad (or pick xRad = 0 and calculate zRad).
|
|
180
|
+
* Therefore, rotation matrix becomes
|
|
181
|
+
* Matrix3d.createRowValues(
|
|
182
|
+
* 0, +-sx, +-cx,
|
|
183
|
+
* 0, cx, -sx,
|
|
184
|
+
* -+1, 0, 0
|
|
185
|
+
* );
|
|
186
|
+
* Math details can be found
|
|
187
|
+
* https://en.wikipedia.org/wiki/Gimbal_lock#Loss_of_a_degree_of_freedom_with_Euler_angles
|
|
188
|
+
*/
|
|
189
|
+
xRad = Math.atan2(-m23, m22);
|
|
110
190
|
zRad = 0;
|
|
111
191
|
}
|
|
112
192
|
break;
|
|
113
193
|
}
|
|
114
194
|
case AxisOrder.YXZ: {
|
|
115
|
-
xRad = Math.asin(
|
|
116
|
-
if (Math.abs(
|
|
117
|
-
yRad = Math.atan2(
|
|
118
|
-
zRad = Math.atan2(
|
|
195
|
+
xRad = Math.asin(Math.max(-1, Math.min(1, m32))); // limit asin domain to [-1,1]
|
|
196
|
+
if (Math.abs(m32) < 0.99999) {
|
|
197
|
+
yRad = Math.atan2(-m31, m33);
|
|
198
|
+
zRad = Math.atan2(-m12, m22);
|
|
119
199
|
}
|
|
120
200
|
else {
|
|
121
|
-
yRad = Math.atan2(
|
|
201
|
+
yRad = Math.atan2(m13, m11);
|
|
122
202
|
zRad = 0;
|
|
123
203
|
}
|
|
124
204
|
break;
|
|
125
205
|
}
|
|
126
206
|
case AxisOrder.ZXY: {
|
|
127
|
-
xRad = Math.asin(Math.max(-1, Math.min(1,
|
|
128
|
-
if (Math.abs(
|
|
129
|
-
yRad = Math.atan2(
|
|
130
|
-
zRad = Math.atan2(
|
|
207
|
+
xRad = Math.asin(Math.max(-1, Math.min(1, -m23))); // limit asin domain to [-1,1]
|
|
208
|
+
if (Math.abs(m23) < 0.99999) {
|
|
209
|
+
yRad = Math.atan2(m13, m33);
|
|
210
|
+
zRad = Math.atan2(m21, m22);
|
|
131
211
|
}
|
|
132
212
|
else {
|
|
133
213
|
yRad = 0;
|
|
134
|
-
zRad = Math.atan2(
|
|
214
|
+
zRad = Math.atan2(-m12, m11);
|
|
135
215
|
}
|
|
136
216
|
break;
|
|
137
217
|
}
|
|
138
218
|
case AxisOrder.ZYX: {
|
|
139
|
-
yRad =
|
|
140
|
-
if (Math.abs(
|
|
141
|
-
xRad = Math.atan2(
|
|
142
|
-
zRad = Math.atan2(
|
|
219
|
+
yRad = Math.asin(Math.max(-1, Math.min(1, m13))); // limit asin domain to [-1,1]
|
|
220
|
+
if (Math.abs(m13) < 0.99999) {
|
|
221
|
+
xRad = Math.atan2(-m23, m33);
|
|
222
|
+
zRad = Math.atan2(-m12, m11);
|
|
143
223
|
}
|
|
144
224
|
else {
|
|
145
225
|
xRad = 0;
|
|
146
|
-
zRad = Math.atan2(
|
|
226
|
+
zRad = Math.atan2(m21, m22);
|
|
147
227
|
}
|
|
148
228
|
break;
|
|
149
229
|
}
|
|
150
230
|
case AxisOrder.YZX: {
|
|
151
|
-
zRad = Math.asin(Math.max(-1, Math.min(1,
|
|
152
|
-
if (Math.abs(
|
|
153
|
-
xRad = Math.atan2(
|
|
154
|
-
yRad = Math.atan2(
|
|
231
|
+
zRad = Math.asin(Math.max(-1, Math.min(1, -m12))); // limit asin domain to [-1,1]
|
|
232
|
+
if (Math.abs(m12) < 0.99999) {
|
|
233
|
+
xRad = Math.atan2(m32, m22);
|
|
234
|
+
yRad = Math.atan2(m13, m11);
|
|
155
235
|
}
|
|
156
236
|
else {
|
|
157
237
|
xRad = 0;
|
|
158
|
-
yRad = Math.atan2(
|
|
238
|
+
yRad = Math.atan2(-m31, m33);
|
|
159
239
|
}
|
|
160
240
|
break;
|
|
161
241
|
}
|
|
162
242
|
case AxisOrder.XZY: {
|
|
163
|
-
zRad =
|
|
164
|
-
if (Math.abs(
|
|
165
|
-
xRad = Math.atan2(
|
|
166
|
-
yRad = Math.atan2(
|
|
243
|
+
zRad = Math.asin(Math.max(-1, Math.min(1, m21))); // limit asin domain to [-1,1]
|
|
244
|
+
if (Math.abs(m21) < 0.99999) {
|
|
245
|
+
xRad = Math.atan2(-m23, m22);
|
|
246
|
+
yRad = Math.atan2(-m31, m11);
|
|
167
247
|
}
|
|
168
248
|
else {
|
|
169
|
-
xRad = Math.atan2(
|
|
249
|
+
xRad = Math.atan2(m32, m33);
|
|
170
250
|
yRad = 0;
|
|
171
251
|
}
|
|
172
252
|
break;
|
|
@@ -175,54 +255,64 @@ export class OrderedRotationAngles {
|
|
|
175
255
|
xRad = yRad = zRad = 0;
|
|
176
256
|
}
|
|
177
257
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
258
|
+
const xyzRotationIsClockwise = [false, false, false];
|
|
259
|
+
const angles = OrderedRotationAngles.createRadians(xRad, yRad, zRad, order, xyzRotationIsClockwise, result);
|
|
260
|
+
// sanity check
|
|
261
|
+
const matrix1 = angles.toMatrix3d();
|
|
262
|
+
/**
|
|
263
|
+
* Below tolerance loosened to allow sanity check to pass for
|
|
264
|
+
*
|
|
265
|
+
* OrderedRotationAngles.createFromMatrix3d(
|
|
266
|
+
* OrderedRotationAngles.createDegrees(0, 89.999, 0.001, AxisOrder.XYZ).toMatrix3d(),
|
|
267
|
+
* AxisOrder.XYZ
|
|
268
|
+
* );
|
|
269
|
+
*
|
|
270
|
+
* with treatVectorsAsColumns = true.
|
|
271
|
+
*/
|
|
272
|
+
return (matrix.maxDiff(matrix1) < 10 * Geometry.smallFraction) ? angles : undefined;
|
|
181
273
|
}
|
|
182
|
-
/**
|
|
274
|
+
/**
|
|
275
|
+
* Create a 3x3 rotational matrix from this OrderedRotationAngles.
|
|
276
|
+
** math details can be found at docs/learning/geometry/Angle.md
|
|
277
|
+
**/
|
|
183
278
|
toMatrix3d(result) {
|
|
184
|
-
const rot = result !== undefined ? result : new Matrix3d();
|
|
279
|
+
const rot = (result !== undefined) ? result : new Matrix3d();
|
|
185
280
|
const axisOrder = this.order;
|
|
186
281
|
const x = this.xAngle, y = this.yAngle, z = this.zAngle;
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
b = -b;
|
|
195
|
-
d = -d;
|
|
196
|
-
f = -f;
|
|
197
|
-
}
|
|
282
|
+
const cx = x.cos(), sx = x.sin();
|
|
283
|
+
const cy = y.cos(), sy = y.sin();
|
|
284
|
+
const cz = z.cos(), sz = z.sin();
|
|
285
|
+
const cxcz = cx * cz, cxsz = cx * sz, cxcy = cx * cy, cxsy = cx * sy;
|
|
286
|
+
const sxcz = sx * cz, sxsz = sx * sz, sxcy = sx * cy, sxsy = sx * sy;
|
|
287
|
+
const cycz = cy * cz, cysz = cy * sz, sycz = sy * cz, sysz = sy * sz;
|
|
288
|
+
// the rotation matrix we build below is created using column-based base rotation matrixes
|
|
198
289
|
if (axisOrder === AxisOrder.XYZ) {
|
|
199
|
-
|
|
200
|
-
rot.setRowValues(c * e, af + be * d, bf - ae * d, -c * f, ae - bf * d, be + af * d, d, -b * c, a * c);
|
|
290
|
+
rot.setRowValues(cy * cz, sxcz * sy - cxsz, cxcz * sy + sxsz, cy * sz, cxcz + sxsz * sy, cxsz * sy - sxcz, -sy, sx * cy, cx * cy);
|
|
201
291
|
}
|
|
202
292
|
else if (axisOrder === AxisOrder.YXZ) {
|
|
203
|
-
|
|
204
|
-
rot.setRowValues(ce + df * b, a * f, cf * b - de, de * b - cf, a * e, df + ce * b, a * d, -b, a * c);
|
|
293
|
+
rot.setRowValues(cycz - sysz * sx, -cx * sz, cysz * sx + sycz, sycz * sx + cysz, cx * cz, sysz - cycz * sx, -cx * sy, sx, cx * cy);
|
|
205
294
|
}
|
|
206
295
|
else if (axisOrder === AxisOrder.ZXY) {
|
|
207
|
-
|
|
208
|
-
rot.setRowValues(ce - df * b, cf + de * b, -a * d, -a * f, a * e, b, de + cf * b, df - ce * b, a * c);
|
|
296
|
+
rot.setRowValues(cycz + sysz * sx, sycz * sx - cysz, cx * sy, cx * sz, cx * cz, -sx, cysz * sx - sycz, cycz * sx + sysz, cx * cy);
|
|
209
297
|
}
|
|
210
298
|
else if (axisOrder === AxisOrder.ZYX) {
|
|
211
|
-
|
|
212
|
-
rot.setRowValues(c * e, c * f, -d, be * d - af, bf * d + ae, b * c, ae * d + bf, af * d - be, a * c);
|
|
299
|
+
rot.setRowValues(cy * cz, -cy * sz, sy, sxcz * sy + cxsz, cxcz - sxsz * sy, -sx * cy, sxsz - cxcz * sy, sxcz + cxsz * sy, cx * cy);
|
|
213
300
|
}
|
|
214
301
|
else if (axisOrder === AxisOrder.YZX) {
|
|
215
|
-
|
|
216
|
-
rot.setRowValues(c * e, f, -d * e, bd - ac * f, a * e, ad * f + bc, bc * f + ad, -b * e, ac - bd * f);
|
|
302
|
+
rot.setRowValues(cy * cz, -sz, sy * cz, sxsy + cxcy * sz, cx * cz, cxsy * sz - sxcy, sxcy * sz - cxsy, sx * cz, cxcy + sxsy * sz);
|
|
217
303
|
}
|
|
218
304
|
else if (axisOrder === AxisOrder.XZY) {
|
|
219
|
-
|
|
220
|
-
|
|
305
|
+
rot.setRowValues(cy * cz, sxsy - cxcy * sz, cxsy + sxcy * sz, sz, cx * cz, -sx * cz, -sy * cz, sxcy + cxsy * sz, cxcy - sxsy * sz);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
rot.setIdentity();
|
|
221
309
|
}
|
|
222
|
-
if
|
|
310
|
+
// if we need row-based rotation matrix, we transpose the rotation matrix
|
|
311
|
+
if (!OrderedRotationAngles.treatVectorsAsColumns)
|
|
223
312
|
rot.transposeInPlace();
|
|
224
313
|
return rot;
|
|
225
314
|
}
|
|
226
315
|
}
|
|
316
|
+
/** treat vectors as matrix columns */
|
|
227
317
|
OrderedRotationAngles._sTreatVectorsAsColumns = false;
|
|
228
318
|
//# sourceMappingURL=OrderedRotationAngles.js.map
|