@itwin/core-geometry 5.1.0-dev.3 → 5.1.0-dev.5

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.
Files changed (47) hide show
  1. package/lib/cjs/curve/RegionMomentsXY.d.ts +14 -21
  2. package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
  3. package/lib/cjs/curve/RegionMomentsXY.js +23 -25
  4. package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
  5. package/lib/cjs/curve/RegionOps.d.ts +27 -10
  6. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  7. package/lib/cjs/curve/RegionOps.js +58 -13
  8. package/lib/cjs/curve/RegionOps.js.map +1 -1
  9. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  10. package/lib/cjs/geometry3d/Point3dVector3d.js +3 -3
  11. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  12. package/lib/cjs/geometry3d/PolygonOps.d.ts +8 -7
  13. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  14. package/lib/cjs/geometry3d/PolygonOps.js +19 -15
  15. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  16. package/lib/cjs/geometry4d/Matrix4d.d.ts +7 -7
  17. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  18. package/lib/cjs/geometry4d/Matrix4d.js +9 -9
  19. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  20. package/lib/cjs/geometry4d/MomentData.d.ts +32 -34
  21. package/lib/cjs/geometry4d/MomentData.d.ts.map +1 -1
  22. package/lib/cjs/geometry4d/MomentData.js +56 -57
  23. package/lib/cjs/geometry4d/MomentData.js.map +1 -1
  24. package/lib/esm/curve/RegionMomentsXY.d.ts +14 -21
  25. package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
  26. package/lib/esm/curve/RegionMomentsXY.js +23 -25
  27. package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
  28. package/lib/esm/curve/RegionOps.d.ts +27 -10
  29. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  30. package/lib/esm/curve/RegionOps.js +59 -14
  31. package/lib/esm/curve/RegionOps.js.map +1 -1
  32. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  33. package/lib/esm/geometry3d/Point3dVector3d.js +3 -3
  34. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  35. package/lib/esm/geometry3d/PolygonOps.d.ts +8 -7
  36. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  37. package/lib/esm/geometry3d/PolygonOps.js +19 -15
  38. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  39. package/lib/esm/geometry4d/Matrix4d.d.ts +7 -7
  40. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  41. package/lib/esm/geometry4d/Matrix4d.js +9 -9
  42. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  43. package/lib/esm/geometry4d/MomentData.d.ts +32 -34
  44. package/lib/esm/geometry4d/MomentData.d.ts.map +1 -1
  45. package/lib/esm/geometry4d/MomentData.js +56 -57
  46. package/lib/esm/geometry4d/MomentData.js.map +1 -1
  47. package/package.json +3 -3
@@ -21,41 +21,34 @@ export declare class RegionMomentsXY extends NullGeometryHandler {
21
21
  private _activeMomentData?;
22
22
  private _point0;
23
23
  private _point1;
24
- /** Accumulate (independent) integrations over
25
- * * origin to chord of the arc.
26
- * * origin to the "cap" between the chord and arc.
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 (as simple addition) products over each component of the union region. */
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
- /** Single curve primitive (not loop . . .).
50
- * * stroke the curve
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
- /** handle strongly typed BSplineCurve3d as generic curve primitive */
47
+ /** Handle strongly typed BSplineCurve3d as generic curve primitive. */
55
48
  handleBSplineCurve3d(g: BSplineCurve3d): void;
56
- /** handle strongly typed BSplineCurve3dH as generic curve primitive */
49
+ /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */
57
50
  handleBSplineCurve3dH(g: BSplineCurve3dH): void;
58
- /** handle strongly typed TransitionSpiral as generic curve primitive */
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,E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I1D,4FAA4F;IAC5E,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAMjE,uEAAuE;IACvD,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,GAAG,SAAS;IAQ9D,+EAA+E;IAC/D,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS;IA+BhF,8EAA8E;IAC9D,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS;IAW9E,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,OAAO,CAAC,gBAAgB;IASxB;;;OAGG;IACI,oBAAoB,CAAC,EAAE,EAAE,cAAc;IAM9C,yEAAyE;IACzD,oBAAoB,CAAC,CAAC,EAAE,cAAc;IAGtD,0EAA0E;IAC1D,qBAAqB,CAAC,CAAC,EAAE,eAAe;IAGxD,0EAA0E;IAC1D,sBAAsB,CAAC,CAAC,EAAE,kBAAkB;CAG7D"}
@@ -20,15 +20,15 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
20
20
  _activeMomentData;
21
21
  _point0 = Point3dVector3d_1.Point3d.create();
22
22
  _point1 = Point3dVector3d_1.Point3d.create();
23
- /** Accumulate (independent) integrations over
24
- * * origin to chord of the arc.
25
- * * origin to the "cap" between the chord and arc.
23
+ /**
24
+ * Accumulate (independent) integrations over:
25
+ * * The area between the arc and the chord connecting its endpoints.
26
+ * * The triangle with vertices: origin, arc start, arc end.
26
27
  */
27
28
  handleArc3d(arc) {
28
29
  const momentData = this._activeMomentData;
29
30
  const sweepRadians = arc.sweep.sweepRadians;
30
31
  const alphaRadians = sweepRadians * 0.5;
31
- // from https://apps.dtic.mil/dtic/tr/fulltext/u2/274936.pdf page 71 for radius = 1
32
32
  let s = Math.sin(alphaRadians);
33
33
  let c = Math.cos(alphaRadians);
34
34
  let s1 = Math.sin(sweepRadians);
@@ -55,12 +55,12 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
55
55
  const pointC = arc.fractionToPoint(1.0);
56
56
  momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);
57
57
  }
58
- /** Accumulate integrals over the (triangular) areas from the origin to each line segment */
58
+ /** Accumulate integrals over the (triangular) areas from the origin to each line segment. */
59
59
  handleLineString3d(ls) {
60
60
  const momentData = this._activeMomentData;
61
61
  momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);
62
62
  }
63
- /** Accumulate integrals over the (triangular) area from the origin to this line segment */
63
+ /** Accumulate integrals over the (triangular) area from the origin to this line segment. */
64
64
  handleLineSegment3d(segment) {
65
65
  const momentData = this._activeMomentData;
66
66
  segment.startPoint(this._point0);
@@ -76,15 +76,7 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
76
76
  this._activeMomentData = undefined;
77
77
  return momentData;
78
78
  }
79
- /**
80
- * ASSUMPTIONS FOR ORIENTATION AND CONTAINMENT ISSUES
81
- * * Largest area is outer
82
- * * All others are interior (and not overlapping)
83
- * Hence
84
- * * Outer area sign must be positive -- negate all integrations as needed
85
- * * Outer area signs must be positive -- negate all integrations as needed
86
- * @param region
87
- */
79
+ /** Accumulate integrals from origin to the components of the parity region. */
88
80
  handleParityRegion(region) {
89
81
  const allChildMoments = [];
90
82
  let maxAbsArea = 0.0;
@@ -116,7 +108,7 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
116
108
  }
117
109
  return undefined;
118
110
  }
119
- /** Accumulate (as simple addition) products over each component of the union region. */
111
+ /** Accumulate integrals from origin to the components of the union region. */
120
112
  handleUnionRegion(region) {
121
113
  const summedMoments = MomentData_1.MomentData.create();
122
114
  for (const child of region.children) {
@@ -138,9 +130,9 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
138
130
  this._strokeOptions = options;
139
131
  return options;
140
132
  }
141
- /** Single curve primitive (not loop . . .).
142
- * * stroke the curve
143
- * * accumulate stroke array.
133
+ /**
134
+ * Handle a single curve primitive (not loop).
135
+ * * Stroke the curve and accumulate stroke array.
144
136
  */
145
137
  handleCurvePrimitive(cp) {
146
138
  const strokes = LineString3d_1.LineString3d.create();
@@ -148,12 +140,18 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
148
140
  cp.emitStrokes(strokes, options);
149
141
  this.handleLineString3d(strokes);
150
142
  }
151
- /** handle strongly typed BSplineCurve3d as generic curve primitive */
152
- handleBSplineCurve3d(g) { return this.handleCurvePrimitive(g); }
153
- /** handle strongly typed BSplineCurve3dH as generic curve primitive */
154
- handleBSplineCurve3dH(g) { return this.handleCurvePrimitive(g); }
155
- /** handle strongly typed TransitionSpiral as generic curve primitive */
156
- handleTransitionSpiral(g) { return this.handleCurvePrimitive(g); }
143
+ /** Handle strongly typed BSplineCurve3d as generic curve primitive. */
144
+ handleBSplineCurve3d(g) {
145
+ return this.handleCurvePrimitive(g);
146
+ }
147
+ /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */
148
+ handleBSplineCurve3dH(g) {
149
+ return this.handleCurvePrimitive(g);
150
+ }
151
+ /** Handle strongly typed TransitionSpiral as generic curve primitive. */
152
+ handleTransitionSpiral(g) {
153
+ return this.handleCurvePrimitive(g);
154
+ }
157
155
  }
158
156
  exports.RegionMomentsXY = RegionMomentsXY;
159
157
  //# 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,+CAA4C;AAC5C,mEAAoE;AACpE,mEAAwD;AACxD,yDAAsD;AAItD,iDAA8C;AAC9C,iCAA8B;AAE9B,mDAAgD;AAIhD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,qCAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IAEnC;;;OAGG;IACa,WA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BAAgB,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;AA/ID,0CA+IC","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,+CAA4C;AAC5C,mEAAoE;AACpE,mEAAwD;AACxD,yDAAsD;AAItD,iDAA8C;AAC9C,iCAA8B;AAE9B,mDAAgD;AAIhD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,qCAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IACnC;;;;OAIG;IACa,WAAW,CAAC,GAAU;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAkB,CAAC;QAC3C,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;QAC5C,MAAM,YAAY,GAAG,YAAY,GAAG,GAAG,CAAC;QACxC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CA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ACD,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;AA1ID,0CA0IC","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"]}
@@ -2,6 +2,7 @@ import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
2
2
  import { IndexedXYZCollection, MultiLineStringDataVariant } from "../geometry3d/IndexedXYZCollection";
3
3
  import { Point3d } from "../geometry3d/Point3dVector3d";
4
4
  import { Range3d } from "../geometry3d/Range";
5
+ import { Ray3d } from "../geometry3d/Ray3d";
5
6
  import { Transform } from "../geometry3d/Transform";
6
7
  import { MomentData } from "../geometry4d/MomentData";
7
8
  import { IndexedPolyface, Polyface } from "../polyface/Polyface";
@@ -47,30 +48,46 @@ export declare enum RegionBinaryOpType {
47
48
  export declare class RegionOps {
48
49
  /**
49
50
  * Return moment sums for a loop, parity region, or union region.
51
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
50
52
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
51
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
52
- * @param root any Loop, ParityRegion, or UnionRegion.
53
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
54
+ * * `rawMomentData.origin` is the centroid of `region`.
55
+ * * `rawMomentData.sums.weight()` is the signed area of `region`.
56
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
53
57
  */
54
- static computeXYAreaMoments(root: AnyRegion): MomentData | undefined;
58
+ static computeXYAreaMoments(region: AnyRegion): MomentData | undefined;
55
59
  /**
56
60
  * Return an area tolerance for a given xy-range and optional distance tolerance.
57
- * @param range range of planar region to tolerance
58
- * @param distanceTolerance optional absolute distance tolerance
61
+ * @param range range of planar region to tolerance.
62
+ * @param distanceTolerance optional absolute distance tolerance.
59
63
  */
60
64
  static computeXYAreaTolerance(range: Range3d, distanceTolerance?: number): number;
61
65
  /**
62
66
  * Return a (signed) xy area for a region.
67
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
63
68
  * * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
64
- * @param root any Loop, ParityRegion, or UnionRegion.
69
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
65
70
  */
66
- static computeXYArea(root: AnyRegion): number | undefined;
71
+ static computeXYArea(region: AnyRegion): number | undefined;
67
72
  /**
68
73
  * Return MomentData with the sums of wire moments.
74
+ * * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
69
75
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
70
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
71
- * @param root any CurveCollection or CurvePrimitive.
76
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
77
+ * * `rawMomentData.origin` is the wire centroid of `curve`.
78
+ * * `rawMomentData.sums.weight()` is the signed length of `curve`.
79
+ * @param curve any [[CurveCollection]] or [[CurvePrimitive]].
72
80
  */
73
- static computeXYZWireMomentSums(root: AnyCurve): MomentData | undefined;
81
+ static computeXYZWireMomentSums(curve: AnyCurve): MomentData | undefined;
82
+ /**
83
+ * Return a [[Ray3d]] with:
84
+ * * `origin` is the centroid of the region,
85
+ * * `direction` is a unit vector perpendicular to the region plane,
86
+ * * `a` is the region area.
87
+ * @param region the region to process. Can lie in any plane.
88
+ * @param result optional pre-allocated result to populate and return.
89
+ */
90
+ static centroidAreaNormal(region: AnyRegion, result?: Ray3d): Ray3d | undefined;
74
91
  /**
75
92
  * Create loops in the graph.
76
93
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"RegionOps.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names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AAU,EAAE,QAAQ,GAAG,QAAQ,EAAE,EACjC,cAAc,CAAC,EAAE,cAAc,EAAE,EACjC,0BAA0B,GAAE,OAAe,EAC3C,kBAAkB,GAAE,OAAe,GAClC,cAAc,EAAE;IAanB;;;;;OAKG;WACW,iBAAiB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAe/E;;;;OAIG;WACW,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,SAAS,GAAG,OAAO;IAkB3E;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,iCAAiC;IAqChD,oCAAoC;IACpC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAepC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAIzC;;;;;;;;;;;OAWG;WACW,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,SAAS;IAyBpG;;;;;MAKE;WACY,wBAAwB,CAAC,OAAO,EAAE,0BAA0B,EAAE,QAAQ,GAAE,OAAc,GAAG,gBAAgB,EAAE,GAAG,SAAS;CActI;AAaD;;;GAGG;AACH,qBAAa,yCAAyC;IACpD,8EAA8E;IACvE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,yEAAyE;IAClE,yBAAyB,EAAE,OAAO,CAAQ;IACjD,gDAAgD;IACzC,uBAAuB,SAAgC;IAC9D,uDAAuD;IAChD,sBAAsB,SAAgC;CAC9D"}
@@ -9,6 +9,7 @@ exports.ConsolidateAdjacentCurvePrimitivesOptions = exports.RegionOps = exports.
9
9
  * @module Curve
10
10
  */
11
11
  const Geometry_1 = require("../Geometry");
12
+ const FrameBuilder_1 = require("../geometry3d/FrameBuilder");
12
13
  const GrowableXYZArray_1 = require("../geometry3d/GrowableXYZArray");
13
14
  const IndexedXYZCollection_1 = require("../geometry3d/IndexedXYZCollection");
14
15
  const Point3dArrayCarrier_1 = require("../geometry3d/Point3dArrayCarrier");
@@ -16,6 +17,7 @@ const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
16
17
  const PolygonOps_1 = require("../geometry3d/PolygonOps");
17
18
  const PolylineCompressionByEdgeOffset_1 = require("../geometry3d/PolylineCompressionByEdgeOffset");
18
19
  const Range_1 = require("../geometry3d/Range");
20
+ const Ray3d_1 = require("../geometry3d/Ray3d");
19
21
  const SortablePolygon_1 = require("../geometry3d/SortablePolygon");
20
22
  const Transform_1 = require("../geometry3d/Transform");
21
23
  const MomentData_1 = require("../geometry4d/MomentData");
@@ -70,13 +72,16 @@ var RegionBinaryOpType;
70
72
  class RegionOps {
71
73
  /**
72
74
  * Return moment sums for a loop, parity region, or union region.
75
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
73
76
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
74
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
75
- * @param root any Loop, ParityRegion, or UnionRegion.
77
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes(rawMomentData.origin, rawMomentData.sums);`
78
+ * * `rawMomentData.origin` is the centroid of `region`.
79
+ * * `rawMomentData.sums.weight()` is the signed area of `region`.
80
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
76
81
  */
77
- static computeXYAreaMoments(root) {
82
+ static computeXYAreaMoments(region) {
78
83
  const handler = new RegionMomentsXY_1.RegionMomentsXY();
79
- const result = root.dispatchToGeometryHandler(handler);
84
+ const result = region.dispatchToGeometryHandler(handler);
80
85
  if (result instanceof MomentData_1.MomentData) {
81
86
  result.shiftOriginAndSumsToCentroidOfSums();
82
87
  return result;
@@ -85,8 +90,8 @@ class RegionOps {
85
90
  }
86
91
  /**
87
92
  * Return an area tolerance for a given xy-range and optional distance tolerance.
88
- * @param range range of planar region to tolerance
89
- * @param distanceTolerance optional absolute distance tolerance
93
+ * @param range range of planar region to tolerance.
94
+ * @param distanceTolerance optional absolute distance tolerance.
90
95
  */
91
96
  static computeXYAreaTolerance(range, distanceTolerance = Geometry_1.Geometry.smallMetricDistance) {
92
97
  // if A = bh and e is distance tolerance, then A' := (b+e/2)(h+e/2) = A + e/2(b+h+e/2), so A'-A = e/2(b+h+e/2).
@@ -95,12 +100,13 @@ class RegionOps {
95
100
  }
96
101
  /**
97
102
  * Return a (signed) xy area for a region.
103
+ * * The input region should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
98
104
  * * The area is negative if and only if the region is oriented clockwise with respect to the positive z-axis.
99
- * @param root any Loop, ParityRegion, or UnionRegion.
105
+ * @param region any [[Loop]], [[ParityRegion]], or [[UnionRegion]].
100
106
  */
101
- static computeXYArea(root) {
107
+ static computeXYArea(region) {
102
108
  const handler = new RegionMomentsXY_1.RegionMomentsXY();
103
- const result = root.dispatchToGeometryHandler(handler);
109
+ const result = region.dispatchToGeometryHandler(handler);
104
110
  if (result instanceof MomentData_1.MomentData) {
105
111
  return result.quantitySum;
106
112
  }
@@ -108,17 +114,56 @@ class RegionOps {
108
114
  }
109
115
  /**
110
116
  * Return MomentData with the sums of wire moments.
117
+ * * The input curve should lie in a plane parallel to the xy-plane, as z-coords will be ignored.
111
118
  * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
112
- * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
113
- * @param root any CurveCollection or CurvePrimitive.
119
+ * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
120
+ * * `rawMomentData.origin` is the wire centroid of `curve`.
121
+ * * `rawMomentData.sums.weight()` is the signed length of `curve`.
122
+ * @param curve any [[CurveCollection]] or [[CurvePrimitive]].
114
123
  */
115
- static computeXYZWireMomentSums(root) {
124
+ static computeXYZWireMomentSums(curve) {
116
125
  const handler = new CurveWireMomentsXYZ_1.CurveWireMomentsXYZ();
117
- handler.visitLeaves(root);
126
+ handler.visitLeaves(curve);
118
127
  const result = handler.momentData;
119
128
  result.shiftOriginAndSumsToCentroidOfSums();
120
129
  return result;
121
130
  }
131
+ /**
132
+ * Return a [[Ray3d]] with:
133
+ * * `origin` is the centroid of the region,
134
+ * * `direction` is a unit vector perpendicular to the region plane,
135
+ * * `a` is the region area.
136
+ * @param region the region to process. Can lie in any plane.
137
+ * @param result optional pre-allocated result to populate and return.
138
+ */
139
+ static centroidAreaNormal(region, result) {
140
+ const localToWorld = FrameBuilder_1.FrameBuilder.createRightHandedFrame(undefined, region);
141
+ if (!localToWorld)
142
+ return undefined;
143
+ const normal = localToWorld.matrix.columnZ(result?.direction);
144
+ const regionIsXY = normal.isParallelTo(Point3dVector3d_1.Vector3d.unitZ(), true);
145
+ let regionXY = region;
146
+ if (!regionIsXY) { // rotate the region to be parallel to the xy-plane
147
+ regionXY = region.cloneTransformed(localToWorld.inverse());
148
+ if (!regionXY)
149
+ return undefined;
150
+ }
151
+ const momentData = RegionOps.computeXYAreaMoments(regionXY);
152
+ if (!momentData)
153
+ return undefined;
154
+ const centroid = momentData.origin.clone(result?.origin);
155
+ if (!regionIsXY) // rotate centroid back (area is unchanged)
156
+ localToWorld.multiplyPoint3d(centroid, centroid);
157
+ let area = momentData.sums.weight();
158
+ if (area < 0.0) {
159
+ area = -area;
160
+ normal.scale(-1.0, normal);
161
+ }
162
+ if (!result)
163
+ result = Ray3d_1.Ray3d.createCapture(centroid, normal);
164
+ result.a = area;
165
+ return result;
166
+ }
122
167
  /**
123
168
  * Create loops in the graph.
124
169
  * @internal