@itwin/core-geometry 5.1.0-dev.1 → 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
|
@@ -28,8 +28,8 @@ const Point4d_1 = require("./Point4d");
|
|
|
28
28
|
* * e.g. entry 03 is summed x.
|
|
29
29
|
* * In this level:
|
|
30
30
|
* * the `absoluteQuantity` member is undefined.
|
|
31
|
-
* * the `localToWorldMap` and `radiiOfGyration` are created
|
|
32
|
-
* * Second level: after a call to inertiaProductsToPrincipalAxes
|
|
31
|
+
* * the `localToWorldMap` and `radiiOfGyration` are created but have undefined contents.
|
|
32
|
+
* * Second level: after a call to `inertiaProductsToPrincipalAxes`, the `localToWorldMap`, `absoluteQuantity` and
|
|
33
33
|
* `radiiOfGyration` are filled in.
|
|
34
34
|
* @public
|
|
35
35
|
*/
|
|
@@ -49,18 +49,35 @@ class MomentData {
|
|
|
49
49
|
* * This set up with its inverse already constructed.
|
|
50
50
|
*/
|
|
51
51
|
localToWorldMap;
|
|
52
|
+
/** Radii of gyration (square roots of principal second moments). */
|
|
53
|
+
radiusOfGyration;
|
|
54
|
+
/**
|
|
55
|
+
* Principal quantity (e.g. length, area, or volume). This is undefined in raw moments, and becomes defined by
|
|
56
|
+
* inertiaProductsToPrincipalAxes.
|
|
57
|
+
*/
|
|
58
|
+
absoluteQuantity;
|
|
52
59
|
// private variables
|
|
53
60
|
static _vectorA;
|
|
54
61
|
static _vectorB;
|
|
55
62
|
static _vectorC;
|
|
56
63
|
_point0 = Point3dVector3d_1.Point3d.create();
|
|
57
64
|
_point1 = Point3dVector3d_1.Point3d.create();
|
|
65
|
+
/** Constructor. */
|
|
66
|
+
constructor() {
|
|
67
|
+
this.origin = Point3dVector3d_1.Point3d.createZero();
|
|
68
|
+
this.needOrigin = false;
|
|
69
|
+
this.sums = Matrix4d_1.Matrix4d.createZero();
|
|
70
|
+
this.localToWorldMap = Transform_1.Transform.createIdentity();
|
|
71
|
+
this.radiusOfGyration = Point3dVector3d_1.Vector3d.create();
|
|
72
|
+
this.absoluteQuantity = 0.1; // so optimizer sees its type
|
|
73
|
+
this.absoluteQuantity = undefined;
|
|
74
|
+
}
|
|
58
75
|
/**
|
|
59
76
|
* Return the lower-right (3,3) entry in the sums.
|
|
60
77
|
* * This is the quantity (i.e. length, area, or volume) summed.
|
|
61
78
|
*/
|
|
62
79
|
get quantitySum() {
|
|
63
|
-
return this.sums.
|
|
80
|
+
return this.sums.weight();
|
|
64
81
|
}
|
|
65
82
|
/**
|
|
66
83
|
* Return a scale factor to make these sums match the target orientation sign.
|
|
@@ -91,23 +108,6 @@ class MomentData {
|
|
|
91
108
|
this.needOrigin = false;
|
|
92
109
|
}
|
|
93
110
|
}
|
|
94
|
-
/** Radii of gyration (square roots of principal second moments). */
|
|
95
|
-
radiusOfGyration;
|
|
96
|
-
/**
|
|
97
|
-
* Principal quantity (e.g. length, area, or volume). This is undefined in raw moments, and becomes defined by
|
|
98
|
-
* inertiaProductsToPrincipalAxes.
|
|
99
|
-
*/
|
|
100
|
-
absoluteQuantity;
|
|
101
|
-
/** Constructor. */
|
|
102
|
-
constructor() {
|
|
103
|
-
this.origin = Point3dVector3d_1.Point3d.createZero();
|
|
104
|
-
this.sums = Matrix4d_1.Matrix4d.createZero();
|
|
105
|
-
this.localToWorldMap = Transform_1.Transform.createIdentity();
|
|
106
|
-
this.radiusOfGyration = Point3dVector3d_1.Vector3d.create();
|
|
107
|
-
this.needOrigin = false;
|
|
108
|
-
this.absoluteQuantity = 0.1; // so optimizer sees its type
|
|
109
|
-
this.absoluteQuantity = undefined;
|
|
110
|
-
}
|
|
111
111
|
/**
|
|
112
112
|
* Create moments with optional origin.
|
|
113
113
|
* * Origin and needOrigin are quirky.
|
|
@@ -151,7 +151,7 @@ class MomentData {
|
|
|
151
151
|
axes.setColumnsPoint4dXYZ(points[0], points[1], points[2]);
|
|
152
152
|
if (axes.determinant() < 0)
|
|
153
153
|
axes.scaleColumnsInPlace(-1.0, -1.0, -1.0);
|
|
154
|
-
// prefer x and z positive
|
|
154
|
+
// prefer x and z positive; y falls wherever
|
|
155
155
|
if (axes.at(0, 0) < 0.0)
|
|
156
156
|
axes.scaleColumnsInPlace(-1.0, -1.0, 1.0);
|
|
157
157
|
if (axes.at(2, 2) < 0.0)
|
|
@@ -176,7 +176,8 @@ class MomentData {
|
|
|
176
176
|
* * Hence x axis is long direction.
|
|
177
177
|
* * Hence planar data generates large moment as Z.
|
|
178
178
|
* @param origin The origin used for the inertia products.
|
|
179
|
-
* @param inertiaProducts The inertia products: sums or integrals of
|
|
179
|
+
* @param inertiaProducts The inertia products: sums or integrals of
|
|
180
|
+
* [xx,xy,xz,xw; yx,yy,yz,yw; zx,zy,zz,zw; wx,wy,wz,w].
|
|
180
181
|
*/
|
|
181
182
|
static inertiaProductsToPrincipalAxes(origin, inertiaProducts) {
|
|
182
183
|
const moments = new MomentData();
|
|
@@ -220,23 +221,21 @@ class MomentData {
|
|
|
220
221
|
*/
|
|
221
222
|
static areEquivalentPrincipalAxes(dataA, dataB) {
|
|
222
223
|
if (dataA && dataB
|
|
223
|
-
&& Geometry_1.Geometry.isSameCoordinate(dataA.quantitySum, dataB.quantitySum)) { //
|
|
224
|
+
&& Geometry_1.Geometry.isSameCoordinate(dataA.quantitySum, dataB.quantitySum)) { // TODO: need different tolerance for area, volume?
|
|
224
225
|
if (dataA.localToWorldMap.getOrigin().isAlmostEqual(dataB.localToWorldMap.getOrigin())
|
|
225
226
|
&& dataA.radiusOfGyration.isAlmostEqual(dataB.radiusOfGyration)) {
|
|
226
227
|
if (Geometry_1.Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.y)) {
|
|
227
|
-
//
|
|
228
|
+
// we have at least xy symmetry
|
|
228
229
|
if (Geometry_1.Geometry.isSameCoordinate(dataA.radiusOfGyration.x, dataA.radiusOfGyration.z))
|
|
229
230
|
return true;
|
|
230
|
-
// just xy
|
|
231
|
-
// allow opposite z directions.
|
|
232
|
-
// If the z's are aligned, x an dy can spin freely.
|
|
231
|
+
// just xy; allow opposite z directions; if the z's are aligned, x and y can spin freely
|
|
233
232
|
const zA = dataA.localToWorldMap.matrix.columnZ();
|
|
234
233
|
const zB = dataB.localToWorldMap.matrix.columnZ();
|
|
235
234
|
if (zA.isParallelTo(zB, true))
|
|
236
235
|
return true;
|
|
237
236
|
return false;
|
|
238
237
|
}
|
|
239
|
-
// no symmetry
|
|
238
|
+
// no symmetry; test all three axes
|
|
240
239
|
const vectorA = Point3dVector3d_1.Vector3d.create();
|
|
241
240
|
const vectorB = Point3dVector3d_1.Vector3d.create();
|
|
242
241
|
for (let i = 0; i < 3; i++) {
|
|
@@ -266,7 +265,7 @@ class MomentData {
|
|
|
266
265
|
}
|
|
267
266
|
/** Revise the accumulated sums to be "around the centroid". */
|
|
268
267
|
shiftOriginAndSumsToCentroidOfSums() {
|
|
269
|
-
const xyz = this.sums.columnW().realPoint();
|
|
268
|
+
const xyz = this.sums.columnW().realPoint(); // centroid of the geometry
|
|
270
269
|
if (xyz) {
|
|
271
270
|
this.shiftOriginAndSumsByXYZ(xyz.x, xyz.y, xyz.z);
|
|
272
271
|
return true;
|
|
@@ -275,9 +274,9 @@ class MomentData {
|
|
|
275
274
|
}
|
|
276
275
|
/**
|
|
277
276
|
* Revise the accumulated sums.
|
|
278
|
-
* *
|
|
279
|
-
* *
|
|
280
|
-
|
|
277
|
+
* * Add (ax,ay,az) to the origin coordinates.
|
|
278
|
+
* * Apply the negative translation to the sums.
|
|
279
|
+
*/
|
|
281
280
|
shiftOriginAndSumsByXYZ(ax, ay, az) {
|
|
282
281
|
this.origin.addXYZInPlace(ax, ay, az);
|
|
283
282
|
this.sums.multiplyTranslationSandwichInPlace(-ax, -ay, -az);
|
|
@@ -287,23 +286,24 @@ class MomentData {
|
|
|
287
286
|
this.shiftOriginAndSumsByXYZ(newOrigin.x - this.origin.x, newOrigin.y - this.origin.y, newOrigin.z - this.origin.z);
|
|
288
287
|
}
|
|
289
288
|
/**
|
|
290
|
-
* Compute moments of a triangle from the origin
|
|
291
|
-
*
|
|
292
|
-
* * If `pointA` is undefined, use `this.origin` as pointA
|
|
293
|
-
|
|
294
|
-
*/
|
|
289
|
+
* Compute moments of a triangle from the origin. Accumulate them to `this.sums`.
|
|
290
|
+
* * If `this.needOrigin` is set, `this.origin` is set to `pointB`.
|
|
291
|
+
* * If `pointA` is undefined, use `this.origin` as `pointA`.
|
|
292
|
+
*/
|
|
295
293
|
accumulateTriangleMomentsXY(pointA, pointB, pointC) {
|
|
296
294
|
this.setOriginXYZIfNeeded(pointB.x, pointB.y, 0.0);
|
|
297
295
|
const x0 = this.origin.x;
|
|
298
296
|
const y0 = this.origin.y;
|
|
299
|
-
const vectorA = MomentData._vectorA =
|
|
300
|
-
|
|
301
|
-
|
|
297
|
+
const vectorA = MomentData._vectorA = (pointA !== undefined) ?
|
|
298
|
+
Point4d_1.Point4d.create(pointA.x - x0, pointA.y - y0, 0.0, 1.0, MomentData._vectorA) :
|
|
299
|
+
Point4d_1.Point4d.create(0.0, 0.0, 0.0, 1.0, MomentData._vectorA);
|
|
302
300
|
const vectorB = MomentData._vectorB = Point4d_1.Point4d.create(pointB.x - x0, pointB.y - y0, 0.0, 1.0, MomentData._vectorB);
|
|
303
301
|
const vectorC = MomentData._vectorC = Point4d_1.Point4d.create(pointC.x - x0, pointC.y - y0, 0.0, 1.0, MomentData._vectorC);
|
|
304
|
-
//
|
|
305
|
-
//
|
|
306
|
-
//
|
|
302
|
+
// Below we calculate 16 double integrals: \iint_T [x y 0 1]^ [x y 0 1] dT over triangle T=(A,B,C).
|
|
303
|
+
// Each accumulates contributions from 9 scaled outer products. Integration computations use the barycentric
|
|
304
|
+
// change of variables [B-A C-A][u,v]^ = [x,y]^ with Jacobian detJ = B-A x C-A = twice the area of T.
|
|
305
|
+
// This converts the integration domain from T to the triangle bounded by u=0, v=0 and v=1-u, yielding e.g.,
|
|
306
|
+
// \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.
|
|
307
307
|
const detJ = Geometry_1.Geometry.crossProductXYXY(vectorB.x - vectorA.x, vectorB.y - vectorA.y, vectorC.x - vectorA.x, vectorC.y - vectorA.y);
|
|
308
308
|
if (detJ !== 0.0) {
|
|
309
309
|
const r1_12 = detJ / 12.0;
|
|
@@ -319,7 +319,7 @@ class MomentData {
|
|
|
319
319
|
this.sums.addScaledOuterProductInPlace(vectorC, vectorC, r1_12);
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
-
/** Add scaled outer product of (4d, unit weight) point to this.sums
|
|
322
|
+
/** Add scaled outer product of (4d, unit weight) point to `this.sums`. */
|
|
323
323
|
accumulateScaledOuterProduct(point, scaleFactor) {
|
|
324
324
|
this.setOriginXYZIfNeeded(point.x, point.y, 0.0);
|
|
325
325
|
const vectorA = MomentData._vectorA = Point4d_1.Point4d.create(point.x - this.origin.x, point.y - this.origin.y, point.z - this.origin.z, 1.0, MomentData._vectorA);
|
|
@@ -342,16 +342,15 @@ class MomentData {
|
|
|
342
342
|
this.sums.addScaledOuterProductInPlace(vectorB, vectorB, r1_3);
|
|
343
343
|
}
|
|
344
344
|
/**
|
|
345
|
-
* Compute moments of triangles from a base point to the given linestring.
|
|
346
|
-
*
|
|
347
|
-
* * If `
|
|
348
|
-
* * If `this.needOrigin` is set, the first point of the array is captured as local origin for subsequent sums.
|
|
349
|
-
*
|
|
345
|
+
* Compute moments of triangles from a base point to the given linestring. Accumulate them to `this.sums`.
|
|
346
|
+
* * If `this.needOrigin` is set, `this.origin` is set to the first point of the array.
|
|
347
|
+
* * If `sweepBase` is undefined, use `this.origin` as `sweepBase`.
|
|
350
348
|
*/
|
|
351
349
|
accumulateTriangleToLineStringMomentsXY(sweepBase, points) {
|
|
352
350
|
const n = points.length;
|
|
353
351
|
if (n > 1) {
|
|
354
352
|
points.getPoint3dAtUncheckedPointIndex(0, this._point0);
|
|
353
|
+
// The linestring forms a polygon with sweepBase. Integrate over this polygon using Shoelace algorithm.
|
|
355
354
|
for (let i = 1; i < n; i++) {
|
|
356
355
|
points.getPoint3dAtUncheckedPointIndex(i, this._point1);
|
|
357
356
|
this.accumulateTriangleMomentsXY(sweepBase, this._point0, this._point1);
|
|
@@ -360,17 +359,17 @@ class MomentData {
|
|
|
360
359
|
}
|
|
361
360
|
}
|
|
362
361
|
/**
|
|
363
|
-
*
|
|
364
|
-
* * Sandwich this between transforms with columns [vectorU, vectorV, 0000, origin].
|
|
365
|
-
* parts of vectors).
|
|
366
|
-
* *
|
|
362
|
+
* 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].
|
|
363
|
+
* * Sandwich this between transforms with columns [vectorU, vectorV, 0000, origin].
|
|
364
|
+
* (column weights 0001; only xy parts of vectors).
|
|
365
|
+
* * Scale by detJ for the xy-only determinant of the vectors.
|
|
367
366
|
* @param productXX
|
|
368
367
|
* @param productXY
|
|
369
368
|
* @param productYY
|
|
370
|
-
* @param area
|
|
371
|
-
* @param origin
|
|
372
|
-
* @param vectorU
|
|
373
|
-
* @param vectorV
|
|
369
|
+
* @param area area in caller's system.
|
|
370
|
+
* @param origin caller's origin.
|
|
371
|
+
* @param vectorU caller's U axis (not necessarily unit).
|
|
372
|
+
* @param vectorV caller's V axis (not necessarily unit).
|
|
374
373
|
*/
|
|
375
374
|
accumulateXYProductsInCentroidalFrame(productXX, productXY, productYY, area, origin, vectorU, vectorV) {
|
|
376
375
|
const centroidalProducts = Matrix4d_1.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,0CAAuC;AAEvC,qDAAkD;AAClD,mEAAuE;AACvE,uDAAoD;AAEpD,yCAAsC;AACtC,uCAAoC;AAEpC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,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,yBAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,yBAAO,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,CAAC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IAED;;;;OAIG;IACI,4BAA4B,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;AAtZD,gCAsZC","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,mBA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,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE;YAChD,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;SAC5C,CAAC;IACJ,CAAC;CACF;AAtZD,gCAsZC","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"]}
|
|
@@ -21,41 +21,34 @@ export declare class RegionMomentsXY extends NullGeometryHandler {
|
|
|
21
21
|
private _activeMomentData?;
|
|
22
22
|
private _point0;
|
|
23
23
|
private _point1;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* *
|
|
24
|
+
/**
|
|
25
|
+
* Accumulate (independent) integrations over:
|
|
26
|
+
* * The area between the arc and the chord connecting its endpoints.
|
|
27
|
+
* * The triangle with vertices: origin, arc start, arc end.
|
|
27
28
|
*/
|
|
28
29
|
handleArc3d(arc: Arc3d): void;
|
|
29
|
-
/** Accumulate integrals over the (triangular) areas from the origin to each line segment */
|
|
30
|
+
/** Accumulate integrals over the (triangular) areas from the origin to each line segment. */
|
|
30
31
|
handleLineString3d(ls: LineString3d): void;
|
|
31
|
-
/** Accumulate integrals over the (triangular) area from the origin to this line segment */
|
|
32
|
+
/** Accumulate integrals over the (triangular) area from the origin to this line segment. */
|
|
32
33
|
handleLineSegment3d(segment: LineSegment3d): void;
|
|
33
34
|
/** Accumulate integrals from origin to all primitives in the chain. */
|
|
34
35
|
handleLoop(loop: Loop): MomentData | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* ASSUMPTIONS FOR ORIENTATION AND CONTAINMENT ISSUES
|
|
37
|
-
* * Largest area is outer
|
|
38
|
-
* * All others are interior (and not overlapping)
|
|
39
|
-
* Hence
|
|
40
|
-
* * Outer area sign must be positive -- negate all integrations as needed
|
|
41
|
-
* * Outer area signs must be positive -- negate all integrations as needed
|
|
42
|
-
* @param region
|
|
43
|
-
*/
|
|
36
|
+
/** Accumulate integrals from origin to the components of the parity region. */
|
|
44
37
|
handleParityRegion(region: ParityRegion): MomentData | undefined;
|
|
45
|
-
/** Accumulate
|
|
38
|
+
/** Accumulate integrals from origin to the components of the union region. */
|
|
46
39
|
handleUnionRegion(region: UnionRegion): MomentData | undefined;
|
|
47
40
|
private _strokeOptions?;
|
|
48
41
|
private getStrokeOptions;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* * accumulate stroke array.
|
|
42
|
+
/**
|
|
43
|
+
* Handle a single curve primitive (not loop).
|
|
44
|
+
* * Stroke the curve and accumulate stroke array.
|
|
52
45
|
*/
|
|
53
46
|
handleCurvePrimitive(cp: CurvePrimitive): void;
|
|
54
|
-
/**
|
|
47
|
+
/** Handle strongly typed BSplineCurve3d as generic curve primitive. */
|
|
55
48
|
handleBSplineCurve3d(g: BSplineCurve3d): void;
|
|
56
|
-
/**
|
|
49
|
+
/** Handle strongly typed BSplineCurve3dH as generic curve primitive. */
|
|
57
50
|
handleBSplineCurve3dH(g: BSplineCurve3dH): void;
|
|
58
|
-
/**
|
|
51
|
+
/** Handle strongly typed TransitionSpiral as generic curve primitive. */
|
|
59
52
|
handleTransitionSpiral(g: TransitionSpiral3d): void;
|
|
60
53
|
}
|
|
61
54
|
//# sourceMappingURL=RegionMomentsXY.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionMomentsXY.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":"AAKA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,mBAAmB;IACtD,OAAO,CAAC,iBAAiB,CAAC,CAAa;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAoB;
|
|
1
|
+
{"version":3,"file":"RegionMomentsXY.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":"AAKA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC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ACzD,oBAAoB,CAAC,CAAC,EAAE,cAAc;IAGtD,0EAA0E;IAC1D,qBAAqB,CAAC,CAAC,EAAE,eAAe;IAGxD,0EAA0E;IAC1D,sBAAsB,CAAC,CAAC,EAAE,kBAAkB;CAG7D"}
|
|
@@ -17,15 +17,15 @@ export class RegionMomentsXY extends NullGeometryHandler {
|
|
|
17
17
|
_activeMomentData;
|
|
18
18
|
_point0 = Point3d.create();
|
|
19
19
|
_point1 = Point3d.create();
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* *
|
|
20
|
+
/**
|
|
21
|
+
* Accumulate (independent) integrations over:
|
|
22
|
+
* * The area between the arc and the chord connecting its endpoints.
|
|
23
|
+
* * The triangle with vertices: origin, arc start, arc end.
|
|
23
24
|
*/
|
|
24
25
|
handleArc3d(arc) {
|
|
25
26
|
const momentData = this._activeMomentData;
|
|
26
27
|
const sweepRadians = arc.sweep.sweepRadians;
|
|
27
28
|
const alphaRadians = sweepRadians * 0.5;
|
|
28
|
-
// from https://apps.dtic.mil/dtic/tr/fulltext/u2/274936.pdf page 71 for radius = 1
|
|
29
29
|
let s = Math.sin(alphaRadians);
|
|
30
30
|
let c = Math.cos(alphaRadians);
|
|
31
31
|
let s1 = Math.sin(sweepRadians);
|
|
@@ -52,12 +52,12 @@ export class RegionMomentsXY extends NullGeometryHandler {
|
|
|
52
52
|
const pointC = arc.fractionToPoint(1.0);
|
|
53
53
|
momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);
|
|
54
54
|
}
|
|
55
|
-
/** Accumulate integrals over the (triangular) areas from the origin to each line segment */
|
|
55
|
+
/** Accumulate integrals over the (triangular) areas from the origin to each line segment. */
|
|
56
56
|
handleLineString3d(ls) {
|
|
57
57
|
const momentData = this._activeMomentData;
|
|
58
58
|
momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);
|
|
59
59
|
}
|
|
60
|
-
/** Accumulate integrals over the (triangular) area from the origin to this line segment */
|
|
60
|
+
/** Accumulate integrals over the (triangular) area from the origin to this line segment. */
|
|
61
61
|
handleLineSegment3d(segment) {
|
|
62
62
|
const momentData = this._activeMomentData;
|
|
63
63
|
segment.startPoint(this._point0);
|
|
@@ -73,15 +73,7 @@ export class RegionMomentsXY extends NullGeometryHandler {
|
|
|
73
73
|
this._activeMomentData = undefined;
|
|
74
74
|
return momentData;
|
|
75
75
|
}
|
|
76
|
-
/**
|
|
77
|
-
* ASSUMPTIONS FOR ORIENTATION AND CONTAINMENT ISSUES
|
|
78
|
-
* * Largest area is outer
|
|
79
|
-
* * All others are interior (and not overlapping)
|
|
80
|
-
* Hence
|
|
81
|
-
* * Outer area sign must be positive -- negate all integrations as needed
|
|
82
|
-
* * Outer area signs must be positive -- negate all integrations as needed
|
|
83
|
-
* @param region
|
|
84
|
-
*/
|
|
76
|
+
/** Accumulate integrals from origin to the components of the parity region. */
|
|
85
77
|
handleParityRegion(region) {
|
|
86
78
|
const allChildMoments = [];
|
|
87
79
|
let maxAbsArea = 0.0;
|
|
@@ -113,7 +105,7 @@ export class RegionMomentsXY extends NullGeometryHandler {
|
|
|
113
105
|
}
|
|
114
106
|
return undefined;
|
|
115
107
|
}
|
|
116
|
-
/** Accumulate
|
|
108
|
+
/** Accumulate integrals from origin to the components of the union region. */
|
|
117
109
|
handleUnionRegion(region) {
|
|
118
110
|
const summedMoments = MomentData.create();
|
|
119
111
|
for (const child of region.children) {
|
|
@@ -135,9 +127,9 @@ export class RegionMomentsXY extends NullGeometryHandler {
|
|
|
135
127
|
this._strokeOptions = options;
|
|
136
128
|
return options;
|
|
137
129
|
}
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
* * accumulate stroke array.
|
|
130
|
+
/**
|
|
131
|
+
* Handle a single curve primitive (not loop).
|
|
132
|
+
* * Stroke the curve and accumulate stroke array.
|
|
141
133
|
*/
|
|
142
134
|
handleCurvePrimitive(cp) {
|
|
143
135
|
const strokes = LineString3d.create();
|
|
@@ -145,11 +137,17 @@ export class RegionMomentsXY extends NullGeometryHandler {
|
|
|
145
137
|
cp.emitStrokes(strokes, options);
|
|
146
138
|
this.handleLineString3d(strokes);
|
|
147
139
|
}
|
|
148
|
-
/**
|
|
149
|
-
handleBSplineCurve3d(g) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
|
|
140
|
+
/** Handle strongly typed BSplineCurve3d as generic curve primitive. */
|
|
141
|
+
handleBSplineCurve3d(g) {
|
|
142
|
+
return this.handleCurvePrimitive(g);
|
|
143
|
+
}
|
|
144
|
+
/** Handle strongly typed BSplineCurve3dH as generic curve primitive. */
|
|
145
|
+
handleBSplineCurve3dH(g) {
|
|
146
|
+
return this.handleCurvePrimitive(g);
|
|
147
|
+
}
|
|
148
|
+
/** Handle strongly typed TransitionSpiral as generic curve primitive. */
|
|
149
|
+
handleTransitionSpiral(g) {
|
|
150
|
+
return this.handleCurvePrimitive(g);
|
|
151
|
+
}
|
|
154
152
|
}
|
|
155
153
|
//# sourceMappingURL=RegionMomentsXY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionMomentsXY.js","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAU/F,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,OAAO,CAAC,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AAM,OAAO,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,wEAAwE;IACxD,oBAAoB,CAAC,CAAiB,IAAI,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChG,yEAAyE;IACzD,qBAAqB,CAAC,CAAkB,IAAI,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClG,0EAA0E;IAC1D,sBAAsB,CAAC,CAAqB,IAAI,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAEvG","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 Curve\n */\n\n// import { Geometry, Angle, AngleSweep } from \"../Geometry\";\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../bspline/BSplineCurve3dH\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { NullGeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { MomentData } from \"../geometry4d/MomentData\";\nimport { Arc3d } from \"./Arc3d\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { LineSegment3d } from \"./LineSegment3d\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Loop } from \"./Loop\";\nimport { ParityRegion } from \"./ParityRegion\";\nimport { StrokeOptions } from \"./StrokeOptions\";\nimport { TransitionSpiral3d } from \"./spiral/TransitionSpiral3d\";\nimport { UnionRegion } from \"./UnionRegion\";\n\n/**\n * Implementation class for computing XY area moments.\n * @internal\n */\nexport class RegionMomentsXY extends NullGeometryHandler {\n private _activeMomentData?: MomentData;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n\n /** Accumulate (independent) integrations over\n * * origin to chord of the arc.\n * * origin to the \"cap\" between the chord and arc.\n */\n public override handleArc3d(arc: Arc3d): void {\n const momentData = this._activeMomentData!;\n const sweepRadians = arc.sweep.sweepRadians;\n const alphaRadians = sweepRadians * 0.5;\n // from https://apps.dtic.mil/dtic/tr/fulltext/u2/274936.pdf page 71 for radius = 1\n let s = Math.sin(alphaRadians);\n let c = Math.cos(alphaRadians);\n let s1 = Math.sin(sweepRadians);\n if (Angle.isFullCircleRadians(sweepRadians)) {\n s = 0.0;\n c = -1.0;\n s1 = 0.0;\n }\n const q = 2 * s * s * s * c / (alphaRadians - s * c);\n const s3 = s * s * s;\n const s6 = s3 * s3;\n const area = 0.5 * (sweepRadians - s1);\n const inertiaXX = 0.25 * area * (1.0 - q / 3.0);\n const inertiaYY1 = 0.25 * area * (1.0 + q);\n const inertiaYY = inertiaYY1 - 4.0 * s6 / (9.0 * area);\n const productXX = inertiaYY;\n const productYY = inertiaXX;\n const centerToCentroid = 4.0 * s * s * s / (3.0 * (sweepRadians - s1));\n const midRadians = arc.sweep.fractionToRadians(0.5);\n const centralPlane = arc.radiansToRotatedBasis(midRadians);\n const centroid = centralPlane.origin.plusScaled(centralPlane.vectorU, centerToCentroid);\n momentData.accumulateXYProductsInCentroidalFrame(productXX, 0.0, productYY, area, centroid, centralPlane.vectorU, centralPlane.vectorV);\n const pointB = arc.fractionToPoint(0.0);\n const pointC = arc.fractionToPoint(1.0);\n momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);\n }\n\n /** Accumulate integrals over the (triangular) areas from the origin to each line segment */\n public override handleLineString3d(ls: LineString3d): void {\n const momentData = this._activeMomentData!;\n momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);\n }\n /** Accumulate integrals over the (triangular) area from the origin to this line segment */\n public override handleLineSegment3d(segment: LineSegment3d): void {\n const momentData = this._activeMomentData!;\n segment.startPoint(this._point0);\n segment.endPoint(this._point1);\n momentData.accumulateTriangleMomentsXY(undefined, this._point0, this._point1);\n }\n /** Accumulate integrals from origin to all primitives in the chain. */\n public override handleLoop(loop: Loop): MomentData | undefined {\n const momentData = this._activeMomentData = MomentData.create();\n momentData.needOrigin = false;\n for (const child of loop.children)\n child.dispatchToGeometryHandler(this);\n this._activeMomentData = undefined;\n return momentData;\n }\n /**\n * ASSUMPTIONS FOR ORIENTATION AND CONTAINMENT ISSUES\n * * Largest area is outer\n * * All others are interior (and not overlapping)\n * Hence\n * * Outer area sign must be positive -- negate all integrations as needed\n * * Outer area signs must be positive -- negate all integrations as needed\n * @param region\n */\n public override handleParityRegion(region: ParityRegion): MomentData | undefined {\n const allChildMoments: MomentData[] = [];\n let maxAbsArea = 0.0;\n let largestChildMoments: MomentData | undefined;\n for (const child of region.children) {\n if (child instanceof Loop) {\n const childMoments = this.handleLoop(child);\n if (childMoments) {\n allChildMoments.push(childMoments);\n const q = Math.abs(childMoments.quantitySum);\n if (q > maxAbsArea) {\n maxAbsArea = q;\n largestChildMoments = childMoments;\n }\n\n }\n }\n }\n if (largestChildMoments) {\n const summedMoments = MomentData.create();\n const sign0 = largestChildMoments.signFactor(1.0);\n summedMoments.accumulateProducts(largestChildMoments, sign0);\n for (const childMoments of allChildMoments) {\n if (childMoments !== largestChildMoments) {\n const sign1 = childMoments.signFactor(-1.0);\n summedMoments.accumulateProducts(childMoments, sign1);\n }\n }\n return summedMoments;\n }\n return undefined;\n }\n /** Accumulate (as simple addition) products over each component of the union region. */\n public override handleUnionRegion(region: UnionRegion): MomentData | undefined {\n const summedMoments = MomentData.create();\n for (const child of region.children) {\n const childMoments = child.dispatchToGeometryHandler(this);\n if (childMoments) {\n const sign0 = childMoments.signFactor(1.0);\n summedMoments.accumulateProducts(childMoments, sign0);\n }\n }\n return summedMoments;\n }\n\n private _strokeOptions?: StrokeOptions;\n private getStrokeOptions(): StrokeOptions {\n if (this._strokeOptions)\n return this._strokeOptions;\n const options = StrokeOptions.createForCurves();\n // this is unusually fine for stroking, but appropriate for sum.\n options.angleTol = Angle.createDegrees(5.0);\n this._strokeOptions = options;\n return options;\n }\n /** Single curve primitive (not loop . . .).\n * * stroke the curve\n * * accumulate stroke array.\n */\n public handleCurvePrimitive(cp: CurvePrimitive) {\n const strokes = LineString3d.create();\n const options = this.getStrokeOptions();\n cp.emitStrokes(strokes, options);\n this.handleLineString3d(strokes);\n }\n /** handle strongly typed BSplineCurve3d as generic curve primitive */\n public override handleBSplineCurve3d(g: BSplineCurve3d) { return this.handleCurvePrimitive(g); }\n /** handle strongly typed BSplineCurve3dH as generic curve primitive */\n public override handleBSplineCurve3dH(g: BSplineCurve3dH) { return this.handleCurvePrimitive(g); }\n /** handle strongly typed TransitionSpiral as generic curve primitive */\n public override handleTransitionSpiral(g: TransitionSpiral3d) { return this.handleCurvePrimitive(g); }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RegionMomentsXY.js","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAU/F,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,OAAO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AAG,YAAY,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,yEAAyE;IACzD,oBAAoB,CAAC,CAAiB;QACpD,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,0EAA0E;IAC1D,qBAAqB,CAAC,CAAkB;QACtD,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,0EAA0E;IAC1D,sBAAsB,CAAC,CAAqB;QAC1D,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACtC,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 Curve\n */\n\n// import { Geometry, Angle, AngleSweep } from \"../Geometry\";\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../bspline/BSplineCurve3dH\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { NullGeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { MomentData } from \"../geometry4d/MomentData\";\nimport { Arc3d } from \"./Arc3d\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { LineSegment3d } from \"./LineSegment3d\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Loop } from \"./Loop\";\nimport { ParityRegion } from \"./ParityRegion\";\nimport { StrokeOptions } from \"./StrokeOptions\";\nimport { TransitionSpiral3d } from \"./spiral/TransitionSpiral3d\";\nimport { UnionRegion } from \"./UnionRegion\";\n\n/**\n * Implementation class for computing XY area moments.\n * @internal\n */\nexport class RegionMomentsXY extends NullGeometryHandler {\n private _activeMomentData?: MomentData;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n /**\n * Accumulate (independent) integrations over:\n * * The area between the arc and the chord connecting its endpoints.\n * * The triangle with vertices: origin, arc start, arc end.\n */\n public override handleArc3d(arc: Arc3d): void {\n const momentData = this._activeMomentData!;\n const sweepRadians = arc.sweep.sweepRadians;\n const alphaRadians = sweepRadians * 0.5;\n let s = Math.sin(alphaRadians);\n let c = Math.cos(alphaRadians);\n let s1 = Math.sin(sweepRadians);\n if (Angle.isFullCircleRadians(sweepRadians)) {\n s = 0.0;\n c = -1.0;\n s1 = 0.0;\n }\n const q = 2 * s * s * s * c / (alphaRadians - s * c);\n const s3 = s * s * s;\n const s6 = s3 * s3;\n const area = 0.5 * (sweepRadians - s1);\n const inertiaXX = 0.25 * area * (1.0 - q / 3.0);\n const inertiaYY1 = 0.25 * area * (1.0 + q);\n const inertiaYY = inertiaYY1 - 4.0 * s6 / (9.0 * area);\n const productXX = inertiaYY;\n const productYY = inertiaXX;\n const centerToCentroid = 4.0 * s * s * s / (3.0 * (sweepRadians - s1));\n const midRadians = arc.sweep.fractionToRadians(0.5);\n const centralPlane = arc.radiansToRotatedBasis(midRadians);\n const centroid = centralPlane.origin.plusScaled(centralPlane.vectorU, centerToCentroid);\n momentData.accumulateXYProductsInCentroidalFrame(\n productXX, 0.0, productYY, area, centroid, centralPlane.vectorU, centralPlane.vectorV,\n );\n const pointB = arc.fractionToPoint(0.0);\n const pointC = arc.fractionToPoint(1.0);\n momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);\n }\n /** Accumulate integrals over the (triangular) areas from the origin to each line segment. */\n public override handleLineString3d(ls: LineString3d): void {\n const momentData = this._activeMomentData!;\n momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);\n }\n /** Accumulate integrals over the (triangular) area from the origin to this line segment. */\n public override handleLineSegment3d(segment: LineSegment3d): void {\n const momentData = this._activeMomentData!;\n segment.startPoint(this._point0);\n segment.endPoint(this._point1);\n momentData.accumulateTriangleMomentsXY(undefined, this._point0, this._point1);\n }\n /** Accumulate integrals from origin to all primitives in the chain. */\n public override handleLoop(loop: Loop): MomentData | undefined {\n const momentData = this._activeMomentData = MomentData.create();\n momentData.needOrigin = false;\n for (const child of loop.children)\n child.dispatchToGeometryHandler(this);\n this._activeMomentData = undefined;\n return momentData;\n }\n /** Accumulate integrals from origin to the components of the parity region. */\n public override handleParityRegion(region: ParityRegion): MomentData | undefined {\n const allChildMoments: MomentData[] = [];\n let maxAbsArea = 0.0;\n let largestChildMoments: MomentData | undefined;\n for (const child of region.children) {\n if (child instanceof Loop) {\n const childMoments = this.handleLoop(child);\n if (childMoments) {\n allChildMoments.push(childMoments);\n const q = Math.abs(childMoments.quantitySum);\n if (q > maxAbsArea) {\n maxAbsArea = q;\n largestChildMoments = childMoments;\n }\n }\n }\n }\n if (largestChildMoments) {\n const summedMoments = MomentData.create();\n const sign0 = largestChildMoments.signFactor(1.0);\n summedMoments.accumulateProducts(largestChildMoments, sign0);\n for (const childMoments of allChildMoments) {\n if (childMoments !== largestChildMoments) {\n const sign1 = childMoments.signFactor(-1.0);\n summedMoments.accumulateProducts(childMoments, sign1);\n }\n }\n return summedMoments;\n }\n return undefined;\n }\n /** Accumulate integrals from origin to the components of the union region. */\n public override handleUnionRegion(region: UnionRegion): MomentData | undefined {\n const summedMoments = MomentData.create();\n for (const child of region.children) {\n const childMoments = child.dispatchToGeometryHandler(this);\n if (childMoments) {\n const sign0 = childMoments.signFactor(1.0);\n summedMoments.accumulateProducts(childMoments, sign0);\n }\n }\n return summedMoments;\n }\n private _strokeOptions?: StrokeOptions;\n private getStrokeOptions(): StrokeOptions {\n if (this._strokeOptions)\n return this._strokeOptions;\n const options = StrokeOptions.createForCurves();\n // this is unusually fine for stroking, but appropriate for sum.\n options.angleTol = Angle.createDegrees(5.0);\n this._strokeOptions = options;\n return options;\n }\n /**\n * Handle a single curve primitive (not loop).\n * * Stroke the curve and accumulate stroke array.\n */\n public handleCurvePrimitive(cp: CurvePrimitive) {\n const strokes = LineString3d.create();\n const options = this.getStrokeOptions();\n cp.emitStrokes(strokes, options);\n this.handleLineString3d(strokes);\n }\n /** Handle strongly typed BSplineCurve3d as generic curve primitive. */\n public override handleBSplineCurve3d(g: BSplineCurve3d) {\n return this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */\n public override handleBSplineCurve3dH(g: BSplineCurve3dH) {\n return this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed TransitionSpiral as generic curve primitive. */\n public override handleTransitionSpiral(g: TransitionSpiral3d) {\n return this.handleCurvePrimitive(g);\n }\n}\n"]}
|