@itwin/core-geometry 5.1.0-dev.3 → 5.1.0-dev.4
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/RegionMomentsXY.d.ts +14 -21
- package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/cjs/curve/RegionMomentsXY.js +23 -25
- package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +27 -10
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +58 -13
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +3 -3
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +8 -7
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +19 -15
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.d.ts +7 -7
- package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.js +9 -9
- package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
- package/lib/cjs/geometry4d/MomentData.d.ts +32 -34
- package/lib/cjs/geometry4d/MomentData.d.ts.map +1 -1
- package/lib/cjs/geometry4d/MomentData.js +56 -57
- package/lib/cjs/geometry4d/MomentData.js.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.d.ts +14 -21
- package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.js +23 -25
- package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +27 -10
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +59 -14
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +3 -3
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +8 -7
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +19 -15
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.d.ts +7 -7
- package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.js +9 -9
- package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
- package/lib/esm/geometry4d/MomentData.d.ts +32 -34
- package/lib/esm/geometry4d/MomentData.d.ts.map +1 -1
- package/lib/esm/geometry4d/MomentData.js +56 -57
- package/lib/esm/geometry4d/MomentData.js.map +1 -1
- package/package.json +3 -3
|
@@ -25,8 +25,8 @@ import { Point4d } from "./Point4d";
|
|
|
25
25
|
* * e.g. entry 03 is summed x.
|
|
26
26
|
* * In this level:
|
|
27
27
|
* * the `absoluteQuantity` member is undefined.
|
|
28
|
-
* * the `localToWorldMap` and `radiiOfGyration` are created
|
|
29
|
-
* * Second level: after a call to inertiaProductsToPrincipalAxes
|
|
28
|
+
* * the `localToWorldMap` and `radiiOfGyration` are created but have undefined contents.
|
|
29
|
+
* * Second level: after a call to `inertiaProductsToPrincipalAxes`, the `localToWorldMap`, `absoluteQuantity` and
|
|
30
30
|
* `radiiOfGyration` are filled in.
|
|
31
31
|
* @public
|
|
32
32
|
*/
|
|
@@ -46,18 +46,35 @@ export class MomentData {
|
|
|
46
46
|
* * This set up with its inverse already constructed.
|
|
47
47
|
*/
|
|
48
48
|
localToWorldMap;
|
|
49
|
+
/** Radii of gyration (square roots of principal second moments). */
|
|
50
|
+
radiusOfGyration;
|
|
51
|
+
/**
|
|
52
|
+
* Principal quantity (e.g. length, area, or volume). This is undefined in raw moments, and becomes defined by
|
|
53
|
+
* inertiaProductsToPrincipalAxes.
|
|
54
|
+
*/
|
|
55
|
+
absoluteQuantity;
|
|
49
56
|
// private variables
|
|
50
57
|
static _vectorA;
|
|
51
58
|
static _vectorB;
|
|
52
59
|
static _vectorC;
|
|
53
60
|
_point0 = Point3d.create();
|
|
54
61
|
_point1 = Point3d.create();
|
|
62
|
+
/** Constructor. */
|
|
63
|
+
constructor() {
|
|
64
|
+
this.origin = Point3d.createZero();
|
|
65
|
+
this.needOrigin = false;
|
|
66
|
+
this.sums = Matrix4d.createZero();
|
|
67
|
+
this.localToWorldMap = Transform.createIdentity();
|
|
68
|
+
this.radiusOfGyration = Vector3d.create();
|
|
69
|
+
this.absoluteQuantity = 0.1; // so optimizer sees its type
|
|
70
|
+
this.absoluteQuantity = undefined;
|
|
71
|
+
}
|
|
55
72
|
/**
|
|
56
73
|
* Return the lower-right (3,3) entry in the sums.
|
|
57
74
|
* * This is the quantity (i.e. length, area, or volume) summed.
|
|
58
75
|
*/
|
|
59
76
|
get quantitySum() {
|
|
60
|
-
return this.sums.
|
|
77
|
+
return this.sums.weight();
|
|
61
78
|
}
|
|
62
79
|
/**
|
|
63
80
|
* Return a scale factor to make these sums match the target orientation sign.
|
|
@@ -88,23 +105,6 @@ export class MomentData {
|
|
|
88
105
|
this.needOrigin = false;
|
|
89
106
|
}
|
|
90
107
|
}
|
|
91
|
-
/** Radii of gyration (square roots of principal second moments). */
|
|
92
|
-
radiusOfGyration;
|
|
93
|
-
/**
|
|
94
|
-
* Principal quantity (e.g. length, area, or volume). This is undefined in raw moments, and becomes defined by
|
|
95
|
-
* inertiaProductsToPrincipalAxes.
|
|
96
|
-
*/
|
|
97
|
-
absoluteQuantity;
|
|
98
|
-
/** Constructor. */
|
|
99
|
-
constructor() {
|
|
100
|
-
this.origin = Point3d.createZero();
|
|
101
|
-
this.sums = Matrix4d.createZero();
|
|
102
|
-
this.localToWorldMap = Transform.createIdentity();
|
|
103
|
-
this.radiusOfGyration = Vector3d.create();
|
|
104
|
-
this.needOrigin = false;
|
|
105
|
-
this.absoluteQuantity = 0.1; // so optimizer sees its type
|
|
106
|
-
this.absoluteQuantity = undefined;
|
|
107
|
-
}
|
|
108
108
|
/**
|
|
109
109
|
* Create moments with optional origin.
|
|
110
110
|
* * Origin and needOrigin are quirky.
|
|
@@ -148,7 +148,7 @@ export class MomentData {
|
|
|
148
148
|
axes.setColumnsPoint4dXYZ(points[0], points[1], points[2]);
|
|
149
149
|
if (axes.determinant() < 0)
|
|
150
150
|
axes.scaleColumnsInPlace(-1.0, -1.0, -1.0);
|
|
151
|
-
// prefer x and z positive
|
|
151
|
+
// prefer x and z positive; y falls wherever
|
|
152
152
|
if (axes.at(0, 0) < 0.0)
|
|
153
153
|
axes.scaleColumnsInPlace(-1.0, -1.0, 1.0);
|
|
154
154
|
if (axes.at(2, 2) < 0.0)
|
|
@@ -173,7 +173,8 @@ export class MomentData {
|
|
|
173
173
|
* * Hence x axis is long direction.
|
|
174
174
|
* * Hence planar data generates large moment as Z.
|
|
175
175
|
* @param origin The origin used for the inertia products.
|
|
176
|
-
* @param inertiaProducts The inertia products: sums or integrals of
|
|
176
|
+
* @param inertiaProducts The inertia products: sums or integrals of
|
|
177
|
+
* [xx,xy,xz,xw; yx,yy,yz,yw; zx,zy,zz,zw; wx,wy,wz,w].
|
|
177
178
|
*/
|
|
178
179
|
static inertiaProductsToPrincipalAxes(origin, inertiaProducts) {
|
|
179
180
|
const moments = new MomentData();
|
|
@@ -217,23 +218,21 @@ export class MomentData {
|
|
|
217
218
|
*/
|
|
218
219
|
static areEquivalentPrincipalAxes(dataA, dataB) {
|
|
219
220
|
if (dataA && dataB
|
|
220
|
-
&& Geometry.isSameCoordinate(dataA.quantitySum, dataB.quantitySum)) { //
|
|
221
|
+
&& Geometry.isSameCoordinate(dataA.quantitySum, dataB.quantitySum)) { // TODO: need different tolerance for area, volume?
|
|
221
222
|
if (dataA.localToWorldMap.getOrigin().isAlmostEqual(dataB.localToWorldMap.getOrigin())
|
|
222
223
|
&& dataA.radiusOfGyration.isAlmostEqual(dataB.radiusOfGyration)) {
|
|
223
224
|
if (Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.y)) {
|
|
224
|
-
//
|
|
225
|
+
// we have at least xy symmetry
|
|
225
226
|
if (Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.z))
|
|
226
227
|
return true;
|
|
227
|
-
// just xy
|
|
228
|
-
// allow opposite z directions.
|
|
229
|
-
// If the z's are aligned, x an dy can spin freely.
|
|
228
|
+
// just xy; allow opposite z directions; if the z's are aligned, x and y can spin freely
|
|
230
229
|
const zA = dataA.localToWorldMap.matrix.columnZ();
|
|
231
230
|
const zB = dataB.localToWorldMap.matrix.columnZ();
|
|
232
231
|
if (zA.isParallelTo(zB, true))
|
|
233
232
|
return true;
|
|
234
233
|
return false;
|
|
235
234
|
}
|
|
236
|
-
// no symmetry
|
|
235
|
+
// no symmetry; test all three axes
|
|
237
236
|
const vectorA = Vector3d.create();
|
|
238
237
|
const vectorB = Vector3d.create();
|
|
239
238
|
for (let i = 0; i < 3; i++) {
|
|
@@ -263,7 +262,7 @@ export class MomentData {
|
|
|
263
262
|
}
|
|
264
263
|
/** Revise the accumulated sums to be "around the centroid". */
|
|
265
264
|
shiftOriginAndSumsToCentroidOfSums() {
|
|
266
|
-
const xyz = this.sums.columnW().realPoint();
|
|
265
|
+
const xyz = this.sums.columnW().realPoint(); // centroid of the geometry
|
|
267
266
|
if (xyz) {
|
|
268
267
|
this.shiftOriginAndSumsByXYZ(xyz.x, xyz.y, xyz.z);
|
|
269
268
|
return true;
|
|
@@ -272,9 +271,9 @@ export class MomentData {
|
|
|
272
271
|
}
|
|
273
272
|
/**
|
|
274
273
|
* Revise the accumulated sums.
|
|
275
|
-
* *
|
|
276
|
-
* *
|
|
277
|
-
|
|
274
|
+
* * Add (ax,ay,az) to the origin coordinates.
|
|
275
|
+
* * Apply the negative translation to the sums.
|
|
276
|
+
*/
|
|
278
277
|
shiftOriginAndSumsByXYZ(ax, ay, az) {
|
|
279
278
|
this.origin.addXYZInPlace(ax, ay, az);
|
|
280
279
|
this.sums.multiplyTranslationSandwichInPlace(-ax, -ay, -az);
|
|
@@ -284,23 +283,24 @@ export class MomentData {
|
|
|
284
283
|
this.shiftOriginAndSumsByXYZ(newOrigin.x - this.origin.x, newOrigin.y - this.origin.y, newOrigin.z - this.origin.z);
|
|
285
284
|
}
|
|
286
285
|
/**
|
|
287
|
-
* Compute moments of a triangle from the origin
|
|
288
|
-
*
|
|
289
|
-
* * If `pointA` is undefined, use `this.origin` as pointA
|
|
290
|
-
|
|
291
|
-
*/
|
|
286
|
+
* Compute moments of a triangle from the origin. Accumulate them to `this.sums`.
|
|
287
|
+
* * If `this.needOrigin` is set, `this.origin` is set to `pointB`.
|
|
288
|
+
* * If `pointA` is undefined, use `this.origin` as `pointA`.
|
|
289
|
+
*/
|
|
292
290
|
accumulateTriangleMomentsXY(pointA, pointB, pointC) {
|
|
293
291
|
this.setOriginXYZIfNeeded(pointB.x, pointB.y, 0.0);
|
|
294
292
|
const x0 = this.origin.x;
|
|
295
293
|
const y0 = this.origin.y;
|
|
296
|
-
const vectorA = MomentData._vectorA =
|
|
297
|
-
|
|
298
|
-
|
|
294
|
+
const vectorA = MomentData._vectorA = (pointA !== undefined) ?
|
|
295
|
+
Point4d.create(pointA.x - x0, pointA.y - y0, 0.0, 1.0, MomentData._vectorA) :
|
|
296
|
+
Point4d.create(0.0, 0.0, 0.0, 1.0, MomentData._vectorA);
|
|
299
297
|
const vectorB = MomentData._vectorB = Point4d.create(pointB.x - x0, pointB.y - y0, 0.0, 1.0, MomentData._vectorB);
|
|
300
298
|
const vectorC = MomentData._vectorC = Point4d.create(pointC.x - x0, pointC.y - y0, 0.0, 1.0, MomentData._vectorC);
|
|
301
|
-
//
|
|
302
|
-
//
|
|
303
|
-
//
|
|
299
|
+
// Below we calculate 16 double integrals: \iint_T [x y 0 1]^ [x y 0 1] dT over triangle T=(A,B,C).
|
|
300
|
+
// Each accumulates contributions from 9 scaled outer products. Integration computations use the barycentric
|
|
301
|
+
// change of variables [B-A C-A][u,v]^ = [x,y]^ with Jacobian detJ = B-A x C-A = twice the area of T.
|
|
302
|
+
// This converts the integration domain from T to the triangle bounded by u=0, v=0 and v=1-u, yielding e.g.,
|
|
303
|
+
// \iint_T x^2 dT = detJ \int_0^1 \int_0^{1-u} u^2 dv du = detJ / 12, and similarly \iint_T xy dT = detJ / 24.
|
|
304
304
|
const detJ = Geometry.crossProductXYXY(vectorB.x - vectorA.x, vectorB.y - vectorA.y, vectorC.x - vectorA.x, vectorC.y - vectorA.y);
|
|
305
305
|
if (detJ !== 0.0) {
|
|
306
306
|
const r1_12 = detJ / 12.0;
|
|
@@ -316,7 +316,7 @@ export class MomentData {
|
|
|
316
316
|
this.sums.addScaledOuterProductInPlace(vectorC, vectorC, r1_12);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
-
/** Add scaled outer product of (4d, unit weight) point to this.sums
|
|
319
|
+
/** Add scaled outer product of (4d, unit weight) point to `this.sums`. */
|
|
320
320
|
accumulateScaledOuterProduct(point, scaleFactor) {
|
|
321
321
|
this.setOriginXYZIfNeeded(point.x, point.y, 0.0);
|
|
322
322
|
const vectorA = MomentData._vectorA = Point4d.create(point.x - this.origin.x, point.y - this.origin.y, point.z - this.origin.z, 1.0, MomentData._vectorA);
|
|
@@ -339,16 +339,15 @@ export class MomentData {
|
|
|
339
339
|
this.sums.addScaledOuterProductInPlace(vectorB, vectorB, r1_3);
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
|
-
* Compute moments of triangles from a base point to the given linestring.
|
|
343
|
-
*
|
|
344
|
-
* * If `
|
|
345
|
-
* * If `this.needOrigin` is set, the first point of the array is captured as local origin for subsequent sums.
|
|
346
|
-
*
|
|
342
|
+
* Compute moments of triangles from a base point to the given linestring. Accumulate them to `this.sums`.
|
|
343
|
+
* * If `this.needOrigin` is set, `this.origin` is set to the first point of the array.
|
|
344
|
+
* * If `sweepBase` is undefined, use `this.origin` as `sweepBase`.
|
|
347
345
|
*/
|
|
348
346
|
accumulateTriangleToLineStringMomentsXY(sweepBase, points) {
|
|
349
347
|
const n = points.length;
|
|
350
348
|
if (n > 1) {
|
|
351
349
|
points.getPoint3dAtUncheckedPointIndex(0, this._point0);
|
|
350
|
+
// The linestring forms a polygon with sweepBase. Integrate over this polygon using Shoelace algorithm.
|
|
352
351
|
for (let i = 1; i < n; i++) {
|
|
353
352
|
points.getPoint3dAtUncheckedPointIndex(i, this._point1);
|
|
354
353
|
this.accumulateTriangleMomentsXY(sweepBase, this._point0, this._point1);
|
|
@@ -357,17 +356,17 @@ export class MomentData {
|
|
|
357
356
|
}
|
|
358
357
|
}
|
|
359
358
|
/**
|
|
360
|
-
*
|
|
361
|
-
* * Sandwich this between transforms with columns [vectorU, vectorV, 0000, origin].
|
|
362
|
-
* parts of vectors).
|
|
363
|
-
* *
|
|
359
|
+
* Assemble XX, YY, XY products into a full matrix form [xx,xy,0,0; xy,yy,0,0; 0,0,0,0; 0,0,0,1].
|
|
360
|
+
* * Sandwich this between transforms with columns [vectorU, vectorV, 0000, origin].
|
|
361
|
+
* (column weights 0001; only xy parts of vectors).
|
|
362
|
+
* * Scale by detJ for the xy-only determinant of the vectors.
|
|
364
363
|
* @param productXX
|
|
365
364
|
* @param productXY
|
|
366
365
|
* @param productYY
|
|
367
|
-
* @param area
|
|
368
|
-
* @param origin
|
|
369
|
-
* @param vectorU
|
|
370
|
-
* @param vectorV
|
|
366
|
+
* @param area area in caller's system.
|
|
367
|
+
* @param origin caller's origin.
|
|
368
|
+
* @param vectorU caller's U axis (not necessarily unit).
|
|
369
|
+
* @param vectorV caller's V axis (not necessarily unit).
|
|
371
370
|
*/
|
|
372
371
|
accumulateXYProductsInCentroidalFrame(productXX, productXY, productYY, area, origin, vectorU, vectorV) {
|
|
373
372
|
const centroidalProducts = Matrix4d.createRowValues(productXX, productXY, 0, 0, productXY, productYY, 0, 0, 0, 0, 0, 0, 0, 0, 0, area);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MomentData.js","sourceRoot":"","sources":["../../../src/geometry4d/MomentData.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,yDAAyD;AACzD,mBAAmB;AAEnB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAO,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,UAAU;IACrB,4BAA4B;IACrB,MAAM,CAAU;IACvB,6CAA6C;IACtC,UAAU,CAAU;IAC3B;;;;OAIG;IACI,IAAI,CAAW;IACtB;;;OAGG;IACI,eAAe,CAAY;IAClC,oBAAoB;IACZ,MAAM,CAAC,QAAQ,CAAW;IAC1B,MAAM,CAAC,QAAQ,CAAW;IAC1B,MAAM,CAAC,QAAQ,CAAW;IAC1B,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACnC;;;OAGG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IACD;;;;OAIG;IACI,UAAU,CAAC,UAAkB;QAClC,OAAO,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAA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CAAC,MAAe,EAAE,QAAkB,EAAE,KAAa;QACpF,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,6BAA6B,CACrC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAC9F,CAAC;IACJ,CAAC;IACD,qCAAqC;IAC9B,MAAM;QACX,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACxB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE;YAChD,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;SAC5C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Numerics\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\n// cspell:word ABAT\n\nimport { Geometry } from \"../Geometry\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\nimport { Point3d, Vector3d, XYZ } from \"../geometry3d/Point3dVector3d\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { XAndY, XYAndZ } from \"../geometry3d/XYZProps\";\nimport { Matrix4d } from \"./Matrix4d\";\nimport { Point4d } from \"./Point4d\";\n\n/**\n * A MomentData structure exists in several levels:\n * * First level: as a carrier of sums of inertial products that determine moments.\n * * origin = local origin used as moments are summed.\n * * sums = array of summed moments.\n * * The [i,j] entry of the sums is a summed or integrated moment for product of axis i and j.\n * * axes 0,1,2 are x,y,z.\n * * e.g. entry [0,1] is summed product xy\n * * axis 3 is \"w\", which is 1 in sums.\n * * e.g. entry 03 is summed x.\n * * In this level:\n * * the `absoluteQuantity` member is undefined.\n * * the `localToWorldMap` and `radiiOfGyration` are created by have undefined contents.\n * * Second level: after a call to inertiaProductsToPrincipalAxes, the `localToWorldMap`, `absoluteQuantity` and\n * `radiiOfGyration` are filled in.\n * @public\n */\nexport class MomentData {\n /** Origin used for sums. */\n public origin: Point3d;\n /** Flag to request deferred origin setup. */\n public needOrigin: boolean;\n /**\n * Moment sums.\n * * Set to zero at initialization and if requested later.\n * * Accumulated during data entry phase.\n */\n public sums: Matrix4d;\n /**\n * The mapping between principal and world system.\n * * This set up with its inverse already constructed.\n */\n public localToWorldMap: Transform;\n // private variables\n private static _vectorA?: Point4d;\n private static _vectorB?: Point4d;\n private static _vectorC?: Point4d;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n /**\n * Return the lower-right (3,3) entry in the sums.\n * * This is the quantity (i.e. length, area, or volume) summed.\n */\n public get quantitySum(): number {\n return this.sums.atIJ(3, 3);\n }\n /**\n * Return a scale factor to make these sums match the target orientation sign.\n * * 1.0 if `this.quantitySum` has the same sign as `targetSign`.\n * * -1.0 if `this.quantitySum` has the opposite sign from `targetSign`\n */\n public signFactor(targetSign: number): number {\n return targetSign * this.quantitySum > 0 ? 1.0 : -1.0;\n }\n /** If `this.needOrigin` flag is set, copy `origin` to `this.origin` and clear the flag. */\n public setOriginIfNeeded(origin: Point3d) {\n if (this.needOrigin) {\n this.origin.setFromPoint3d(origin);\n this.needOrigin = false;\n }\n }\n /** If `this.needOrigin` flag is set, copy `origin` to `this.origin` and clear the flag. */\n public setOriginFromGrowableXYZArrayIfNeeded(points: GrowableXYZArray) {\n if (this.needOrigin && points.length > 0) {\n points.getPoint3dAtCheckedPointIndex(0, this.origin);\n this.needOrigin = false;\n }\n }\n /** If `this.needOrigin` flag is set, copy `origin` to `this.origin` and clear the flag. */\n public setOriginXYZIfNeeded(x: number, y: number, z: number) {\n if (this.needOrigin) {\n this.origin.set(x, y, z);\n this.needOrigin = false;\n }\n }\n /** Radii of gyration (square roots of principal second moments). */\n public radiusOfGyration: Vector3d;\n /**\n * Principal quantity (e.g. length, area, or volume). This is undefined in raw moments, and becomes defined by\n * inertiaProductsToPrincipalAxes.\n */\n public absoluteQuantity?: number;\n /** Constructor. */\n private constructor() {\n this.origin = Point3d.createZero();\n this.sums = Matrix4d.createZero();\n this.localToWorldMap = Transform.createIdentity();\n this.radiusOfGyration = Vector3d.create();\n this.needOrigin = false;\n this.absoluteQuantity = 0.1; // so optimizer sees its type\n this.absoluteQuantity = undefined;\n }\n /**\n * Create moments with optional origin.\n * * Origin and needOrigin are quirky.\n * * (undefined, true) sets up to use first incoming point as origin.\n * * (origin) sets up to use that durable origin, set needsOrigin flag false.\n * * (origin, true) the \"true\" is meaningless.\n * * (undefined, false) makes 000 the durable origin.\n */\n public static create(origin?: Point3d | undefined, needOrigin: boolean = false): MomentData {\n const data = new MomentData();\n data.needOrigin = needOrigin;\n if (origin) {\n data.origin.setFromPoint3d(origin);\n data.needOrigin = false;\n }\n return data;\n }\n /**\n * Return the formal tensor of integrated values `[yy+zz,xy,xz][yx,xx+zz,yz][zx,xy,xx+yy]`.\n * @param products matrix of (integrated) `[xx,xy,xz][yx,yy,yz][zx,xy,zz]`.\n */\n public static momentTensorFromInertiaProducts(products: Matrix3d): Matrix3d {\n const rr = products.sumDiagonal();\n const result = Matrix3d.createScale(rr, rr, rr);\n result.addScaledInPlace(products, -1.0);\n return result;\n }\n /** Sort the columns of the matrix for increasing moments. */\n public static sortColumnsForIncreasingMoments(axes: Matrix3d, moments: Vector3d) {\n const points = [\n axes.indexedColumnWithWeight(0, moments.x),\n axes.indexedColumnWithWeight(1, moments.y),\n axes.indexedColumnWithWeight(2, moments.z),\n ].sort((dataA: Point4d, dataB: Point4d): number => {\n if (dataA.w < dataB.w) return -1;\n if (dataA.w > dataB.w) return 1;\n return 0;\n });\n axes.setColumnsPoint4dXYZ(points[0], points[1], points[2]);\n if (axes.determinant() < 0)\n axes.scaleColumnsInPlace(-1.0, -1.0, -1.0);\n // prefer x and z positive -- y falls wherever . ..\n if (axes.at(0, 0) < 0.0)\n axes.scaleColumnsInPlace(-1.0, -1.0, 1.0);\n if (axes.at(2, 2) < 0.0)\n axes.scaleColumnsInPlace(1.0, -1.0, -1.0);\n moments.set(points[0].w, points[1].w, points[2].w);\n }\n /**\n * Return the principal moment data for an array of points.\n * @param points array of points.\n */\n public static pointsToPrincipalAxes(points: Point3d[]): MomentData | undefined {\n const moments = new MomentData();\n if (points.length === 0)\n return moments;\n moments.clearSums(points[0]);\n moments.accumulatePointMomentsFromOrigin(points);\n return this.inertiaProductsToPrincipalAxes(moments.origin, moments.sums);\n }\n /**\n * Compute principal axes from inertial products.\n * * The radii of gyration are sorted smallest to largest.\n * * Hence x axis is long direction.\n * * Hence planar data generates large moment as Z.\n * @param origin The origin used for the inertia products.\n * @param inertiaProducts The inertia products: sums or integrals of [xx,xy,xz,xw; yx,yy, yz,yw; zx,zy,zz,zw; wx,wy,wz,w].\n */\n public static inertiaProductsToPrincipalAxes(origin: XYZ, inertiaProducts: Matrix4d): MomentData | undefined {\n const moments = new MomentData();\n moments.sums.setFrom(inertiaProducts);\n moments.origin.setFrom(origin);\n if (!moments.shiftOriginAndSumsToCentroidOfSums())\n return undefined;\n const products = moments.sums.matrixPart();\n const w = moments.sums.weight();\n if (w < 0.0)\n products.scaleColumnsInPlace(-1, -1, -1);\n const tensor = MomentData.momentTensorFromInertiaProducts(products);\n const moment2 = Vector3d.create();\n const axisVectors = Matrix3d.createZero();\n tensor.fastSymmetricEigenvalues(axisVectors, moment2);\n if (moment2.x < 0.0)\n return undefined;\n MomentData.sortColumnsForIncreasingMoments(axisVectors, moment2);\n if (w < 0.0)\n axisVectors.scaleColumnsInPlace(1, -1, -1);\n moments.localToWorldMap = Transform.createOriginAndMatrix(moments.origin, axisVectors);\n moments.radiusOfGyration.set(\n Math.sqrt(Math.abs(moment2.x)), Math.sqrt(Math.abs(moment2.y)), Math.sqrt(Math.abs(moment2.z)));\n moments.radiusOfGyration.scaleInPlace(1.0 / Math.sqrt(Math.abs(w)));\n moments.absoluteQuantity = Math.abs(w);\n return moments;\n }\n /**\n * Test for match among selected members as they exist after `inertiaProductsToPrincipalAxes`.\n * * The members considered are:\n * * origin of local to world map (i.e. centroid),\n * * radius of gyration,\n * * axes of localToWorldMap.\n * * Axis direction tests allow these quirks:\n * * opposite orientation is considered matched.\n * * Full xyz symmetry: If x,y,z radii are matched, axes are not tested.\n * * Symmetry in xy plane: If x and y radii are matched, the x and y axes area allowed to spin freely. Only Z direction\n * is tested.\n * * If either or both are undefined, returns false.\n * @param dataA first set of moments.\n * @param dataB second set of moments.\n */\n public static areEquivalentPrincipalAxes(dataA: MomentData | undefined, dataB: MomentData | undefined): boolean {\n if (dataA && dataB\n && Geometry.isSameCoordinate(dataA.quantitySum, dataB.quantitySum)) { // um.. need different tolerance for area, volume?)\n if (dataA.localToWorldMap.getOrigin().isAlmostEqual(dataB.localToWorldMap.getOrigin())\n && dataA.radiusOfGyration.isAlmostEqual(dataB.radiusOfGyration)) {\n if (Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.y)) {\n // We have at least xy symmetry ....\n if (Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.z))\n return true;\n // just xy.\n // allow opposite z directions.\n // If the z's are aligned, x an dy can spin freely.\n const zA = dataA.localToWorldMap.matrix.columnZ();\n const zB = dataB.localToWorldMap.matrix.columnZ();\n if (zA.isParallelTo(zB, true))\n return true;\n return false;\n }\n // no symmetry. Test all three axes.\n const vectorA = Vector3d.create();\n const vectorB = Vector3d.create();\n for (let i = 0; i < 3; i++) {\n dataA.localToWorldMap.matrix.getColumn(i, vectorA);\n dataB.localToWorldMap.matrix.getColumn(i, vectorB);\n if (!vectorA.isParallelTo(vectorB, true))\n return false;\n }\n return true;\n }\n }\n return false;\n }\n /** Clear the MomentData sums to zero, and establish a new origin. */\n public clearSums(origin?: Point3d) {\n this.sums.setZero();\n if (origin)\n this.origin.setFrom(origin);\n else\n this.origin.setZero();\n }\n /** Accumulate products-of-components for given points. */\n public accumulatePointMomentsFromOrigin(points: Point3d[]) {\n for (const p of points) {\n this.sums.addMomentsInPlace(\n p.x - this.origin.x,\n p.y - this.origin.y,\n p.z - this.origin.z,\n 1.0,\n );\n }\n }\n /** Revise the accumulated sums to be \"around the centroid\". */\n public shiftOriginAndSumsToCentroidOfSums(): boolean {\n const xyz = this.sums.columnW().realPoint();\n if (xyz) {\n this.shiftOriginAndSumsByXYZ(xyz.x, xyz.y, xyz.z);\n return true;\n }\n return false;\n }\n\n /**\n * Revise the accumulated sums.\n * * add ax,ay,ax to the origin coordinates.\n * * apply the negative translation to the sums.\n */\n public shiftOriginAndSumsByXYZ(ax: number, ay: number, az: number) {\n this.origin.addXYZInPlace(ax, ay, az);\n this.sums.multiplyTranslationSandwichInPlace(-ax, -ay, -az);\n }\n /** Revise the accumulated sums so they are based at a specified origin. */\n public shiftOriginAndSumsToNewOrigin(newOrigin: XYAndZ) {\n this.shiftOriginAndSumsByXYZ(newOrigin.x - this.origin.x, newOrigin.y - this.origin.y, newOrigin.z - this.origin.z);\n }\n /**\n * Compute moments of a triangle from the origin to the given line.\n * Accumulate them to this.sums.\n * * If `pointA` is undefined, use `this.origin` as pointA.\n * * If `this.needOrigin` is set, pointB is used\n */\n public accumulateTriangleMomentsXY(pointA: XAndY | undefined, pointB: XAndY, pointC: XAndY) {\n this.setOriginXYZIfNeeded(pointB.x, pointB.y, 0.0);\n const x0 = this.origin.x;\n const y0 = this.origin.y;\n const vectorA = MomentData._vectorA =\n pointA !== undefined ? Point4d.create(pointA.x - x0, pointA.y - y0, 0.0, 1.0, MomentData._vectorA)\n : Point4d.create(this.origin.x, this.origin.y, 0.0, 1.0, MomentData._vectorA);\n const vectorB = MomentData._vectorB = Point4d.create(pointB.x - x0, pointB.y - y0, 0.0, 1.0, MomentData._vectorB);\n const vectorC = MomentData._vectorC = Point4d.create(pointC.x - x0, pointC.y - y0, 0.0, 1.0, MomentData._vectorC);\n // accumulate Return product integrals I(0<=u<=1) I (0<=v<= u) (w*W + u *U + v * V)(w*W + u *U + v * V)^ du dv\n // where w = 1-u-v\n // W = column vector (point00.x, point00.y, point00.z, 1.0) etc.\n const detJ = Geometry.crossProductXYXY(vectorB.x - vectorA.x, vectorB.y - vectorA.y, vectorC.x - vectorA.x, vectorC.y - vectorA.y);\n if (detJ !== 0.0) {\n const r1_12 = detJ / 12.0;\n const r1_24 = detJ / 24.0;\n\n this.sums.addScaledOuterProductInPlace(vectorA, vectorA, r1_12);\n this.sums.addScaledOuterProductInPlace(vectorA, vectorB, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorA, vectorC, r1_24);\n\n this.sums.addScaledOuterProductInPlace(vectorB, vectorA, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorB, r1_12);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorC, r1_24);\n\n this.sums.addScaledOuterProductInPlace(vectorC, vectorA, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorC, vectorB, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorC, vectorC, r1_12);\n }\n }\n /** Add scaled outer product of (4d, unit weight) point to this.sums. */\n public accumulateScaledOuterProduct(point: XYAndZ, scaleFactor: number) {\n this.setOriginXYZIfNeeded(point.x, point.y, 0.0);\n const vectorA = MomentData._vectorA = Point4d.create(\n point.x - this.origin.x, point.y - this.origin.y, point.z - this.origin.z, 1.0, MomentData._vectorA,\n );\n this.sums.addScaledOuterProductInPlace(vectorA, vectorA, scaleFactor);\n }\n /** Accumulate wire moment integral from pointA to pointB */\n public accumulateLineMomentsXYZ(pointA: Point3d, pointB: Point3d) {\n this.setOriginXYZIfNeeded(pointA.x, pointA.y, pointA.z);\n const x0 = this.origin.x;\n const y0 = this.origin.y;\n const z0 = this.origin.z;\n const vectorA = MomentData._vectorA = Point4d.create(\n pointA.x - x0, pointA.y - y0, pointA.z - z0, 1.0, MomentData._vectorA,\n );\n const vectorB = MomentData._vectorB = Point4d.create(\n pointB.x - x0, pointB.y - y0, pointB.z - z0, 1.0, MomentData._vectorB,\n );\n const detJ = pointA.distance(pointB);\n const r1_3 = detJ / 3.0;\n const r1_6 = detJ / 6.0;\n this.sums.addScaledOuterProductInPlace(vectorA, vectorA, r1_3);\n this.sums.addScaledOuterProductInPlace(vectorA, vectorB, r1_6);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorA, r1_6);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorB, r1_3);\n }\n /**\n * Compute moments of triangles from a base point to the given linestring.\n * Accumulate them to this.sums.\n * * If `pointA` is undefined, use `this.origin` as pointA.\n * * If `this.needOrigin` is set, the first point of the array is captured as local origin for subsequent sums.\n *\n */\n public accumulateTriangleToLineStringMomentsXY(sweepBase: XAndY | undefined, points: GrowableXYZArray) {\n const n = points.length;\n if (n > 1) {\n points.getPoint3dAtUncheckedPointIndex(0, this._point0);\n for (let i = 1; i < n; i++) {\n points.getPoint3dAtUncheckedPointIndex(i, this._point1);\n this.accumulateTriangleMomentsXY(sweepBase, this._point0, this._point1);\n this._point0.setFromPoint3d(this._point1);\n }\n }\n }\n /**\n * * Assemble XX, YY, XY products into a full matrix form [xx,xy,0,0; xy,yy,0,0;0,0,0,0;0,0,0,1].\n * * Sandwich this between transforms with columns [vectorU, vectorV, 0000, origin]. (Column weights 0001) (only xy\n * parts of vectors).\n * * scale by detJ for the xy-only determinant of the vectors.\n * @param productXX\n * @param productXY\n * @param productYY\n * @param area Area in caller's system.\n * @param origin Caller's origin.\n * @param vectorU Caller's U axis (not necessarily unit).\n * @param vectorV Caller's V axis (not necessarily unit).\n */\n public accumulateXYProductsInCentroidalFrame(\n productXX: number, productXY: number, productYY: number,\n area: number, origin: XAndY, vectorU: XAndY, vectorV: XAndY,\n ) {\n const centroidalProducts = Matrix4d.createRowValues(\n productXX, productXY, 0, 0,\n productXY, productYY, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, area,\n );\n const detJ = Geometry.crossProductXYXY(vectorU.x, vectorV.x, vectorU.y, vectorV.y);\n const placement = Matrix4d.createRowValues(\n vectorU.x, vectorV.x, 0, origin.x - this.origin.x,\n vectorU.y, vectorV.y, 0, origin.y - this.origin.y,\n 0, 0, 0, 0,\n 0, 0, 0, 1,\n );\n const AB = placement.multiplyMatrixMatrix(centroidalProducts);\n const ABAT = AB.multiplyMatrixMatrixTranspose(placement);\n this.sums.addScaledInPlace(ABAT, detJ);\n }\n /**\n * Accumulate sums from other moments.\n * * Scale by given scaleFactor (e.g. sign to correct orientation).\n * * Pull the origin from `other` if `this` needs an origin.\n */\n public accumulateProducts(other: MomentData, scale: number) {\n this.setOriginIfNeeded(other.origin);\n this.sums.addTranslationSandwichInPlace(\n other.sums, this.origin.x - other.origin.x, this.origin.y - other.origin.y, this.origin.z - other.origin.z, scale,\n );\n }\n\n /**\n * Accumulate sums from Matrix4d and origin.\n * * Scale by given scaleFactor (e.g. sign to correct orientation).\n * * Trap the origin if `this` needs an origin.\n */\n public accumulateProductsFromOrigin(origin: Point3d, products: Matrix4d, scale: number) {\n this.setOriginIfNeeded(origin);\n this.sums.addTranslationSandwichInPlace(\n products, this.origin.x - origin.x, this.origin.y - origin.y, this.origin.z - origin.z, scale,\n );\n }\n /** Convert to a json data object. */\n public toJSON(): any {\n return {\n origin: this.origin,\n sums: this.sums.toJSON(),\n radiusOfGyration: this.radiusOfGyration.toJSON(),\n localToWorld: this.localToWorldMap.toJSON(),\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MomentData.js","sourceRoot":"","sources":["../../../src/geometry4d/MomentData.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,yDAAyD;AACzD,mBAAmB;AAEnB,OAAO,EAAE,QAAQ,EAAE,MAAM,aA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AC9F,CAAC;IACJ,CAAC;IACD,qCAAqC;IAC9B,MAAM;QACX,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACxB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE;YAChD,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;SAC5C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Numerics\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\n// cspell:word ABAT\n\nimport { Geometry } from \"../Geometry\";\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\nimport { Point3d, Vector3d, XYZ } from \"../geometry3d/Point3dVector3d\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { XAndY, XYAndZ } from \"../geometry3d/XYZProps\";\nimport { Matrix4d } from \"./Matrix4d\";\nimport { Point4d } from \"./Point4d\";\n\n/**\n * A MomentData structure exists in several levels:\n * * First level: as a carrier of sums of inertial products that determine moments.\n * * origin = local origin used as moments are summed.\n * * sums = array of summed moments.\n * * The [i,j] entry of the sums is a summed or integrated moment for product of axis i and j.\n * * axes 0,1,2 are x,y,z.\n * * e.g. entry [0,1] is summed product xy\n * * axis 3 is \"w\", which is 1 in sums.\n * * e.g. entry 03 is summed x.\n * * In this level:\n * * the `absoluteQuantity` member is undefined.\n * * the `localToWorldMap` and `radiiOfGyration` are created but have undefined contents.\n * * Second level: after a call to `inertiaProductsToPrincipalAxes`, the `localToWorldMap`, `absoluteQuantity` and\n * `radiiOfGyration` are filled in.\n * @public\n */\nexport class MomentData {\n /** Origin used for sums. */\n public origin: Point3d;\n /** Flag to request deferred origin setup. */\n public needOrigin: boolean;\n /**\n * Moment sums.\n * * Set to zero at initialization and if requested later.\n * * Accumulated during data entry phase.\n */\n public sums: Matrix4d;\n /**\n * The mapping between principal and world system.\n * * This set up with its inverse already constructed.\n */\n public localToWorldMap: Transform;\n /** Radii of gyration (square roots of principal second moments). */\n public radiusOfGyration: Vector3d;\n /**\n * Principal quantity (e.g. length, area, or volume). This is undefined in raw moments, and becomes defined by\n * inertiaProductsToPrincipalAxes.\n */\n public absoluteQuantity?: number;\n // private variables\n private static _vectorA?: Point4d;\n private static _vectorB?: Point4d;\n private static _vectorC?: Point4d;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n /** Constructor. */\n private constructor() {\n this.origin = Point3d.createZero();\n this.needOrigin = false;\n this.sums = Matrix4d.createZero();\n this.localToWorldMap = Transform.createIdentity();\n this.radiusOfGyration = Vector3d.create();\n this.absoluteQuantity = 0.1; // so optimizer sees its type\n this.absoluteQuantity = undefined;\n }\n /**\n * Return the lower-right (3,3) entry in the sums.\n * * This is the quantity (i.e. length, area, or volume) summed.\n */\n public get quantitySum(): number {\n return this.sums.weight();\n }\n /**\n * Return a scale factor to make these sums match the target orientation sign.\n * * 1.0 if `this.quantitySum` has the same sign as `targetSign`.\n * * -1.0 if `this.quantitySum` has the opposite sign from `targetSign`\n */\n public signFactor(targetSign: number): number {\n return targetSign * this.quantitySum > 0 ? 1.0 : -1.0;\n }\n /** If `this.needOrigin` flag is set, copy `origin` to `this.origin` and clear the flag. */\n public setOriginIfNeeded(origin: Point3d) {\n if (this.needOrigin) {\n this.origin.setFromPoint3d(origin);\n this.needOrigin = false;\n }\n }\n /** If `this.needOrigin` flag is set, copy `origin` to `this.origin` and clear the flag. */\n public setOriginFromGrowableXYZArrayIfNeeded(points: GrowableXYZArray) {\n if (this.needOrigin && points.length > 0) {\n points.getPoint3dAtCheckedPointIndex(0, this.origin);\n this.needOrigin = false;\n }\n }\n /** If `this.needOrigin` flag is set, copy `origin` to `this.origin` and clear the flag. */\n public setOriginXYZIfNeeded(x: number, y: number, z: number) {\n if (this.needOrigin) {\n this.origin.set(x, y, z);\n this.needOrigin = false;\n }\n }\n /**\n * Create moments with optional origin.\n * * Origin and needOrigin are quirky.\n * * (undefined, true) sets up to use first incoming point as origin.\n * * (origin) sets up to use that durable origin, set needsOrigin flag false.\n * * (origin, true) the \"true\" is meaningless.\n * * (undefined, false) makes 000 the durable origin.\n */\n public static create(origin?: Point3d | undefined, needOrigin: boolean = false): MomentData {\n const data = new MomentData();\n data.needOrigin = needOrigin;\n if (origin) {\n data.origin.setFromPoint3d(origin);\n data.needOrigin = false;\n }\n return data;\n }\n /**\n * Return the formal tensor of integrated values `[yy+zz,xy,xz][yx,xx+zz,yz][zx,xy,xx+yy]`.\n * @param products matrix of (integrated) `[xx,xy,xz][yx,yy,yz][zx,xy,zz]`.\n */\n public static momentTensorFromInertiaProducts(products: Matrix3d): Matrix3d {\n const rr = products.sumDiagonal();\n const result = Matrix3d.createScale(rr, rr, rr);\n result.addScaledInPlace(products, -1.0);\n return result;\n }\n /** Sort the columns of the matrix for increasing moments. */\n public static sortColumnsForIncreasingMoments(axes: Matrix3d, moments: Vector3d) {\n const points = [\n axes.indexedColumnWithWeight(0, moments.x),\n axes.indexedColumnWithWeight(1, moments.y),\n axes.indexedColumnWithWeight(2, moments.z),\n ].sort((dataA: Point4d, dataB: Point4d): number => {\n if (dataA.w < dataB.w) return -1;\n if (dataA.w > dataB.w) return 1;\n return 0;\n });\n axes.setColumnsPoint4dXYZ(points[0], points[1], points[2]);\n if (axes.determinant() < 0)\n axes.scaleColumnsInPlace(-1.0, -1.0, -1.0);\n // prefer x and z positive; y falls wherever\n if (axes.at(0, 0) < 0.0)\n axes.scaleColumnsInPlace(-1.0, -1.0, 1.0);\n if (axes.at(2, 2) < 0.0)\n axes.scaleColumnsInPlace(1.0, -1.0, -1.0);\n moments.set(points[0].w, points[1].w, points[2].w);\n }\n /**\n * Return the principal moment data for an array of points.\n * @param points array of points.\n */\n public static pointsToPrincipalAxes(points: Point3d[]): MomentData | undefined {\n const moments = new MomentData();\n if (points.length === 0)\n return moments;\n moments.clearSums(points[0]);\n moments.accumulatePointMomentsFromOrigin(points);\n return this.inertiaProductsToPrincipalAxes(moments.origin, moments.sums);\n }\n /**\n * Compute principal axes from inertial products.\n * * The radii of gyration are sorted smallest to largest.\n * * Hence x axis is long direction.\n * * Hence planar data generates large moment as Z.\n * @param origin The origin used for the inertia products.\n * @param inertiaProducts The inertia products: sums or integrals of\n * [xx,xy,xz,xw; yx,yy,yz,yw; zx,zy,zz,zw; wx,wy,wz,w].\n */\n public static inertiaProductsToPrincipalAxes(origin: XYZ, inertiaProducts: Matrix4d): MomentData | undefined {\n const moments = new MomentData();\n moments.sums.setFrom(inertiaProducts);\n moments.origin.setFrom(origin);\n if (!moments.shiftOriginAndSumsToCentroidOfSums())\n return undefined;\n const products = moments.sums.matrixPart();\n const w = moments.sums.weight();\n if (w < 0.0)\n products.scaleColumnsInPlace(-1, -1, -1);\n const tensor = MomentData.momentTensorFromInertiaProducts(products);\n const moment2 = Vector3d.create();\n const axisVectors = Matrix3d.createZero();\n tensor.fastSymmetricEigenvalues(axisVectors, moment2);\n if (moment2.x < 0.0)\n return undefined;\n MomentData.sortColumnsForIncreasingMoments(axisVectors, moment2);\n if (w < 0.0)\n axisVectors.scaleColumnsInPlace(1, -1, -1);\n moments.localToWorldMap = Transform.createOriginAndMatrix(moments.origin, axisVectors);\n moments.radiusOfGyration.set(\n Math.sqrt(Math.abs(moment2.x)), Math.sqrt(Math.abs(moment2.y)), Math.sqrt(Math.abs(moment2.z)),\n );\n moments.radiusOfGyration.scaleInPlace(1.0 / Math.sqrt(Math.abs(w)));\n moments.absoluteQuantity = Math.abs(w);\n return moments;\n }\n /**\n * Test for match among selected members as they exist after `inertiaProductsToPrincipalAxes`.\n * * The members considered are:\n * * origin of local to world map (i.e. centroid),\n * * radius of gyration,\n * * axes of localToWorldMap.\n * * Axis direction tests allow these quirks:\n * * opposite orientation is considered matched.\n * * Full xyz symmetry: If x,y,z radii are matched, axes are not tested.\n * * Symmetry in xy plane: If x and y radii are matched, the x and y axes area allowed to spin freely. Only Z direction\n * is tested.\n * * If either or both are undefined, returns false.\n * @param dataA first set of moments.\n * @param dataB second set of moments.\n */\n public static areEquivalentPrincipalAxes(dataA: MomentData | undefined, dataB: MomentData | undefined): boolean {\n if (dataA && dataB\n && Geometry.isSameCoordinate(dataA.quantitySum, dataB.quantitySum)) { // TODO: need different tolerance for area, volume?\n if (dataA.localToWorldMap.getOrigin().isAlmostEqual(dataB.localToWorldMap.getOrigin())\n && dataA.radiusOfGyration.isAlmostEqual(dataB.radiusOfGyration)) {\n if (Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.y)) {\n // we have at least xy symmetry\n if (Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.z))\n return true;\n // just xy; allow opposite z directions; if the z's are aligned, x and y can spin freely\n const zA = dataA.localToWorldMap.matrix.columnZ();\n const zB = dataB.localToWorldMap.matrix.columnZ();\n if (zA.isParallelTo(zB, true))\n return true;\n return false;\n }\n // no symmetry; test all three axes\n const vectorA = Vector3d.create();\n const vectorB = Vector3d.create();\n for (let i = 0; i < 3; i++) {\n dataA.localToWorldMap.matrix.getColumn(i, vectorA);\n dataB.localToWorldMap.matrix.getColumn(i, vectorB);\n if (!vectorA.isParallelTo(vectorB, true))\n return false;\n }\n return true;\n }\n }\n return false;\n }\n /** Clear the MomentData sums to zero, and establish a new origin. */\n public clearSums(origin?: Point3d) {\n this.sums.setZero();\n if (origin)\n this.origin.setFrom(origin);\n else\n this.origin.setZero();\n }\n /** Accumulate products-of-components for given points. */\n public accumulatePointMomentsFromOrigin(points: Point3d[]) {\n for (const p of points) {\n this.sums.addMomentsInPlace(\n p.x - this.origin.x,\n p.y - this.origin.y,\n p.z - this.origin.z,\n 1.0,\n );\n }\n }\n /** Revise the accumulated sums to be \"around the centroid\". */\n public shiftOriginAndSumsToCentroidOfSums(): boolean {\n const xyz = this.sums.columnW().realPoint(); // centroid of the geometry\n if (xyz) {\n this.shiftOriginAndSumsByXYZ(xyz.x, xyz.y, xyz.z);\n return true;\n }\n return false;\n }\n /**\n * Revise the accumulated sums.\n * * Add (ax,ay,az) to the origin coordinates.\n * * Apply the negative translation to the sums.\n */\n public shiftOriginAndSumsByXYZ(ax: number, ay: number, az: number) {\n this.origin.addXYZInPlace(ax, ay, az);\n this.sums.multiplyTranslationSandwichInPlace(-ax, -ay, -az);\n }\n /** Revise the accumulated sums so they are based at a specified origin. */\n public shiftOriginAndSumsToNewOrigin(newOrigin: XYAndZ) {\n this.shiftOriginAndSumsByXYZ(newOrigin.x - this.origin.x, newOrigin.y - this.origin.y, newOrigin.z - this.origin.z);\n }\n /**\n * Compute moments of a triangle from the origin. Accumulate them to `this.sums`.\n * * If `this.needOrigin` is set, `this.origin` is set to `pointB`.\n * * If `pointA` is undefined, use `this.origin` as `pointA`.\n */\n public accumulateTriangleMomentsXY(pointA: XAndY | undefined, pointB: XAndY, pointC: XAndY) {\n this.setOriginXYZIfNeeded(pointB.x, pointB.y, 0.0);\n const x0 = this.origin.x;\n const y0 = this.origin.y;\n const vectorA = MomentData._vectorA = (pointA !== undefined) ?\n Point4d.create(pointA.x - x0, pointA.y - y0, 0.0, 1.0, MomentData._vectorA) :\n Point4d.create(0.0, 0.0, 0.0, 1.0, MomentData._vectorA);\n const vectorB = MomentData._vectorB = Point4d.create(pointB.x - x0, pointB.y - y0, 0.0, 1.0, MomentData._vectorB);\n const vectorC = MomentData._vectorC = Point4d.create(pointC.x - x0, pointC.y - y0, 0.0, 1.0, MomentData._vectorC);\n // Below we calculate 16 double integrals: \\iint_T [x y 0 1]^ [x y 0 1] dT over triangle T=(A,B,C).\n // Each accumulates contributions from 9 scaled outer products. Integration computations use the barycentric\n // change of variables [B-A C-A][u,v]^ = [x,y]^ with Jacobian detJ = B-A x C-A = twice the area of T.\n // This converts the integration domain from T to the triangle bounded by u=0, v=0 and v=1-u, yielding e.g.,\n // \\iint_T x^2 dT = detJ \\int_0^1 \\int_0^{1-u} u^2 dv du = detJ / 12, and similarly \\iint_T xy dT = detJ / 24.\n const detJ = Geometry.crossProductXYXY(\n vectorB.x - vectorA.x, vectorB.y - vectorA.y, vectorC.x - vectorA.x, vectorC.y - vectorA.y,\n );\n if (detJ !== 0.0) {\n const r1_12 = detJ / 12.0;\n const r1_24 = detJ / 24.0;\n\n this.sums.addScaledOuterProductInPlace(vectorA, vectorA, r1_12);\n this.sums.addScaledOuterProductInPlace(vectorA, vectorB, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorA, vectorC, r1_24);\n\n this.sums.addScaledOuterProductInPlace(vectorB, vectorA, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorB, r1_12);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorC, r1_24);\n\n this.sums.addScaledOuterProductInPlace(vectorC, vectorA, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorC, vectorB, r1_24);\n this.sums.addScaledOuterProductInPlace(vectorC, vectorC, r1_12);\n }\n }\n /** Add scaled outer product of (4d, unit weight) point to `this.sums`. */\n public accumulateScaledOuterProduct(point: XYAndZ, scaleFactor: number) {\n this.setOriginXYZIfNeeded(point.x, point.y, 0.0);\n const vectorA = MomentData._vectorA = Point4d.create(\n point.x - this.origin.x, point.y - this.origin.y, point.z - this.origin.z, 1.0, MomentData._vectorA,\n );\n this.sums.addScaledOuterProductInPlace(vectorA, vectorA, scaleFactor);\n }\n /** Accumulate wire moment integral from pointA to pointB */\n public accumulateLineMomentsXYZ(pointA: Point3d, pointB: Point3d) {\n this.setOriginXYZIfNeeded(pointA.x, pointA.y, pointA.z);\n const x0 = this.origin.x;\n const y0 = this.origin.y;\n const z0 = this.origin.z;\n const vectorA = MomentData._vectorA = Point4d.create(\n pointA.x - x0, pointA.y - y0, pointA.z - z0, 1.0, MomentData._vectorA,\n );\n const vectorB = MomentData._vectorB = Point4d.create(\n pointB.x - x0, pointB.y - y0, pointB.z - z0, 1.0, MomentData._vectorB,\n );\n const detJ = pointA.distance(pointB);\n const r1_3 = detJ / 3.0;\n const r1_6 = detJ / 6.0;\n this.sums.addScaledOuterProductInPlace(vectorA, vectorA, r1_3);\n this.sums.addScaledOuterProductInPlace(vectorA, vectorB, r1_6);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorA, r1_6);\n this.sums.addScaledOuterProductInPlace(vectorB, vectorB, r1_3);\n }\n /**\n * Compute moments of triangles from a base point to the given linestring. Accumulate them to `this.sums`.\n * * If `this.needOrigin` is set, `this.origin` is set to the first point of the array.\n * * If `sweepBase` is undefined, use `this.origin` as `sweepBase`.\n */\n public accumulateTriangleToLineStringMomentsXY(sweepBase: XAndY | undefined, points: GrowableXYZArray) {\n const n = points.length;\n if (n > 1) {\n points.getPoint3dAtUncheckedPointIndex(0, this._point0);\n // The linestring forms a polygon with sweepBase. Integrate over this polygon using Shoelace algorithm.\n for (let i = 1; i < n; i++) {\n points.getPoint3dAtUncheckedPointIndex(i, this._point1);\n this.accumulateTriangleMomentsXY(sweepBase, this._point0, this._point1);\n this._point0.setFromPoint3d(this._point1);\n }\n }\n }\n /**\n * Assemble XX, YY, XY products into a full matrix form [xx,xy,0,0; xy,yy,0,0; 0,0,0,0; 0,0,0,1].\n * * Sandwich this between transforms with columns [vectorU, vectorV, 0000, origin].\n * (column weights 0001; only xy parts of vectors).\n * * Scale by detJ for the xy-only determinant of the vectors.\n * @param productXX\n * @param productXY\n * @param productYY\n * @param area area in caller's system.\n * @param origin caller's origin.\n * @param vectorU caller's U axis (not necessarily unit).\n * @param vectorV caller's V axis (not necessarily unit).\n */\n public accumulateXYProductsInCentroidalFrame(\n productXX: number, productXY: number, productYY: number,\n area: number, origin: XAndY, vectorU: XAndY, vectorV: XAndY,\n ) {\n const centroidalProducts = Matrix4d.createRowValues(\n productXX, productXY, 0, 0,\n productXY, productYY, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, area,\n );\n const detJ = Geometry.crossProductXYXY(vectorU.x, vectorV.x, vectorU.y, vectorV.y);\n const placement = Matrix4d.createRowValues(\n vectorU.x, vectorV.x, 0, origin.x - this.origin.x,\n vectorU.y, vectorV.y, 0, origin.y - this.origin.y,\n 0, 0, 0, 0,\n 0, 0, 0, 1,\n );\n const AB = placement.multiplyMatrixMatrix(centroidalProducts);\n const ABAT = AB.multiplyMatrixMatrixTranspose(placement);\n this.sums.addScaledInPlace(ABAT, detJ);\n }\n /**\n * Accumulate sums from other moments.\n * * Scale by given scaleFactor (e.g. sign to correct orientation).\n * * Pull the origin from `other` if `this` needs an origin.\n */\n public accumulateProducts(other: MomentData, scale: number) {\n this.setOriginIfNeeded(other.origin);\n this.sums.addTranslationSandwichInPlace(\n other.sums, this.origin.x - other.origin.x, this.origin.y - other.origin.y, this.origin.z - other.origin.z, scale,\n );\n }\n /**\n * Accumulate sums from Matrix4d and origin.\n * * Scale by given scaleFactor (e.g. sign to correct orientation).\n * * Trap the origin if `this` needs an origin.\n */\n public accumulateProductsFromOrigin(origin: Point3d, products: Matrix4d, scale: number) {\n this.setOriginIfNeeded(origin);\n this.sums.addTranslationSandwichInPlace(\n products, this.origin.x - origin.x, this.origin.y - origin.y, this.origin.z - origin.z, scale,\n );\n }\n /** Convert to a json data object. */\n public toJSON(): any {\n return {\n origin: this.origin,\n sums: this.sums.toJSON(),\n radiusOfGyration: this.radiusOfGyration.toJSON(),\n localToWorld: this.localToWorldMap.toJSON(),\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-geometry",
|
|
3
|
-
"version": "5.1.0-dev.
|
|
3
|
+
"version": "5.1.0-dev.4",
|
|
4
4
|
"description": "iTwin.js Core Geometry library",
|
|
5
5
|
"main": "lib/cjs/core-geometry.js",
|
|
6
6
|
"module": "lib/esm/core-geometry.js",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"rimraf": "^6.0.1",
|
|
32
32
|
"typescript": "~5.6.2",
|
|
33
33
|
"vitest": "^3.0.6",
|
|
34
|
-
"@itwin/build-tools": "5.1.0-dev.
|
|
34
|
+
"@itwin/build-tools": "5.1.0-dev.4"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"flatbuffers": "~1.12.0",
|
|
38
|
-
"@itwin/core-bentley": "5.1.0-dev.
|
|
38
|
+
"@itwin/core-bentley": "5.1.0-dev.4"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "npm run -s build:cjs && npm run -s build:esm",
|