@itwin/core-geometry 5.1.0-dev.52 → 5.1.0-dev.53

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 (183) hide show
  1. package/lib/cjs/Geometry.d.ts +1 -1
  2. package/lib/cjs/Geometry.js.map +1 -1
  3. package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
  4. package/lib/cjs/bspline/BSplineSurface.js +0 -2
  5. package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
  6. package/lib/cjs/curve/CurveCollection.d.ts +7 -0
  7. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  8. package/lib/cjs/curve/CurveCollection.js +11 -0
  9. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  10. package/lib/cjs/curve/CurveFactory.d.ts +3 -2
  11. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  12. package/lib/cjs/curve/CurveFactory.js +6 -5
  13. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  14. package/lib/cjs/curve/CurveLocationDetail.d.ts +3 -1
  15. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  16. package/lib/cjs/curve/CurveLocationDetail.js +6 -1
  17. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  18. package/lib/cjs/curve/CurvePrimitive.d.ts +7 -0
  19. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  20. package/lib/cjs/curve/CurvePrimitive.js +11 -0
  21. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  22. package/lib/cjs/curve/LineSegment3d.d.ts +2 -0
  23. package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
  24. package/lib/cjs/curve/LineSegment3d.js +4 -0
  25. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  26. package/lib/cjs/curve/LineString3d.d.ts +7 -0
  27. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  28. package/lib/cjs/curve/LineString3d.js +15 -3
  29. package/lib/cjs/curve/LineString3d.js.map +1 -1
  30. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  31. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +28 -4
  32. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  33. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +25 -3
  34. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  35. package/lib/cjs/curve/Query/PlanarSubdivision.js +102 -22
  36. package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
  37. package/lib/cjs/curve/Query/StrokeCountChain.d.ts +4 -3
  38. package/lib/cjs/curve/Query/StrokeCountChain.d.ts.map +1 -1
  39. package/lib/cjs/curve/Query/StrokeCountChain.js +20 -9
  40. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  41. package/lib/cjs/curve/RegionMomentsXY.d.ts +1 -1
  42. package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
  43. package/lib/cjs/curve/RegionMomentsXY.js +6 -3
  44. package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
  45. package/lib/cjs/curve/RegionOps.d.ts +23 -14
  46. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  47. package/lib/cjs/curve/RegionOps.js +60 -21
  48. package/lib/cjs/curve/RegionOps.js.map +1 -1
  49. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +9 -1
  50. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  51. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +91 -1
  52. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  53. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +2 -2
  54. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +6 -6
  55. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  56. package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -1
  57. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  58. package/lib/cjs/geometry3d/AngleSweep.js +1 -1
  59. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  60. package/lib/cjs/geometry3d/Ellipsoid.js +1 -1
  61. package/lib/cjs/geometry3d/Ellipsoid.js.map +1 -1
  62. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +9 -0
  63. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  64. package/lib/cjs/geometry3d/IndexedXYZCollection.js +14 -0
  65. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  66. package/lib/cjs/geometry3d/Ray3d.d.ts +7 -9
  67. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  68. package/lib/cjs/geometry3d/Ray3d.js +12 -22
  69. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  70. package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -4
  71. package/lib/cjs/geometry3d/SortablePolygon.d.ts.map +1 -1
  72. package/lib/cjs/geometry3d/SortablePolygon.js +48 -43
  73. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  74. package/lib/cjs/polyface/PolyfaceBuilder.js +3 -3
  75. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  76. package/lib/cjs/solid/Sphere.js +1 -1
  77. package/lib/cjs/solid/Sphere.js.map +1 -1
  78. package/lib/cjs/solid/SweepContour.d.ts +1 -1
  79. package/lib/cjs/solid/SweepContour.js +1 -1
  80. package/lib/cjs/solid/SweepContour.js.map +1 -1
  81. package/lib/cjs/topology/Graph.d.ts +64 -14
  82. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  83. package/lib/cjs/topology/Graph.js +149 -32
  84. package/lib/cjs/topology/Graph.js.map +1 -1
  85. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts +2 -2
  86. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  87. package/lib/cjs/topology/HalfEdgeGraphSearch.js +2 -2
  88. package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
  89. package/lib/cjs/topology/RegularizeFace.d.ts.map +1 -1
  90. package/lib/cjs/topology/RegularizeFace.js +2 -1
  91. package/lib/cjs/topology/RegularizeFace.js.map +1 -1
  92. package/lib/esm/Geometry.d.ts +1 -1
  93. package/lib/esm/Geometry.js.map +1 -1
  94. package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
  95. package/lib/esm/bspline/BSplineSurface.js +0 -2
  96. package/lib/esm/bspline/BSplineSurface.js.map +1 -1
  97. package/lib/esm/curve/CurveCollection.d.ts +7 -0
  98. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  99. package/lib/esm/curve/CurveCollection.js +11 -0
  100. package/lib/esm/curve/CurveCollection.js.map +1 -1
  101. package/lib/esm/curve/CurveFactory.d.ts +3 -2
  102. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  103. package/lib/esm/curve/CurveFactory.js +6 -5
  104. package/lib/esm/curve/CurveFactory.js.map +1 -1
  105. package/lib/esm/curve/CurveLocationDetail.d.ts +3 -1
  106. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  107. package/lib/esm/curve/CurveLocationDetail.js +6 -1
  108. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  109. package/lib/esm/curve/CurvePrimitive.d.ts +7 -0
  110. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  111. package/lib/esm/curve/CurvePrimitive.js +11 -0
  112. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  113. package/lib/esm/curve/LineSegment3d.d.ts +2 -0
  114. package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
  115. package/lib/esm/curve/LineSegment3d.js +4 -0
  116. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  117. package/lib/esm/curve/LineString3d.d.ts +7 -0
  118. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  119. package/lib/esm/curve/LineString3d.js +15 -3
  120. package/lib/esm/curve/LineString3d.js.map +1 -1
  121. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  122. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +28 -4
  123. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  124. package/lib/esm/curve/Query/PlanarSubdivision.d.ts +25 -3
  125. package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  126. package/lib/esm/curve/Query/PlanarSubdivision.js +104 -24
  127. package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
  128. package/lib/esm/curve/Query/StrokeCountChain.d.ts +4 -3
  129. package/lib/esm/curve/Query/StrokeCountChain.d.ts.map +1 -1
  130. package/lib/esm/curve/Query/StrokeCountChain.js +20 -9
  131. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  132. package/lib/esm/curve/RegionMomentsXY.d.ts +1 -1
  133. package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
  134. package/lib/esm/curve/RegionMomentsXY.js +6 -3
  135. package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
  136. package/lib/esm/curve/RegionOps.d.ts +23 -14
  137. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  138. package/lib/esm/curve/RegionOps.js +60 -21
  139. package/lib/esm/curve/RegionOps.js.map +1 -1
  140. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +9 -1
  141. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  142. package/lib/esm/curve/RegionOpsClassificationSweeps.js +91 -2
  143. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  144. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +2 -2
  145. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +6 -6
  146. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  147. package/lib/esm/geometry3d/AngleSweep.d.ts +1 -1
  148. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  149. package/lib/esm/geometry3d/AngleSweep.js +1 -1
  150. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  151. package/lib/esm/geometry3d/Ellipsoid.js +1 -1
  152. package/lib/esm/geometry3d/Ellipsoid.js.map +1 -1
  153. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +9 -0
  154. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  155. package/lib/esm/geometry3d/IndexedXYZCollection.js +14 -0
  156. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  157. package/lib/esm/geometry3d/Ray3d.d.ts +7 -9
  158. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  159. package/lib/esm/geometry3d/Ray3d.js +12 -22
  160. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  161. package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -4
  162. package/lib/esm/geometry3d/SortablePolygon.d.ts.map +1 -1
  163. package/lib/esm/geometry3d/SortablePolygon.js +48 -43
  164. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  165. package/lib/esm/polyface/PolyfaceBuilder.js +3 -3
  166. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  167. package/lib/esm/solid/Sphere.js +1 -1
  168. package/lib/esm/solid/Sphere.js.map +1 -1
  169. package/lib/esm/solid/SweepContour.d.ts +1 -1
  170. package/lib/esm/solid/SweepContour.js +1 -1
  171. package/lib/esm/solid/SweepContour.js.map +1 -1
  172. package/lib/esm/topology/Graph.d.ts +64 -14
  173. package/lib/esm/topology/Graph.d.ts.map +1 -1
  174. package/lib/esm/topology/Graph.js +149 -32
  175. package/lib/esm/topology/Graph.js.map +1 -1
  176. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts +2 -2
  177. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  178. package/lib/esm/topology/HalfEdgeGraphSearch.js +2 -2
  179. package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
  180. package/lib/esm/topology/RegularizeFace.d.ts.map +1 -1
  181. package/lib/esm/topology/RegularizeFace.js +2 -1
  182. package/lib/esm/topology/RegularizeFace.js.map +1 -1
  183. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"IndexedXYZCollection.js","sourceRoot":"","sources":["../../../src/geometry3d/IndexedXYZCollection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAO,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,MAAM,cAAc;IACD,WAAW,CAAuB;IAC3C,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB,YAAmB,UAAgC;QACjD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAEM,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAChD,0JAA0J;YAC1J,OAAO,EAAE,IAAI,EAAE,IAAI,EAAoC,CAAC;QAC1D,CAAC;QAED,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,IAAI,CAAC,SAAS,CAAC;YACvE,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAwB,OAAO,IAAI,CAAC,CAAC,CAAC;CAC/D;AACD;;;;;;;;GAQG;AACH,MAAM,OAAgB,oBAAoB;IAsCxC;;;;;;OAMG;IACI,iBAAiB,CAAC,MAAc,EAAE,MAAc,EAAE,MAAiB;QACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE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CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACtH,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACpH,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5H,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,6BAA8B,SAAQ,oBAAoB;CAkB/E","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 ArraysAndInterfaces\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Point3d, Vector3d, XYZ } from \"./Point3dVector3d\";\nimport { Range3d } from \"./Range\";\nimport { Transform } from \"./Transform\";\nimport { XAndY, XYAndZ } from \"./XYZProps\";\n\nclass PointsIterator implements Iterator<Point3d>, Iterable<Point3d> {\n private readonly _collection: IndexedXYZCollection;\n private _curIndex = -1;\n\n public constructor(collection: IndexedXYZCollection) {\n this._collection = collection;\n }\n\n public next(): IteratorResult<Point3d> {\n if (++this._curIndex >= this._collection.length) {\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\n return { done: true } as any as IteratorResult<Point3d>;\n }\n\n return {\n value: this._collection.getPoint3dAtUncheckedPointIndex(this._curIndex),\n done: false,\n };\n }\n\n public [Symbol.iterator](): Iterator<Point3d> { return this; }\n}\n/**\n * abstract base class for read-only access to XYZ data with indexed reference.\n * * This allows algorithms to work with Point3d[] or GrowableXYZ.\n * * GrowableXYZArray implements these for its data.\n * * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.\n * * In addition to \"point by point\" accessors, other abstract members compute commonly useful vector data \"between points\".\n * * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.\n * @public\n */\nexport abstract class IndexedXYZCollection {\n /**\n * Return the point at `index` as a strongly typed Point3d.\n * @param index index of point within the array\n * @param result caller-allocated destination\n * @returns undefined if the index is out of bounds\n */\n public abstract getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined;\n /**\n * Return the point at `index` as a strongly typed Point3d, without checking the point index validity.\n * @param index index of point within the array\n * @param result caller-allocated destination\n * @returns undefined if the index is out of bounds\n */\n public abstract getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d;\n /**\n * Get from `index` as a strongly typed Vector3d.\n * @param index index of point within the array\n * @param result caller-allocated destination\n * @returns undefined if the index is out of bounds\n */\n public abstract getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return a vector from the point at `indexA` to the point at `indexB`\n * @param indexA index of point within the array\n * @param indexB index of point within the array\n * @param result caller-allocated vector.\n * @returns undefined if either index is out of bounds\n */\n public abstract vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return a vector from `origin` to the point at `indexB`\n * @param origin origin for vector\n * @param indexB index of point within the array\n * @param result caller-allocated vector.\n * @returns undefined if index is out of bounds\n */\n public abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return a vector from the point at `indexA` to `target`\n * @param indexA index of point within the array\n * @param target target for vector\n * @param result caller-allocated vector.\n * @returns undefined if index is out of bounds\n */\n public vectorIndexXYAndZ(indexA: number, target: XYAndZ, result?: Vector3d): Vector3d | undefined {\n const reversed = this.vectorXYAndZIndex(target, indexA, result);\n return reversed?.negate(reversed);\n }\n /**\n * Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`.\n * @param origin index of point within the array; origin of both vectors\n * @param indexA index of point within the array; target of the first vector\n * @param indexA index of point within the array; target of the second vector\n * @returns undefined if index is out of bounds\n */\n public dotProductIndexIndexIndex(origin: number, indexA: number, indexB: number): number | undefined {\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length || indexB < 0 || indexB >= this.length)\n return undefined;\n const x0 = this.getXAtUncheckedPointIndex(origin);\n const y0 = this.getYAtUncheckedPointIndex(origin);\n const z0 = this.getZAtUncheckedPointIndex(origin);\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (this.getXAtUncheckedPointIndex(indexB) - x0) +\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (this.getYAtUncheckedPointIndex(indexB) - y0) +\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (this.getZAtUncheckedPointIndex(indexB) - z0);\n }\n /**\n * Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`.\n * @param origin index of point within the array; origin of both vectors\n * @param indexA index of point within the array; target of the first vector\n * @param targetB target for second vector\n * @returns undefined if index is out of bounds\n */\n public dotProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number | undefined {\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\n return undefined;\n const x0 = this.getXAtUncheckedPointIndex(origin);\n const y0 = this.getYAtUncheckedPointIndex(origin);\n const z0 = this.getZAtUncheckedPointIndex(origin);\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (targetB.x - x0) +\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (targetB.y - y0) +\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (targetB.z - z0);\n }\n /**\n * Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`\n * @param origin origin for vector\n * @param indexA index of first target within the array\n * @param indexB index of second target within the array\n * @param result caller-allocated vector.\n * @returns undefined if either index is out of bounds\n */\n public abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`\n * @param origin index of point within the array; origin of both vectors\n * @param indexA index of point within the array; target of the first vector\n * @param targetB target of second vector\n * @param result optional caller-allocated result to fill and return\n * @returns undefined if an index is out of bounds\n */\n public crossProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d | undefined {\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\n return undefined;\n const x0 = this.getXAtUncheckedPointIndex(origin);\n const y0 = this.getYAtUncheckedPointIndex(origin);\n const z0 = this.getZAtUncheckedPointIndex(origin);\n return Vector3d.createCrossProduct(this.getXAtUncheckedPointIndex(indexA) - x0,\n this.getYAtUncheckedPointIndex(indexA) - y0,\n this.getZAtUncheckedPointIndex(indexA) - z0,\n targetB.x - x0,\n targetB.y - y0,\n targetB.z - z0, result);\n }\n /**\n * Return the cross product of vectors from `origin` to points at `indexA` and `indexB`\n * @param origin origin for vector\n * @param indexA index of first target within the array\n * @param indexB index of second target within the array\n * @param result optional caller-allocated vector.\n * @returns undefined if either index is out of bounds\n */\n public abstract crossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return the cross product of vectors from origin point at `indexA` to target points at `indexB` and `indexC`\n * @param origin index of origin\n * @param indexA index of first target within the array\n * @param indexB index of second target within the array\n * @param result caller-allocated vector.\n * @returns return true if indexA, indexB both valid\n */\n public abstract accumulateCrossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result: Vector3d): void;\n\n /**\n * read-only property for number of XYZ in the collection.\n */\n public abstract get length(): number;\n /**\n * Return distance squared between indicated points.\n * @param index0 first point index\n * @param index1 second point index\n */\n public abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;\n /**\n * Return distance squared between the point at index0 and target.\n * @param index0 first point index\n * @param target second point\n */\n public distanceSquaredIndexXYAndZ(index0: number, target: XYAndZ): number | undefined {\n if (index0 < 0 || index0 >= this.length)\n return undefined;\n return Geometry.hypotenuseSquaredXYZ(\n target.x - this.getXAtUncheckedPointIndex(index0),\n target.y - this.getYAtUncheckedPointIndex(index0),\n target.z - this.getZAtUncheckedPointIndex(index0));\n }\n /**\n * Return distance between indicated points.\n * @param index0 first point index\n * @param index1 second point index\n */\n public abstract distanceIndexIndex(index0: number, index1: number): number | undefined;\n /**\n * Test if index is valid for an xyz within this array.\n * @param index xyz index to test.\n */\n public isIndexValid(index: number): boolean {\n return index >= 0 && index < this.length;\n }\n /** Adjust index into range by modulo with the length. */\n public cyclicIndex(i: number): number {\n return (i % this.length);\n }\n /** Return the range of the points. */\n public getRange(transform?: Transform, result?: Range3d): Range3d {\n let range = result;\n if (range)\n range.setNull();\n else\n range = Range3d.createNull();\n const n = this.length;\n const point = Point3d.create();\n for (let i = 0; i < n; i++) {\n this.getPoint3dAtUncheckedPointIndex(i, point);\n range.extendPoint(point, transform);\n }\n return range;\n }\n\n /**\n * For each subset of `k` successive points within tolerance of the first point in the subset, return the indices of\n * the last `k-1` duplicates.\n * * Index `0` is never returned.\n * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]])\n * @param preserveLast if the last `k < this.length` points of the instance are duplicates, whether to return the\n * indices of the *first* `k-1` duplicates for this last run. If true, index `this.length - 1` is not returned\n * unless all points are duplicates, in which case all indices but `0` are returned. Default value is false.\n * @return ordered array of 0-based indices of duplicate points\n */\n public findOrderedDuplicates(tolerance: number = Geometry.smallMetricDistance, preserveLast: boolean = false): number[] {\n const indices: number[] = [];\n if (this.length > 1) {\n for (let i = 0; i < this.length - 1;) {\n let j = i + 1;\n for (; this.almostEqualIndexIndex(i, j, tolerance); ++j)\n indices.push(j);\n i = j; // found next unique point\n }\n if (preserveLast && indices.length > 0 && indices.length < this.length - 1) { // not all points are duplicate\n let numLastRun = 0;\n for (; numLastRun <= indices.length - 1 && indices[indices.length - 1 - numLastRun] === this.length - 1 - numLastRun; ++numLastRun);\n for (let i = 0; i < numLastRun; ++i)\n indices[indices.length - 1 - i] -= 1; // decrement the indices of the last run so that the last point is preserved\n }\n }\n return indices;\n }\n\n /** Accumulate scale times the x,y,z values at index.\n * * No action if index is out of bounds.\n */\n public abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void;\n\n /** Compute the linear combination s of the indexed p_i and given scales s_i.\n * @param scales array of scales. For best results, scales should have same length as the instance.\n * @param result optional pre-allocated object to fill and return\n * @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length).\n */\n public linearCombination(scales: number[], result?: Point3d | Vector3d): XYZ {\n const n = Math.min(this.length, scales.length);\n const sum = (result instanceof Vector3d) ? Vector3d.createZero(result) : Point3d.createZero(result);\n for (let i = 0; i < n; ++i) {\n sum.x += scales[i] * this.getXAtUncheckedPointIndex(i);\n sum.y += scales[i] * this.getYAtUncheckedPointIndex(i);\n sum.z += scales[i] * this.getZAtUncheckedPointIndex(i);\n }\n return sum;\n }\n\n /**\n * Interpolate the points at the given indices.\n * @param index0 index of point p0 within the array\n * @param fraction fraction f such that returned point is p0 + f * (p1 - p0)\n * @param index1 index of point p1 within the array\n * @param result optional caller-allocated result to fill and return\n * @returns undefined if an index is out of bounds\n */\n public interpolateIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d | undefined {\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\n return undefined;\n return Point3d.create(Geometry.interpolate(this.getXAtUncheckedPointIndex(index0), fraction, this.getXAtUncheckedPointIndex(index1)),\n Geometry.interpolate(this.getYAtUncheckedPointIndex(index0), fraction, this.getYAtUncheckedPointIndex(index1)),\n Geometry.interpolate(this.getZAtUncheckedPointIndex(index0), fraction, this.getZAtUncheckedPointIndex(index1)), result);\n }\n\n /** access x of indexed point */\n public abstract getXAtUncheckedPointIndex(pointIndex: number): number;\n\n /** access y of indexed point */\n public abstract getYAtUncheckedPointIndex(pointIndex: number): number;\n\n /** access z of indexed point */\n public abstract getZAtUncheckedPointIndex(pointIndex: number): number;\n\n /** Return iterator over the points in this collection. Usage:\n * ```ts\n * for (const point: Point3d of collection.points) { ... }\n * ```\n */\n public get points(): Iterable<Point3d> {\n return new PointsIterator(this);\n }\n /** convert to Point3d[] */\n public getArray(): Point3d[] {\n const result = [];\n for (const p of this.points)\n result.push(p);\n return result;\n }\n /** Return the first point, or undefined if the array is empty. */\n public front(result?: Point3d): Point3d | undefined {\n if (this.length === 0)\n return undefined;\n return this.getPoint3dAtUncheckedPointIndex(0, result);\n }\n /** Return the last point, or undefined if the array is empty. */\n public back(result?: Point3d): Point3d | undefined {\n if (this.length === 0)\n return undefined;\n return this.getPoint3dAtUncheckedPointIndex(this.length - 1, result);\n }\n /**\n * Test whether the indexed points are equal within tolerance.\n * @param index0 index of first point\n * @param index1 index of second point\n * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`.\n */\n public almostEqualIndexIndex(index0: number, index1: number, tolerance = Geometry.smallMetricDistance): boolean | undefined {\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\n return undefined;\n return Geometry.isSameCoordinate(this.getXAtUncheckedPointIndex(index0), this.getXAtUncheckedPointIndex(index1), tolerance)\n && Geometry.isSameCoordinate(this.getYAtUncheckedPointIndex(index0), this.getYAtUncheckedPointIndex(index1), tolerance)\n && Geometry.isSameCoordinate(this.getZAtUncheckedPointIndex(index0), this.getZAtUncheckedPointIndex(index1), tolerance);\n }\n}\n/**\n * abstract base class extends IndexedXYZCollection, adding methods to push, peek, and pop, and rewrite.\n * @public\n */\nexport abstract class IndexedReadWriteXYZCollection extends IndexedXYZCollection {\n /** push a (clone of) point onto the collection\n * * point itself is not pushed -- xyz data is extracted into the native form of the collection.\n */\n public abstract push(data: XYAndZ): void;\n /**\n * push a new point (given by coordinates) onto the collection\n * @param x x coordinate\n * @param y y coordinate\n * @param z z coordinate\n */\n public abstract pushXYZ(x?: number, y?: number, z?: number): void;\n /** remove the final point. */\n public abstract pop(): void;\n /** clear all entries */\n public abstract clear(): void;\n /** reverse the points in place. */\n public abstract reverseInPlace(): void;\n}\n\n/**\n * Type for use as signature for xyz data of a single linestring appearing in a parameter list.\n * @public\n */\nexport type LineStringDataVariant = IndexedXYZCollection | XYAndZ[] | XAndY[] | number[][];\n\n/**\n * Type for use as signature for multiple xyz data of multiple linestrings appearing in a parameter list.\n * @public\n */\nexport type MultiLineStringDataVariant = LineStringDataVariant | LineStringDataVariant[];\n"]}
1
+ {"version":3,"file":"IndexedXYZCollection.js","sourceRoot":"","sources":["../../../src/geometry3d/IndexedXYZCollection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAO,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,MAAM,cAAc;IACD,WAAW,CAAuB;IAC3C,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB,YAAmB,UAAgC;QACjD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAEM,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAChD,0JAA0J;YAC1J,OAAO,EAAE,IAAI,EAAE,IAAI,EAAoC,CAAC;QAC1D,CAAC;QAED,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,IAAI,CAAC,SAAS,CAAC;YACvE,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAwB,OAAO,IAAI,CAAC,CAAC,CAAC;CAC/D;AACD;;;;;;;;GAQG;AACH,MAAM,OAAgB,oBAAoB;IAsCxC;;;;;;OAMG;IACI,iBAAiB,CAAC,MAAc,EAAE,MAAc,EAAE,MAAiB;QACxE,MAAM,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AAM;YAC5E,OAAO,SAAS,CAAC;QACnB,OAAO,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACtH,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACpH,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5H,CAAC;IACD;;;;;;OAMG;IACI,uBAAuB,CAAC,MAAc,EAAE,MAAc,EAAE,SAAS,GAAG,QAAQ,CAAC,mBAAmB;QACrG,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM;YAC5E,OAAO,SAAS,CAAC;QACnB,OAAO,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;eACtH,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5H,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,6BAA8B,SAAQ,oBAAoB;CAkB/E","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 ArraysAndInterfaces\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Point3d, Vector3d, XYZ } from \"./Point3dVector3d\";\nimport { Range3d } from \"./Range\";\nimport { Transform } from \"./Transform\";\nimport { XAndY, XYAndZ } from \"./XYZProps\";\n\nclass PointsIterator implements Iterator<Point3d>, Iterable<Point3d> {\n private readonly _collection: IndexedXYZCollection;\n private _curIndex = -1;\n\n public constructor(collection: IndexedXYZCollection) {\n this._collection = collection;\n }\n\n public next(): IteratorResult<Point3d> {\n if (++this._curIndex >= this._collection.length) {\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\n return { done: true } as any as IteratorResult<Point3d>;\n }\n\n return {\n value: this._collection.getPoint3dAtUncheckedPointIndex(this._curIndex),\n done: false,\n };\n }\n\n public [Symbol.iterator](): Iterator<Point3d> { return this; }\n}\n/**\n * abstract base class for read-only access to XYZ data with indexed reference.\n * * This allows algorithms to work with Point3d[] or GrowableXYZ.\n * * GrowableXYZArray implements these for its data.\n * * Point3dArrayCarrier carries a (reference to) a Point3d[] and implements the methods with calls on that array reference.\n * * In addition to \"point by point\" accessors, other abstract members compute commonly useful vector data \"between points\".\n * * Methods that create vectors among multiple indices allow callers to avoid creating temporaries.\n * @public\n */\nexport abstract class IndexedXYZCollection {\n /**\n * Return the point at `index` as a strongly typed Point3d.\n * @param index index of point within the array\n * @param result caller-allocated destination\n * @returns undefined if the index is out of bounds\n */\n public abstract getPoint3dAtCheckedPointIndex(index: number, result?: Point3d): Point3d | undefined;\n /**\n * Return the point at `index` as a strongly typed Point3d, without checking the point index validity.\n * @param index index of point within the array\n * @param result caller-allocated destination\n * @returns undefined if the index is out of bounds\n */\n public abstract getPoint3dAtUncheckedPointIndex(index: number, result?: Point3d): Point3d;\n /**\n * Get from `index` as a strongly typed Vector3d.\n * @param index index of point within the array\n * @param result caller-allocated destination\n * @returns undefined if the index is out of bounds\n */\n public abstract getVector3dAtCheckedVectorIndex(index: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return a vector from the point at `indexA` to the point at `indexB`\n * @param indexA index of point within the array\n * @param indexB index of point within the array\n * @param result caller-allocated vector.\n * @returns undefined if either index is out of bounds\n */\n public abstract vectorIndexIndex(indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return a vector from `origin` to the point at `indexB`\n * @param origin origin for vector\n * @param indexB index of point within the array\n * @param result caller-allocated vector.\n * @returns undefined if index is out of bounds\n */\n public abstract vectorXYAndZIndex(origin: XYAndZ, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return a vector from the point at `indexA` to `target`\n * @param indexA index of point within the array\n * @param target target for vector\n * @param result caller-allocated vector.\n * @returns undefined if index is out of bounds\n */\n public vectorIndexXYAndZ(indexA: number, target: XYAndZ, result?: Vector3d): Vector3d | undefined {\n const reversed = this.vectorXYAndZIndex(target, indexA, result);\n return reversed?.negate(reversed);\n }\n /**\n * Return the dot product of the vectors from the point at `origin` to the points at `indexA` and `indexB`.\n * @param origin index of point within the array; origin of both vectors\n * @param indexA index of point within the array; target of the first vector\n * @param indexA index of point within the array; target of the second vector\n * @returns undefined if index is out of bounds\n */\n public dotProductIndexIndexIndex(origin: number, indexA: number, indexB: number): number | undefined {\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length || indexB < 0 || indexB >= this.length)\n return undefined;\n const x0 = this.getXAtUncheckedPointIndex(origin);\n const y0 = this.getYAtUncheckedPointIndex(origin);\n const z0 = this.getZAtUncheckedPointIndex(origin);\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (this.getXAtUncheckedPointIndex(indexB) - x0) +\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (this.getYAtUncheckedPointIndex(indexB) - y0) +\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (this.getZAtUncheckedPointIndex(indexB) - z0);\n }\n /**\n * Return the dot product of the vectors from the point at `origin` to the point at `indexA` and to `targetB`.\n * @param origin index of point within the array; origin of both vectors\n * @param indexA index of point within the array; target of the first vector\n * @param targetB target for second vector\n * @returns undefined if index is out of bounds\n */\n public dotProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ): number | undefined {\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\n return undefined;\n const x0 = this.getXAtUncheckedPointIndex(origin);\n const y0 = this.getYAtUncheckedPointIndex(origin);\n const z0 = this.getZAtUncheckedPointIndex(origin);\n return (this.getXAtUncheckedPointIndex(indexA) - x0) * (targetB.x - x0) +\n (this.getYAtUncheckedPointIndex(indexA) - y0) * (targetB.y - y0) +\n (this.getZAtUncheckedPointIndex(indexA) - z0) * (targetB.z - z0);\n }\n /**\n * Return the cross product of the vectors from `origin` to points at `indexA` and `indexB`\n * @param origin origin for vector\n * @param indexA index of first target within the array\n * @param indexB index of second target within the array\n * @param result caller-allocated vector.\n * @returns undefined if either index is out of bounds\n */\n public abstract crossProductXYAndZIndexIndex(origin: XYAndZ, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB`\n * @param origin index of point within the array; origin of both vectors\n * @param indexA index of point within the array; target of the first vector\n * @param targetB target of second vector\n * @param result optional caller-allocated result to fill and return\n * @returns undefined if an index is out of bounds\n */\n public crossProductIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d | undefined {\n if (origin < 0 || origin >= this.length || indexA < 0 || indexA >= this.length)\n return undefined;\n const x0 = this.getXAtUncheckedPointIndex(origin);\n const y0 = this.getYAtUncheckedPointIndex(origin);\n const z0 = this.getZAtUncheckedPointIndex(origin);\n return Vector3d.createCrossProduct(this.getXAtUncheckedPointIndex(indexA) - x0,\n this.getYAtUncheckedPointIndex(indexA) - y0,\n this.getZAtUncheckedPointIndex(indexA) - z0,\n targetB.x - x0,\n targetB.y - y0,\n targetB.z - z0, result);\n }\n /**\n * Return the cross product of vectors from `origin` to points at `indexA` and `indexB`\n * @param origin origin for vector\n * @param indexA index of first target within the array\n * @param indexB index of second target within the array\n * @param result optional caller-allocated vector.\n * @returns undefined if either index is out of bounds\n */\n public abstract crossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result?: Vector3d): Vector3d | undefined;\n /**\n * Return the cross product of vectors from origin point at `indexA` to target points at `indexB` and `indexC`\n * @param origin index of origin\n * @param indexA index of first target within the array\n * @param indexB index of second target within the array\n * @param result caller-allocated vector.\n * @returns return true if indexA, indexB both valid\n */\n public abstract accumulateCrossProductIndexIndexIndex(origin: number, indexA: number, indexB: number, result: Vector3d): void;\n\n /**\n * read-only property for number of XYZ in the collection.\n */\n public abstract get length(): number;\n /**\n * Return distance squared between indicated points.\n * @param index0 first point index\n * @param index1 second point index\n */\n public abstract distanceSquaredIndexIndex(index0: number, index1: number): number | undefined;\n /**\n * Return distance squared between the point at index0 and target.\n * @param index0 first point index\n * @param target second point\n */\n public distanceSquaredIndexXYAndZ(index0: number, target: XYAndZ): number | undefined {\n if (index0 < 0 || index0 >= this.length)\n return undefined;\n return Geometry.hypotenuseSquaredXYZ(\n target.x - this.getXAtUncheckedPointIndex(index0),\n target.y - this.getYAtUncheckedPointIndex(index0),\n target.z - this.getZAtUncheckedPointIndex(index0));\n }\n /**\n * Return distance between indicated points.\n * @param index0 first point index\n * @param index1 second point index\n */\n public abstract distanceIndexIndex(index0: number, index1: number): number | undefined;\n /**\n * Test if index is valid for an xyz within this array.\n * @param index xyz index to test.\n */\n public isIndexValid(index: number): boolean {\n return index >= 0 && index < this.length;\n }\n /** Adjust index into range by modulo with the length. */\n public cyclicIndex(i: number): number {\n return (i % this.length);\n }\n /** Return the range of the points. */\n public getRange(transform?: Transform, result?: Range3d): Range3d {\n let range = result;\n if (range)\n range.setNull();\n else\n range = Range3d.createNull();\n const n = this.length;\n const point = Point3d.create();\n for (let i = 0; i < n; i++) {\n this.getPoint3dAtUncheckedPointIndex(i, point);\n range.extendPoint(point, transform);\n }\n return range;\n }\n\n /**\n * For each subset of `k` successive points within tolerance of the first point in the subset, return the indices of\n * the last `k-1` duplicates.\n * * Index `0` is never returned.\n * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]])\n * @param preserveLast if the last `k < this.length` points of the instance are duplicates, whether to return the\n * indices of the *first* `k-1` duplicates for this last run. If true, index `this.length - 1` is not returned\n * unless all points are duplicates, in which case all indices but `0` are returned. Default value is false.\n * @return ordered array of 0-based indices of duplicate points\n */\n public findOrderedDuplicates(tolerance: number = Geometry.smallMetricDistance, preserveLast: boolean = false): number[] {\n const indices: number[] = [];\n if (this.length > 1) {\n for (let i = 0; i < this.length - 1;) {\n let j = i + 1;\n for (; this.almostEqualIndexIndex(i, j, tolerance); ++j)\n indices.push(j);\n i = j; // found next unique point\n }\n if (preserveLast && indices.length > 0 && indices.length < this.length - 1) { // not all points are duplicate\n let numLastRun = 0;\n for (; numLastRun <= indices.length - 1 && indices[indices.length - 1 - numLastRun] === this.length - 1 - numLastRun; ++numLastRun);\n for (let i = 0; i < numLastRun; ++i)\n indices[indices.length - 1 - i] -= 1; // decrement the indices of the last run so that the last point is preserved\n }\n }\n return indices;\n }\n\n /** Accumulate scale times the x,y,z values at index.\n * * No action if index is out of bounds.\n */\n public abstract accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void;\n\n /** Compute the linear combination s of the indexed p_i and given scales s_i.\n * @param scales array of scales. For best results, scales should have same length as the instance.\n * @param result optional pre-allocated object to fill and return\n * @return s = sum(p_i * s_i), where i ranges from 0 to min(this.length, scales.length).\n */\n public linearCombination(scales: number[], result?: Point3d | Vector3d): XYZ {\n const n = Math.min(this.length, scales.length);\n const sum = (result instanceof Vector3d) ? Vector3d.createZero(result) : Point3d.createZero(result);\n for (let i = 0; i < n; ++i) {\n sum.x += scales[i] * this.getXAtUncheckedPointIndex(i);\n sum.y += scales[i] * this.getYAtUncheckedPointIndex(i);\n sum.z += scales[i] * this.getZAtUncheckedPointIndex(i);\n }\n return sum;\n }\n\n /**\n * Interpolate the points at the given indices.\n * @param index0 index of point p0 within the array\n * @param fraction fraction f such that returned point is p0 + f * (p1 - p0)\n * @param index1 index of point p1 within the array\n * @param result optional caller-allocated result to fill and return\n * @returns undefined if an index is out of bounds\n */\n public interpolateIndexIndex(index0: number, fraction: number, index1: number, result?: Point3d): Point3d | undefined {\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\n return undefined;\n return Point3d.create(Geometry.interpolate(this.getXAtUncheckedPointIndex(index0), fraction, this.getXAtUncheckedPointIndex(index1)),\n Geometry.interpolate(this.getYAtUncheckedPointIndex(index0), fraction, this.getYAtUncheckedPointIndex(index1)),\n Geometry.interpolate(this.getZAtUncheckedPointIndex(index0), fraction, this.getZAtUncheckedPointIndex(index1)), result);\n }\n\n /** access x of indexed point */\n public abstract getXAtUncheckedPointIndex(pointIndex: number): number;\n\n /** access y of indexed point */\n public abstract getYAtUncheckedPointIndex(pointIndex: number): number;\n\n /** access z of indexed point */\n public abstract getZAtUncheckedPointIndex(pointIndex: number): number;\n\n /** Return iterator over the points in this collection. Usage:\n * ```ts\n * for (const point: Point3d of collection.points) { ... }\n * ```\n */\n public get points(): Iterable<Point3d> {\n return new PointsIterator(this);\n }\n /** convert to Point3d[] */\n public getArray(): Point3d[] {\n const result = [];\n for (const p of this.points)\n result.push(p);\n return result;\n }\n /** Return the first point, or undefined if the array is empty. */\n public front(result?: Point3d): Point3d | undefined {\n if (this.length === 0)\n return undefined;\n return this.getPoint3dAtUncheckedPointIndex(0, result);\n }\n /** Return the last point, or undefined if the array is empty. */\n public back(result?: Point3d): Point3d | undefined {\n if (this.length === 0)\n return undefined;\n return this.getPoint3dAtUncheckedPointIndex(this.length - 1, result);\n }\n /**\n * Test whether the indexed points are equal within tolerance.\n * @param index0 index of first point\n * @param index1 index of second point\n * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`.\n * @returns whether the points are equal within tolerance, or `undefined` if either index is invalid.\n */\n public almostEqualIndexIndex(index0: number, index1: number, tolerance = Geometry.smallMetricDistance): boolean | undefined {\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\n return undefined;\n return Geometry.isSameCoordinate(this.getXAtUncheckedPointIndex(index0), this.getXAtUncheckedPointIndex(index1), tolerance)\n && Geometry.isSameCoordinate(this.getYAtUncheckedPointIndex(index0), this.getYAtUncheckedPointIndex(index1), tolerance)\n && Geometry.isSameCoordinate(this.getZAtUncheckedPointIndex(index0), this.getZAtUncheckedPointIndex(index1), tolerance);\n }\n /**\n * Test whether the xy-coordinates of the indexed points are equal within tolerance. The z-coordinates are ignored.\n * @param index0 index of first point\n * @param index1 index of second point\n * @param tolerance max coordinate difference to be considered equal. For exact test, pass 0. Defaults to `Geometry.smallMetricDistance`.\n * @returns whether the xy-coordinates of the points are equal within tolerance, or `undefined` if either index is invalid.\n */\n public almostEqualXYIndexIndex(index0: number, index1: number, tolerance = Geometry.smallMetricDistance): boolean | undefined {\n if (index0 < 0 || index0 >= this.length || index1 < 0 || index1 >= this.length)\n return undefined;\n return Geometry.isSameCoordinate(this.getXAtUncheckedPointIndex(index0), this.getXAtUncheckedPointIndex(index1), tolerance)\n && Geometry.isSameCoordinate(this.getYAtUncheckedPointIndex(index0), this.getYAtUncheckedPointIndex(index1), tolerance);\n }\n}\n/**\n * abstract base class extends IndexedXYZCollection, adding methods to push, peek, and pop, and rewrite.\n * @public\n */\nexport abstract class IndexedReadWriteXYZCollection extends IndexedXYZCollection {\n /** push a (clone of) point onto the collection\n * * point itself is not pushed -- xyz data is extracted into the native form of the collection.\n */\n public abstract push(data: XYAndZ): void;\n /**\n * push a new point (given by coordinates) onto the collection\n * @param x x coordinate\n * @param y y coordinate\n * @param z z coordinate\n */\n public abstract pushXYZ(x?: number, y?: number, z?: number): void;\n /** remove the final point. */\n public abstract pop(): void;\n /** clear all entries */\n public abstract clear(): void;\n /** reverse the points in place. */\n public abstract reverseInPlace(): void;\n}\n\n/**\n * Type for use as signature for xyz data of a single linestring appearing in a parameter list.\n * @public\n */\nexport type LineStringDataVariant = IndexedXYZCollection | XYAndZ[] | XAndY[] | number[][];\n\n/**\n * Type for use as signature for multiple xyz data of multiple linestrings appearing in a parameter list.\n * @public\n */\nexport type MultiLineStringDataVariant = LineStringDataVariant | LineStringDataVariant[];\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module CartesianGeometry
3
3
  */
4
4
  import { CurveLocationDetailPair } from "../curve/CurveLocationDetail";
5
- import { BeJSONFunctions } from "../Geometry";
5
+ import { BeJSONFunctions, PerpParallelOptions } from "../Geometry";
6
6
  import { Plane3dByOriginAndUnitNormal } from "./Plane3dByOriginAndUnitNormal";
7
7
  import { Point3d, Vector3d } from "./Point3dVector3d";
8
8
  import { Range1d, Range3d } from "./Range";
@@ -39,12 +39,10 @@ export declare class Ray3d implements BeJSONFunctions {
39
39
  /** Create a ray with all zeros. */
40
40
  static createZero(result?: Ray3d): Ray3d;
41
41
  /**
42
- * Test for nearly equal Ray3d objects.
43
- * * This tests for near equality of origin and direction -- i.e. member-by-member comparison.
44
- * * Use [[isAlmostEqualPointSet]] to allow origins to be anywhere along the common ray and to have to allow the
45
- * directions to be scaled or opposing.
42
+ * Test for nearly equal Ray3d objects by comparing their origin and direction members.
43
+ * @see [[isAlmostEqualPointSet]] to test for rays on the same infinite line.
46
44
  */
47
- isAlmostEqual(other: Ray3d): boolean;
45
+ isAlmostEqual(other: Ray3d, tolerance?: number): boolean;
48
46
  /**
49
47
  * Return the dot product of the ray's direction vector with a vector from the ray origin
50
48
  * to the `spacePoint`.
@@ -58,10 +56,10 @@ export declare class Ray3d implements BeJSONFunctions {
58
56
  /** Return the `spacePoint` projected onto the ray. */
59
57
  projectPointToRay(spacePoint: Point3d): Point3d;
60
58
  /**
61
- * Test for nearly equal rays, allowing origin float and direction scaling.
62
- * * Use [[isAlmostEqual]] to require member-by-member comparison.
59
+ * Test for rays that describe the same infinite line.
60
+ * @see [[isAlmostEqual]] for member-by-member comparison.
63
61
  */
64
- isAlmostEqualPointSet(other: Ray3d): boolean;
62
+ isAlmostEqualPointSet(other: Ray3d, options?: PerpParallelOptions): boolean;
65
63
  /** Create a ray from origin and direction. */
66
64
  static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d;
67
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Ray3d.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAA+C,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAa,eAAe,EAAY,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGpC;;;;;;GAMG;AACH,qBAAa,KAAM,YAAW,eAAe;IAC3C,qBAAqB;IACd,MAAM,EAAE,OAAO,CAAC;IACvB,0EAA0E;IACnE,SAAS,EAAE,QAAQ,CAAC;IAC3B,0BAA0B;IACnB,CAAC,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAW;IAEtC,OAAO;IAKP,OAAO,CAAC,MAAM,CAAC,OAAO;IAGtB,kCAAkC;WACpB,WAAW,IAAI,KAAK;IAGlC,kCAAkC;WACpB,WAAW,IAAI,KAAK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EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAC/E,KAAK;CAcT"}
@@ -65,13 +65,11 @@ export class Ray3d {
65
65
  return new Ray3d(Point3d.createZero(), Vector3d.createZero());
66
66
  }
67
67
  /**
68
- * Test for nearly equal Ray3d objects.
69
- * * This tests for near equality of origin and direction -- i.e. member-by-member comparison.
70
- * * Use [[isAlmostEqualPointSet]] to allow origins to be anywhere along the common ray and to have to allow the
71
- * directions to be scaled or opposing.
68
+ * Test for nearly equal Ray3d objects by comparing their origin and direction members.
69
+ * @see [[isAlmostEqualPointSet]] to test for rays on the same infinite line.
72
70
  */
73
- isAlmostEqual(other) {
74
- return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);
71
+ isAlmostEqual(other, tolerance = Geometry.smallMetricDistance) {
72
+ return this.origin.isAlmostEqual(other.origin, tolerance) && this.direction.isAlmostEqual(other.direction, tolerance);
75
73
  }
76
74
  /**
77
75
  * Return the dot product of the ray's direction vector with a vector from the ray origin
@@ -99,27 +97,19 @@ export class Ray3d {
99
97
  return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));
100
98
  }
101
99
  /**
102
- * Test for nearly equal rays, allowing origin float and direction scaling.
103
- * * Use [[isAlmostEqual]] to require member-by-member comparison.
100
+ * Test for rays that describe the same infinite line.
101
+ * @see [[isAlmostEqual]] for member-by-member comparison.
104
102
  */
105
- isAlmostEqualPointSet(other) {
106
- /**
107
- * This function tests two rays to determine if they define the same infinite lines.
108
- * So the origins can be different as long as they are on the infinite line (they can
109
- * "float") but the directions must be parallel or antiparallel.
110
- */
111
- if (!this.direction.isParallelTo(other.direction, true))
103
+ isAlmostEqualPointSet(other, options) {
104
+ if (!this.direction.isParallelTo(other.direction, true, false, options))
112
105
  return false;
113
- /**
114
- * In exact math, we consider a ray to have an infinite line as direction (not a finite vector).
115
- * Therefore, in exact math it is not possible for one origin to be on the other ray but not vice
116
- * versa. However, we test both ways because first check may pass due to round-off errors.
117
- */
106
+ const tol2 = options?.distanceSquaredTol ?? Geometry.smallMetricDistanceSquared;
107
+ // theoretically, one test below is sufficient, but perform both in case the first passes because of round-off
118
108
  let workPoint = this.projectPointToRay(other.origin);
119
- if (!other.origin.isAlmostEqualMetric(workPoint))
109
+ if (other.origin.distanceSquared(workPoint) > tol2)
120
110
  return false;
121
111
  workPoint = other.projectPointToRay(this.origin);
122
- if (!this.origin.isAlmostEqualMetric(workPoint))
112
+ if (this.origin.distanceSquared(workPoint) > tol2)
123
113
  return false;
124
114
  return true;
125
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAE,SAAS,EAAmB,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAW,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,qBAAqB;AACrB;;;;;;GAMG;AACH,MAAM,OAAO,KAAK;IAChB,qBAAqB;IACd,MAAM,CAAU;IACvB,0EAA0E;IACnE,SAAS,CAAW;IAC3B,0BAA0B;IACnB,CAAC,CAAU,CAAC,yBAAyB;IACpC,MAAM,CAAC,YAAY,CAAY;IAC/B,MAAM,CAAC,YAAY,CAAY;IAC/B,MAAM,CAAC,YA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AC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,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 CartesianGeometry\n */\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\nimport { SmallSystem } from \"../numerics/SmallSystem\";\nimport { Matrix3d } from \"./Matrix3d\";\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\nimport { Vector2d } from \"./Point2dVector2d\";\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\nimport { Range1d, Range3d } from \"./Range\";\nimport { Transform } from \"./Transform\";\nimport { XYAndZ } from \"./XYZProps\";\n\n// cspell:word Cramer\n/**\n * A Ray3d contains\n * * an `origin` point.\n * * a `direction` vector (The vector is not required to be normalized).\n * * an optional weight (number).\n * @public\n */\nexport class Ray3d implements BeJSONFunctions {\n /** The ray origin */\n public origin: Point3d;\n /** The ray direction. This is commonly (but not always) a unit vector. */\n public direction: Vector3d;\n /** Numeric annotation. */\n public a?: number; // optional (e.g. weight)\n private static _workVector0?: Vector3d;\n private static _workVector1?: Vector3d;\n private static _workVector2?: Vector3d;\n private static _workVector3?: Vector3d;\n private static _workVector4?: Vector3d;\n private static _workMatrix?: Matrix3d;\n // constructor (captures references)\n private constructor(origin: Point3d, direction: Vector3d) {\n this.origin = origin;\n this.direction = direction;\n this.a = undefined;\n }\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\n }\n /** Create a ray on the x axis. */\n public static createXAxis(): Ray3d {\n return Ray3d._create(0, 0, 0, 1, 0, 0);\n }\n /** Create a ray on the y axis. */\n public static createYAxis(): Ray3d {\n return Ray3d._create(0, 0, 0, 0, 1, 0);\n }\n /** Create a ray on the z axis. */\n public static createZAxis(): Ray3d {\n return Ray3d._create(0, 0, 0, 0, 0, 1);\n }\n /** Create a ray with all zeros. */\n public static createZero(result?: Ray3d): Ray3d {\n if (result) {\n result.origin.setZero();\n result.direction.setZero();\n return result;\n }\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\n }\n /**\n * Test for nearly equal Ray3d objects.\n * * This tests for near equality of origin and direction -- i.e. member-by-member comparison.\n * * Use [[isAlmostEqualPointSet]] to allow origins to be anywhere along the common ray and to have to allow the\n * directions to be scaled or opposing.\n */\n public isAlmostEqual(other: Ray3d): boolean {\n return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);\n }\n /**\n * Return the dot product of the ray's direction vector with a vector from the ray origin\n * to the `spacePoint`.\n * * If the instance is the unit normal of a plane, then this method returns the (signed) altitude\n * of `spacePoint` with respect to the plane.\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane\n */\n public dotProductToPoint(spacePoint: Point3d): number {\n return this.direction.dotProductStartEnd(this.origin, spacePoint);\n }\n /** Return the fractional coordinate (along the direction vector) of the `spacePoint` projected to the ray. */\n public pointToFraction(spacePoint: Point3d): number {\n return Geometry.safeDivideFraction(\n this.dotProductToPoint(spacePoint),\n this.direction.magnitudeSquared(),\n 0,\n );\n }\n /** Return the `spacePoint` projected onto the ray. */\n public projectPointToRay(spacePoint: Point3d): Point3d {\n /**\n * To project a point to the ray, we can create a vector called \"v\" from ray origin to the spacePoint and project\n * that vector to the ray direction vector \"r\". The projection is \"((v.r)/||r||^2) r\" where \"v.r\" is the dot\n * product. Note that pointToFraction returns \"(v.r)/||r||^2\".\n * Note: If r is the normal of a plane, then projection length \"(v.r)/||r||\" is the signed altitude of the\n * spacePoint with respect to the plane.\n */\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\n }\n /**\n * Test for nearly equal rays, allowing origin float and direction scaling.\n * * Use [[isAlmostEqual]] to require member-by-member comparison.\n */\n public isAlmostEqualPointSet(other: Ray3d): boolean {\n /**\n * This function tests two rays to determine if they define the same infinite lines.\n * So the origins can be different as long as they are on the infinite line (they can\n * \"float\") but the directions must be parallel or antiparallel.\n */\n if (!this.direction.isParallelTo(other.direction, true))\n return false;\n /**\n * In exact math, we consider a ray to have an infinite line as direction (not a finite vector).\n * Therefore, in exact math it is not possible for one origin to be on the other ray but not vice\n * versa. However, we test both ways because first check may pass due to round-off errors.\n */\n let workPoint = this.projectPointToRay(other.origin);\n if (!other.origin.isAlmostEqualMetric(workPoint))\n return false;\n workPoint = other.projectPointToRay(this.origin);\n if (!this.origin.isAlmostEqualMetric(workPoint))\n return false;\n return true;\n }\n /** Create a ray from origin and direction. */\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\n if (result) {\n result.set(origin, direction);\n return result;\n }\n return new Ray3d(origin.clone(), direction.clone());\n }\n /**\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian\n * coordinates and derivatives.\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\n * @param weightedDerivative `[x,y,z,w]` derivatives\n * @param result\n */\n public static createWeightedDerivative(\n weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d,\n ): Ray3d | undefined {\n const w = weightedPoint[3];\n const dw = weightedDerivative[3];\n const x = weightedPoint[0];\n const y = weightedPoint[1];\n const z = weightedPoint[2];\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\n if (Geometry.isSmallMetricDistance(w))\n return undefined;\n const divW = 1.0 / w;\n const divWW = divW * divW;\n return Ray3d.createXYZUVW(\n x * divW, y * divW, z * divW,\n dx * divWW, dy * divWW, dz * divWW,\n result,\n );\n }\n /** Create from coordinates of the origin and direction. */\n public static createXYZUVW(\n originX: number, originY: number, originZ: number,\n directionX: number, directionY: number, directionZ: number,\n result?: Ray3d,\n ): Ray3d {\n if (result) {\n result.getOriginRef().set(originX, originY, originZ);\n result.getDirectionRef().set(directionX, directionY, directionZ);\n return result;\n }\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\n }\n /** Capture origin and direction in a new Ray3d. */\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\n return new Ray3d(origin, direction);\n }\n /** Create from (clones of) origin, direction, and numeric weight. */\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\n if (result) {\n result.origin.setFrom(origin);\n result.direction.setFrom(direction);\n result.a = a;\n return result;\n }\n result = new Ray3d(origin.clone(), direction.clone());\n result.a = a;\n return result;\n }\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\n if (result) {\n result.origin.setFrom(origin);\n result.direction.setStartEnd(origin, target);\n return result;\n }\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\n }\n /** Return a reference to the ray's origin. */\n public getOriginRef(): Point3d {\n return this.origin;\n }\n /** Return a reference to the ray's direction vector. */\n public getDirectionRef(): Vector3d {\n return this.direction;\n }\n /** Copy coordinates from origin and direction. */\n public set(origin: Point3d, direction: Vector3d): void {\n this.origin.setFrom(origin);\n this.direction.setFrom(direction);\n }\n /** Clone the ray. */\n public clone(result?: Ray3d): Ray3d {\n if (result) {\n result.set(this.origin.clone(), this.direction.clone());\n return result;\n }\n return new Ray3d(this.origin.clone(), this.direction.clone());\n }\n /** Return a clone of the transformed instance */\n public cloneTransformed(transform: Transform, result?: Ray3d): Ray3d {\n return Ray3d.create(\n transform.multiplyPoint3d(this.origin, result?.origin),\n transform.multiplyVector(this.direction, result?.direction),\n result,\n );\n }\n /** Create a clone and return the inverse transform of the clone. */\n public cloneInverseTransformed(transform: Transform, result?: Ray3d): Ray3d | undefined {\n if (!transform.computeCachedInverse(true))\n return undefined;\n return Ray3d.create(\n transform.multiplyInversePoint3d(this.origin, result?.origin)!,\n transform.matrix.multiplyInverseXYZAsVector3d(\n this.direction.x, this.direction.y, this.direction.z, result?.direction,\n )!,\n result,\n );\n }\n /** Apply a transform in place. */\n public transformInPlace(transform: Transform) {\n transform.multiplyPoint3d(this.origin, this.origin);\n transform.multiplyVector(this.direction, this.direction);\n }\n /** Copy data from another ray. */\n public setFrom(source: Ray3d): void {\n this.set(source.origin, source.direction);\n }\n /**\n * Return a point at fractional position along the ray.\n * * fraction 0 is the ray origin.\n * * fraction 1 is at the end of the direction vector when placed at the origin.\n */\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\n return this.origin.plusScaled(this.direction, fraction, result);\n }\n /**\n * Return a transform for rigid axes at ray origin with z in ray direction.\n * * If the direction vector is zero, axes default to identity (from [[Matrix3d.createRigidHeadsUp]])\n */\n public toRigidZFrame(result?: Transform): Transform {\n const axes = Ray3d._workMatrix = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY, Ray3d._workMatrix);\n return Transform.createOriginAndMatrix(this.origin, axes, result);\n }\n /** Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d. */\n public setFromJSON(json?: any) {\n if (!json) {\n this.origin.set(0, 0, 0);\n this.direction.set(0, 0, 1);\n return;\n }\n this.origin.setFromJSON(json.origin);\n this.direction.setFromJSON(json.direction);\n }\n /**\n * Construct a JSON object from this Ray3d.\n * @return {*} [origin,normal]\n */\n public toJSON(): any {\n return { origin: this.origin.toJSON(), direction: this.direction.toJSON() };\n }\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\n public static fromJSON(json?: any) {\n const result = Ray3d.createXAxis();\n result.setFromJSON(json);\n return result;\n }\n /**\n * Try to scale the direction vector to a given `magnitude`.\n * * Returns `false` if the ray direction is a zero vector.\n */\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\n if (this.direction.tryNormalizeInPlace()) {\n this.direction.scaleInPlace(magnitude);\n return true;\n }\n this.direction.setZero();\n this.a = 0.0;\n return false;\n }\n /**\n * Normalize the ray direction in place.\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\n * * Save the parameter `a` as the optional `a` member of the ray.\n * * Normalize the ray's direction vector.\n * * If parameter `a` is nearly zero,\n * * Set the `a` member to zero.\n * * Set the ray's direction vector to zero.\n * @param a value to be saved (e.g,. area).\n * @returns `true` if `a` is nonzero and normalization was successful. Otherwise, return `false`.\n */\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\n const tolerance = Geometry.smallMetricDistanceSquared;\n this.a = a;\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\n return true;\n this.direction.setZero();\n this.a = 0.0;\n return false;\n }\n /** Return distance from the ray to point in space. */\n public distance(spacePoint: Point3d): number {\n const uu = this.direction.magnitudeSquared();\n const uv = this.dotProductToPoint(spacePoint);\n const aa = Geometry.inverseMetricDistanceSquared(uu);\n if (aa)\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\n else\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\n }\n /**\n * Return the intersection parameter of the line defined by the ray with a `plane`.\n * * Stores the point of intersection in the `result` point (if passed as a parameter) and returns the parameter\n * along the ray where the intersection occurs. If we call the parameter 'f' then the point of intersection would\n * be `ray.origin + f * ray.direction`. Therefore:\n * * if ray intersects the plane at its origin, the function returns f = 0.\n * * if intersects at `ray.origin + ray.direction`, the function returns f = 1.\n * * if intersects behind the ray origin, the function returns f < 0.\n * * if intersects after `ray.origin + ray.direction`, the function returns f > 1.\n * * Returns `undefined` if the ray and plane are parallel or coplanar.\n */\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\n const nDotN = this.direction.magnitudeSquared();\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\n if (undefined === division)\n return undefined;\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\n if (undefined === division1)\n return undefined;\n if (result) {\n this.origin.plusScaled(this.direction, division, result);\n }\n return division;\n }\n /**\n * Find the intersection of the line defined by the ray with a Range3d.\n * * Return the range of parameters (on the ray) which are \"inside\" the range.\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.isNull`.\n */\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\n if (range.isNull)\n return Range1d.createNull(result);\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z)\n )\n return interval;\n return interval;\n }\n /**\n * Compute the intersection of the ray with a triangle.\n * * This method is faster than `BarycentricTriangle.intersectRay3d`.\n * @param vertex0 first vertex of the triangle\n * @param vertex1 second vertex of the triangle\n * @param vertex2 third vertex of the triangle\n * @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line\n * intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)\n * @param parameterTol optional tolerance used to allow intersections just beyond an edge/vertex in barycentric\n * coordinate space (if tolerance is not provided, Geometry.smallFloatingPoint is used)\n * @param result optional pre-allocated object to fill and return\n * @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.\n */\n public intersectionWithTriangle(\n vertex0: Point3d, vertex1: Point3d, vertex2: Point3d, distanceTol?: number, parameterTol?: number, result?: Point3d,\n ): Point3d | undefined {\n /**\n * Let (w,u,v) be the barycentric coordinates of point P wrt the triangle (v0,v1,v2), such that\n * P = w*v0 + u*v1 + v*v2 = (1-u-v)*v0 + u*v1 + v*v2 = v0 + u*(v1-v0) + v*(v2-v0)\n *\n * Then if the ray given by rayOrigin + t*rayVector intersects the triangle at P, we have\n * v0 + u*(v1-v0) + v*(v2-v0) = rayOrigin + t*rayVector\n *\n * This equation can be reformulated as the following linear system:\n *\n * [ | | | ] [t] [ | ]\n * [-rayVector v1-v0 v2-v0] [u] = [rayOrigin - v0]\n * [ | | | ] [v] [ | ]\n *\n * Then to find t, u, and v, use Cramer's Rule, the formulation of matrix determinant as column triple product,\n * and the fact that swapping any 2 vectors in the triple product negates it:\n *\n * t = (v2-v0).(rayOrigin - v0) x (v1-v0) / (v1-v0).rayVector x (v2-v0)\n * u = (rayOrigin - v0).rayVector x (v2-v0) / (v1-v0).rayVector x (v2-v0)\n * v = -rayVector.(rayOrigin - v0) x (v1-v0) / (v1-v0).rayVector x (v2-v0)\n *\n * Note that we verify 0 <= u,v,w <= 1. To do so we only need to check 0 <= u <= 1, 0 <= v, and u+v <= 1:\n * these 4 checks guarantee that v <= 1 and 0 <= u+v, and so with w = 1-(u+v), we have 0 <= w <= 1.\n *\n * More info be found at https://en.wikipedia.org/wiki/Moller-Trumbore_intersection_algorithm.\n */\n if (distanceTol === undefined || distanceTol < 0) // we explicitly allow zero tolerance\n distanceTol = Geometry.smallMetricDistance;\n if (parameterTol === undefined || parameterTol < 0) // we explicitly allow zero tolerance\n parameterTol = Geometry.smallFloatingPoint;\n const edge1 = Ray3d._workVector0 = Vector3d.createStartEnd(vertex0, vertex1, Ray3d._workVector0);\n const edge2 = Ray3d._workVector1 = Vector3d.createStartEnd(vertex0, vertex2, Ray3d._workVector1);\n const h = Ray3d._workVector2 = this.direction.crossProduct(edge2, Ray3d._workVector2);\n const a = edge1.dotProduct(h);\n if (a >= -distanceTol && a <= distanceTol)\n return undefined; // ray is parallel to the triangle (includes coplanar case)\n const f = 1.0 / a;\n const s = Ray3d._workVector3 = Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);\n let u = f * s.dotProduct(h);\n if (u < 0.0) {\n if (u >= -parameterTol)\n u = 0.0;\n else\n return undefined; // ray does not intersect the triangle\n } else if (u > 1.0) {\n if (u <= 1.0 + parameterTol)\n u = 1.0;\n else\n return undefined; // ray does not intersect the triangle\n }\n const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);\n let v = f * this.direction.dotProduct(q);\n if (v < 0.0) {\n if (v >= -parameterTol)\n v = 0.0;\n else\n return undefined; // ray does not intersect the triangle\n } else if (u + v > 1.0 + parameterTol) {\n return undefined; // ray does not intersect the triangle\n }\n // at this stage, we know the line (parameterized as the ray) intersects the triangle\n const t = f * edge2.dotProduct(q);\n if (t < -distanceTol) // line intersection but not ray intersection\n return undefined;\n return this.origin.plusScaled(this.direction, t, result); // ray intersection\n }\n /**\n * Return the shortest vector `v` to `targetPoint` from the line defined by this ray.\n * * If the projection of `targetPoint` onto the line defined by this ray is q, then `v  = targetPoint - q`.\n */\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\n const uu = this.direction.magnitudeSquared();\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\n return vectorV.plusScaled(this.direction, -fraction, result);\n }\n /**\n * Determine if two rays intersect, or are fully overlapped, or parallel but not coincident, or skew.\n * * Return a CurveLocationDetailPair which contains fraction and point on each ray and has\n * annotation (in member `approachType`) indicating one of these relationships:\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated\n * in detailA and detailB\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach.\n * The rays are skew in space.\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The\n * fractions and points are a representative single common point.\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are\n * at the minimum distance\n */\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\n const intersectionFractions = Vector2d.create();\n let fractionA, fractionB;\n let pointA, pointB;\n let pairType;\n if (\n SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z,\n intersectionFractions,\n )\n ) {\n fractionA = intersectionFractions.x;\n fractionB = intersectionFractions.y;\n pointA = rayA.fractionToPoint(fractionA);\n pointB = rayB.fractionToPoint(fractionB);\n pairType = pointA.isAlmostEqualMetric(pointB) ?\n CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\n } else {\n fractionB = 0.0;\n fractionA = rayA.pointToFraction(rayB.origin);\n pointA = rayA.fractionToPoint(fractionA);\n pointB = rayB.fractionToPoint(fractionB);\n pairType = pointA.isAlmostEqualMetric(pointB) ?\n CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\n }\n const pair = CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\n pair.approachType = pairType;\n return pair;\n }\n /**\n * Return a ray with `ray.origin` interpolated between `pt1` and `pt2` at the given `fraction`\n * and `ray.direction` set to the vector from `pt1` to `pt2` multiplied by the given `tangentScale`.\n * @param pt1 start point of the interpolation.\n * @param fraction fractional position between points.\n * @param pt2 end point of the interpolation.\n * @param tangentScale scale factor to apply to the startToEnd vector.\n * @param result optional receiver.\n */\n public static interpolatePointAndTangent(\n pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d,\n ): Ray3d {\n result = result ?? Ray3d.createZero();\n const dx = pt2.x - pt1.x;\n const dy = pt2.y - pt1.y;\n const dz = pt2.z - pt1.z;\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\n if (fraction <= 0.5)\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\n else {\n const t: number = fraction - 1.0;\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\n }\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAE,SAAS,EAAmB,QAAQ,EAAuB,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAW,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,qBAAqB;AACrB;;;;;;GAMG;AACH,MAAM,OAAO,KAAK;IAChB,qBAAqB;IACd,MAAM,CAAU;IACvB,0EAA0E;IACnE,SAAS,CAAW;IAC3B,0BAA0B;IACnB,CAAC,CAAU,CAAC,yBAAyB;IACpC,MAAM,CAAC,YAAY,CAAY;IAC/B,MAAM,CAAC,YAAY,CAAY;IAC/B,MAAM,CAAC,YAAY,CAAY;IAC/B,MAAM,CAAC,YAAY,CAAY;IAC/B,MAAM,CAAC,YAAY,CAAY;IAC/B,MAAM,CAAC,WAAW,CAAY;IACtC,oCAAoC;IACpC,YAAoB,MAAe,EAAE,SAAmB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB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GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,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 CartesianGeometry\n */\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\nimport { AxisOrder, BeJSONFunctions, Geometry, PerpParallelOptions } from \"../Geometry\";\nimport { SmallSystem } from \"../numerics/SmallSystem\";\nimport { Matrix3d } from \"./Matrix3d\";\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\nimport { Vector2d } from \"./Point2dVector2d\";\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\nimport { Range1d, Range3d } from \"./Range\";\nimport { Transform } from \"./Transform\";\nimport { XYAndZ } from \"./XYZProps\";\n\n// cspell:word Cramer\n/**\n * A Ray3d contains\n * * an `origin` point.\n * * a `direction` vector (The vector is not required to be normalized).\n * * an optional weight (number).\n * @public\n */\nexport class Ray3d implements BeJSONFunctions {\n /** The ray origin */\n public origin: Point3d;\n /** The ray direction. This is commonly (but not always) a unit vector. */\n public direction: Vector3d;\n /** Numeric annotation. */\n public a?: number; // optional (e.g. weight)\n private static _workVector0?: Vector3d;\n private static _workVector1?: Vector3d;\n private static _workVector2?: Vector3d;\n private static _workVector3?: Vector3d;\n private static _workVector4?: Vector3d;\n private static _workMatrix?: Matrix3d;\n // constructor (captures references)\n private constructor(origin: Point3d, direction: Vector3d) {\n this.origin = origin;\n this.direction = direction;\n this.a = undefined;\n }\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\n }\n /** Create a ray on the x axis. */\n public static createXAxis(): Ray3d {\n return Ray3d._create(0, 0, 0, 1, 0, 0);\n }\n /** Create a ray on the y axis. */\n public static createYAxis(): Ray3d {\n return Ray3d._create(0, 0, 0, 0, 1, 0);\n }\n /** Create a ray on the z axis. */\n public static createZAxis(): Ray3d {\n return Ray3d._create(0, 0, 0, 0, 0, 1);\n }\n /** Create a ray with all zeros. */\n public static createZero(result?: Ray3d): Ray3d {\n if (result) {\n result.origin.setZero();\n result.direction.setZero();\n return result;\n }\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\n }\n /**\n * Test for nearly equal Ray3d objects by comparing their origin and direction members.\n * @see [[isAlmostEqualPointSet]] to test for rays on the same infinite line.\n */\n public isAlmostEqual(other: Ray3d, tolerance: number = Geometry.smallMetricDistance): boolean {\n return this.origin.isAlmostEqual(other.origin, tolerance) && this.direction.isAlmostEqual(other.direction, tolerance);\n }\n /**\n * Return the dot product of the ray's direction vector with a vector from the ray origin\n * to the `spacePoint`.\n * * If the instance is the unit normal of a plane, then this method returns the (signed) altitude\n * of `spacePoint` with respect to the plane.\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane\n */\n public dotProductToPoint(spacePoint: Point3d): number {\n return this.direction.dotProductStartEnd(this.origin, spacePoint);\n }\n /** Return the fractional coordinate (along the direction vector) of the `spacePoint` projected to the ray. */\n public pointToFraction(spacePoint: Point3d): number {\n return Geometry.safeDivideFraction(\n this.dotProductToPoint(spacePoint),\n this.direction.magnitudeSquared(),\n 0,\n );\n }\n /** Return the `spacePoint` projected onto the ray. */\n public projectPointToRay(spacePoint: Point3d): Point3d {\n /**\n * To project a point to the ray, we can create a vector called \"v\" from ray origin to the spacePoint and project\n * that vector to the ray direction vector \"r\". The projection is \"((v.r)/||r||^2) r\" where \"v.r\" is the dot\n * product. Note that pointToFraction returns \"(v.r)/||r||^2\".\n * Note: If r is the normal of a plane, then projection length \"(v.r)/||r||\" is the signed altitude of the\n * spacePoint with respect to the plane.\n */\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\n }\n /**\n * Test for rays that describe the same infinite line.\n * @see [[isAlmostEqual]] for member-by-member comparison.\n */\n public isAlmostEqualPointSet(other: Ray3d, options?: PerpParallelOptions): boolean {\n if (!this.direction.isParallelTo(other.direction, true, false, options))\n return false;\n const tol2 = options?.distanceSquaredTol ?? Geometry.smallMetricDistanceSquared;\n // theoretically, one test below is sufficient, but perform both in case the first passes because of round-off\n let workPoint = this.projectPointToRay(other.origin);\n if (other.origin.distanceSquared(workPoint) > tol2)\n return false;\n workPoint = other.projectPointToRay(this.origin);\n if (this.origin.distanceSquared(workPoint) > tol2)\n return false;\n return true;\n }\n /** Create a ray from origin and direction. */\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\n if (result) {\n result.set(origin, direction);\n return result;\n }\n return new Ray3d(origin.clone(), direction.clone());\n }\n /**\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian\n * coordinates and derivatives.\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\n * @param weightedDerivative `[x,y,z,w]` derivatives\n * @param result\n */\n public static createWeightedDerivative(\n weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d,\n ): Ray3d | undefined {\n const w = weightedPoint[3];\n const dw = weightedDerivative[3];\n const x = weightedPoint[0];\n const y = weightedPoint[1];\n const z = weightedPoint[2];\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\n if (Geometry.isSmallMetricDistance(w))\n return undefined;\n const divW = 1.0 / w;\n const divWW = divW * divW;\n return Ray3d.createXYZUVW(\n x * divW, y * divW, z * divW,\n dx * divWW, dy * divWW, dz * divWW,\n result,\n );\n }\n /** Create from coordinates of the origin and direction. */\n public static createXYZUVW(\n originX: number, originY: number, originZ: number,\n directionX: number, directionY: number, directionZ: number,\n result?: Ray3d,\n ): Ray3d {\n if (result) {\n result.getOriginRef().set(originX, originY, originZ);\n result.getDirectionRef().set(directionX, directionY, directionZ);\n return result;\n }\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\n }\n /** Capture origin and direction in a new Ray3d. */\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\n return new Ray3d(origin, direction);\n }\n /** Create from (clones of) origin, direction, and numeric weight. */\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\n if (result) {\n result.origin.setFrom(origin);\n result.direction.setFrom(direction);\n result.a = a;\n return result;\n }\n result = new Ray3d(origin.clone(), direction.clone());\n result.a = a;\n return result;\n }\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\n if (result) {\n result.origin.setFrom(origin);\n result.direction.setStartEnd(origin, target);\n return result;\n }\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\n }\n /** Return a reference to the ray's origin. */\n public getOriginRef(): Point3d {\n return this.origin;\n }\n /** Return a reference to the ray's direction vector. */\n public getDirectionRef(): Vector3d {\n return this.direction;\n }\n /** Copy coordinates from origin and direction. */\n public set(origin: Point3d, direction: Vector3d): void {\n this.origin.setFrom(origin);\n this.direction.setFrom(direction);\n }\n /** Clone the ray. */\n public clone(result?: Ray3d): Ray3d {\n if (result) {\n result.set(this.origin.clone(), this.direction.clone());\n return result;\n }\n return new Ray3d(this.origin.clone(), this.direction.clone());\n }\n /** Return a clone of the transformed instance */\n public cloneTransformed(transform: Transform, result?: Ray3d): Ray3d {\n return Ray3d.create(\n transform.multiplyPoint3d(this.origin, result?.origin),\n transform.multiplyVector(this.direction, result?.direction),\n result,\n );\n }\n /** Create a clone and return the inverse transform of the clone. */\n public cloneInverseTransformed(transform: Transform, result?: Ray3d): Ray3d | undefined {\n if (!transform.computeCachedInverse(true))\n return undefined;\n return Ray3d.create(\n transform.multiplyInversePoint3d(this.origin, result?.origin)!,\n transform.matrix.multiplyInverseXYZAsVector3d(\n this.direction.x, this.direction.y, this.direction.z, result?.direction,\n )!,\n result,\n );\n }\n /** Apply a transform in place. */\n public transformInPlace(transform: Transform) {\n transform.multiplyPoint3d(this.origin, this.origin);\n transform.multiplyVector(this.direction, this.direction);\n }\n /** Copy data from another ray. */\n public setFrom(source: Ray3d): void {\n this.set(source.origin, source.direction);\n }\n /**\n * Return a point at fractional position along the ray.\n * * fraction 0 is the ray origin.\n * * fraction 1 is at the end of the direction vector when placed at the origin.\n */\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\n return this.origin.plusScaled(this.direction, fraction, result);\n }\n /**\n * Return a transform for rigid axes at ray origin with z in ray direction.\n * * If the direction vector is zero, axes default to identity (from [[Matrix3d.createRigidHeadsUp]])\n */\n public toRigidZFrame(result?: Transform): Transform {\n const axes = Ray3d._workMatrix = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY, Ray3d._workMatrix);\n return Transform.createOriginAndMatrix(this.origin, axes, result);\n }\n /** Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d. */\n public setFromJSON(json?: any) {\n if (!json) {\n this.origin.set(0, 0, 0);\n this.direction.set(0, 0, 1);\n return;\n }\n this.origin.setFromJSON(json.origin);\n this.direction.setFromJSON(json.direction);\n }\n /**\n * Construct a JSON object from this Ray3d.\n * @return {*} [origin,normal]\n */\n public toJSON(): any {\n return { origin: this.origin.toJSON(), direction: this.direction.toJSON() };\n }\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\n public static fromJSON(json?: any) {\n const result = Ray3d.createXAxis();\n result.setFromJSON(json);\n return result;\n }\n /**\n * Try to scale the direction vector to a given `magnitude`.\n * * Returns `false` if the ray direction is a zero vector.\n */\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\n if (this.direction.tryNormalizeInPlace()) {\n this.direction.scaleInPlace(magnitude);\n return true;\n }\n this.direction.setZero();\n this.a = 0.0;\n return false;\n }\n /**\n * Normalize the ray direction in place.\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\n * * Save the parameter `a` as the optional `a` member of the ray.\n * * Normalize the ray's direction vector.\n * * If parameter `a` is nearly zero,\n * * Set the `a` member to zero.\n * * Set the ray's direction vector to zero.\n * @param a value to be saved (e.g,. area).\n * @returns `true` if `a` is nonzero and normalization was successful. Otherwise, return `false`.\n */\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\n const tolerance = Geometry.smallMetricDistanceSquared;\n this.a = a;\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\n return true;\n this.direction.setZero();\n this.a = 0.0;\n return false;\n }\n /** Return distance from the ray to point in space. */\n public distance(spacePoint: Point3d): number {\n const uu = this.direction.magnitudeSquared();\n const uv = this.dotProductToPoint(spacePoint);\n const aa = Geometry.inverseMetricDistanceSquared(uu);\n if (aa)\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\n else\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\n }\n /**\n * Return the intersection parameter of the line defined by the ray with a `plane`.\n * * Stores the point of intersection in the `result` point (if passed as a parameter) and returns the parameter\n * along the ray where the intersection occurs. If we call the parameter 'f' then the point of intersection would\n * be `ray.origin + f * ray.direction`. Therefore:\n * * if ray intersects the plane at its origin, the function returns f = 0.\n * * if intersects at `ray.origin + ray.direction`, the function returns f = 1.\n * * if intersects behind the ray origin, the function returns f < 0.\n * * if intersects after `ray.origin + ray.direction`, the function returns f > 1.\n * * Returns `undefined` if the ray and plane are parallel or coplanar.\n */\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\n const nDotN = this.direction.magnitudeSquared();\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\n if (undefined === division)\n return undefined;\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\n if (undefined === division1)\n return undefined;\n if (result) {\n this.origin.plusScaled(this.direction, division, result);\n }\n return division;\n }\n /**\n * Find the intersection of the line defined by the ray with a Range3d.\n * * Return the range of parameters (on the ray) which are \"inside\" the range.\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.isNull`.\n */\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\n if (range.isNull)\n return Range1d.createNull(result);\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z)\n )\n return interval;\n return interval;\n }\n /**\n * Compute the intersection of the ray with a triangle.\n * * This method is faster than `BarycentricTriangle.intersectRay3d`.\n * @param vertex0 first vertex of the triangle\n * @param vertex1 second vertex of the triangle\n * @param vertex2 third vertex of the triangle\n * @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line\n * intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)\n * @param parameterTol optional tolerance used to allow intersections just beyond an edge/vertex in barycentric\n * coordinate space (if tolerance is not provided, Geometry.smallFloatingPoint is used)\n * @param result optional pre-allocated object to fill and return\n * @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.\n */\n public intersectionWithTriangle(\n vertex0: Point3d, vertex1: Point3d, vertex2: Point3d, distanceTol?: number, parameterTol?: number, result?: Point3d,\n ): Point3d | undefined {\n /**\n * Let (w,u,v) be the barycentric coordinates of point P wrt the triangle (v0,v1,v2), such that\n * P = w*v0 + u*v1 + v*v2 = (1-u-v)*v0 + u*v1 + v*v2 = v0 + u*(v1-v0) + v*(v2-v0)\n *\n * Then if the ray given by rayOrigin + t*rayVector intersects the triangle at P, we have\n * v0 + u*(v1-v0) + v*(v2-v0) = rayOrigin + t*rayVector\n *\n * This equation can be reformulated as the following linear system:\n *\n * [ | | | ] [t] [ | ]\n * [-rayVector v1-v0 v2-v0] [u] = [rayOrigin - v0]\n * [ | | | ] [v] [ | ]\n *\n * Then to find t, u, and v, use Cramer's Rule, the formulation of matrix determinant as column triple product,\n * and the fact that swapping any 2 vectors in the triple product negates it:\n *\n * t = (v2-v0).(rayOrigin - v0) x (v1-v0) / (v1-v0).rayVector x (v2-v0)\n * u = (rayOrigin - v0).rayVector x (v2-v0) / (v1-v0).rayVector x (v2-v0)\n * v = -rayVector.(rayOrigin - v0) x (v1-v0) / (v1-v0).rayVector x (v2-v0)\n *\n * Note that we verify 0 <= u,v,w <= 1. To do so we only need to check 0 <= u <= 1, 0 <= v, and u+v <= 1:\n * these 4 checks guarantee that v <= 1 and 0 <= u+v, and so with w = 1-(u+v), we have 0 <= w <= 1.\n *\n * More info be found at https://en.wikipedia.org/wiki/Moller-Trumbore_intersection_algorithm.\n */\n if (distanceTol === undefined || distanceTol < 0) // we explicitly allow zero tolerance\n distanceTol = Geometry.smallMetricDistance;\n if (parameterTol === undefined || parameterTol < 0) // we explicitly allow zero tolerance\n parameterTol = Geometry.smallFloatingPoint;\n const edge1 = Ray3d._workVector0 = Vector3d.createStartEnd(vertex0, vertex1, Ray3d._workVector0);\n const edge2 = Ray3d._workVector1 = Vector3d.createStartEnd(vertex0, vertex2, Ray3d._workVector1);\n const h = Ray3d._workVector2 = this.direction.crossProduct(edge2, Ray3d._workVector2);\n const a = edge1.dotProduct(h);\n if (a >= -distanceTol && a <= distanceTol)\n return undefined; // ray is parallel to the triangle (includes coplanar case)\n const f = 1.0 / a;\n const s = Ray3d._workVector3 = Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);\n let u = f * s.dotProduct(h);\n if (u < 0.0) {\n if (u >= -parameterTol)\n u = 0.0;\n else\n return undefined; // ray does not intersect the triangle\n } else if (u > 1.0) {\n if (u <= 1.0 + parameterTol)\n u = 1.0;\n else\n return undefined; // ray does not intersect the triangle\n }\n const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);\n let v = f * this.direction.dotProduct(q);\n if (v < 0.0) {\n if (v >= -parameterTol)\n v = 0.0;\n else\n return undefined; // ray does not intersect the triangle\n } else if (u + v > 1.0 + parameterTol) {\n return undefined; // ray does not intersect the triangle\n }\n // at this stage, we know the line (parameterized as the ray) intersects the triangle\n const t = f * edge2.dotProduct(q);\n if (t < -distanceTol) // line intersection but not ray intersection\n return undefined;\n return this.origin.plusScaled(this.direction, t, result); // ray intersection\n }\n /**\n * Return the shortest vector `v` to `targetPoint` from the line defined by this ray.\n * * If the projection of `targetPoint` onto the line defined by this ray is q, then `v  = targetPoint - q`.\n */\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\n const uu = this.direction.magnitudeSquared();\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\n return vectorV.plusScaled(this.direction, -fraction, result);\n }\n /**\n * Determine if two rays intersect, or are fully overlapped, or parallel but not coincident, or skew.\n * * Return a CurveLocationDetailPair which contains fraction and point on each ray and has\n * annotation (in member `approachType`) indicating one of these relationships:\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated\n * in detailA and detailB\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach.\n * The rays are skew in space.\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The\n * fractions and points are a representative single common point.\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are\n * at the minimum distance\n */\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\n const intersectionFractions = Vector2d.create();\n let fractionA, fractionB;\n let pointA, pointB;\n let pairType;\n if (\n SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z,\n intersectionFractions,\n )\n ) {\n fractionA = intersectionFractions.x;\n fractionB = intersectionFractions.y;\n pointA = rayA.fractionToPoint(fractionA);\n pointB = rayB.fractionToPoint(fractionB);\n pairType = pointA.isAlmostEqualMetric(pointB) ?\n CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\n } else {\n fractionB = 0.0;\n fractionA = rayA.pointToFraction(rayB.origin);\n pointA = rayA.fractionToPoint(fractionA);\n pointB = rayB.fractionToPoint(fractionB);\n pairType = pointA.isAlmostEqualMetric(pointB) ?\n CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\n }\n const pair = CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\n pair.approachType = pairType;\n return pair;\n }\n /**\n * Return a ray with `ray.origin` interpolated between `pt1` and `pt2` at the given `fraction`\n * and `ray.direction` set to the vector from `pt1` to `pt2` multiplied by the given `tangentScale`.\n * @param pt1 start point of the interpolation.\n * @param fraction fractional position between points.\n * @param pt2 end point of the interpolation.\n * @param tangentScale scale factor to apply to the startToEnd vector.\n * @param result optional receiver.\n */\n public static interpolatePointAndTangent(\n pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d,\n ): Ray3d {\n result = result ?? Ray3d.createZero();\n const dx = pt2.x - pt1.x;\n const dy = pt2.y - pt1.y;\n const dz = pt2.z - pt1.z;\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\n if (fraction <= 0.5)\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\n else {\n const t: number = fraction - 1.0;\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\n }\n return result;\n }\n}\n"]}
@@ -1,13 +1,10 @@
1
- /** @packageDocumentation
2
- * @module CartesianGeometry
3
- */
4
1
  import { AnyRegion } from "../curve/CurveTypes";
5
2
  import { Loop } from "../curve/Loop";
6
3
  import { IndexedReadWriteXYZCollection, IndexedXYZCollection } from "./IndexedXYZCollection";
7
4
  import { Point3d } from "./Point3dVector3d";
8
5
  import { Range3d } from "./Range";
9
6
  /**
10
- * A `SortablePolygon` carries a (single) loop with data useful for sorting for inner-outer structure.
7
+ * A `SortablePolygon` carries a (single) xy-loop with data useful for sorting for inner-outer structure.
11
8
  * @internal
12
9
  */
13
10
  export declare class SortablePolygon {
@@ -1 +1 @@
1
- {"version":3,"file":"SortablePolygon.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/SortablePolygon.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAsKlC;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAsB;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;gBACgB,IAAI,EAAE,6BAA6B,GAAG,IAAI,EAAE,KAAK,EAAE,OAAO;IAS7E;;;OAGG;WACW,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,IAAI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KAAK,EAAE,OAAO;IAS7E;;;OAGG;WACW,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,6BAA6B,GAAG,OAAO;IASjG;;;OAGG;WACW,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;IASrE;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAyBpC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAwBjC,OAAO,CAAC,MAAM,CAAC,eAAe;WAuChB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,SAAS;WAYpD,4BAA4B,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,6BAA6B,EAAE,EAAE;IAIhG,WAAW,IAAI,oBAAoB,GAAG,SAAS;IAG/C,QAAQ,IAAI,IAAI,GAAG,SAAS;IAG5B,kBAAkB,CAAC,UAAU,EAAE,MAAM;IAGrC,mBAAmB,IAAI,OAAO,GAAG,SAAS;CAGlD"}
@@ -2,6 +2,9 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module CartesianGeometry
7
+ */
5
8
  import { CurveChain } from "../curve/CurveCollection";
6
9
  import { CurvePrimitive } from "../curve/CurvePrimitive";
7
10
  import { LineString3d } from "../curve/LineString3d";
@@ -10,15 +13,39 @@ import { ParityRegion } from "../curve/ParityRegion";
10
13
  import { RegionOps } from "../curve/RegionOps";
11
14
  import { UnionRegion } from "../curve/UnionRegion";
12
15
  import { IndexedReadWriteXYZCollection } from "./IndexedXYZCollection";
16
+ import { Point3d } from "./Point3dVector3d";
13
17
  import { PolygonOps } from "./PolygonOps";
14
- /** abstract base class for area-related queries of a loop.
15
- * * subclasses have particular logic for `Loop` and polygon data.
18
+ import { Ray3d } from "./Ray3d";
19
+ /** Abstract base class for area-related queries of an xy-loop.
20
+ * * Subclasses have particular logic for `Loop` and polygon data.
16
21
  * @internal
17
22
  */
18
23
  class SimpleRegionCarrier {
24
+ /** Fractions for interior point search. */
25
+ searchFractions = [0.2349, 0.4142, 0.6587, 0.8193];
26
+ /**
27
+ * Given a region boundary tangent, construct a point interior to the region.
28
+ * @param ray point and tangent on an edge of the region (modified on return)
29
+ */
30
+ constructInteriorPoint(ray) {
31
+ ray.direction.z = 0.0;
32
+ if (!ray.direction.normalizeInPlace())
33
+ return undefined; // loop has zero length edge, or a vertical (gap) edge
34
+ ray.direction.rotate90CCWXY(ray.direction);
35
+ if (this.signedArea < 0.0)
36
+ ray.direction.scaleInPlace(-1.0); // aim toward the region interior
37
+ const refDistance = Math.sqrt(Math.abs(this.signedArea));
38
+ const candidatePoint = Point3d.create();
39
+ for (let fraction = 1.0e-5; fraction < 3; fraction *= 5.0) {
40
+ ray.fractionToPoint(fraction * refDistance, candidatePoint);
41
+ if (1 === this.classifyPointXY(candidatePoint))
42
+ return candidatePoint;
43
+ }
44
+ return undefined;
45
+ }
19
46
  }
20
47
  /**
21
- * Implement `LoopCarrier` queries with the area as a polygon carried in an `IndexedReadWriteXYZCollection`
48
+ * Implement `SimpleRegionCarrier` queries with the area as a polygon carried in an `IndexedReadWriteXYZCollection`.
22
49
  */
23
50
  class PolygonCarrier extends SimpleRegionCarrier {
24
51
  data;
@@ -37,14 +64,14 @@ class PolygonCarrier extends SimpleRegionCarrier {
37
64
  classifyPointXY(xy) {
38
65
  return PolygonOps.classifyPointInPolygonXY(xy.x, xy.y, this.data);
39
66
  }
40
- /** Return some point "inside"
41
- * NEEDS WORK: this returns a point ON --
42
- */
67
+ /** Return some point "inside". */
43
68
  getAnyInteriorPoint() {
44
69
  for (let childIndex = 0; childIndex < this.data.length; childIndex++) {
45
- const q = this.constructInteriorPointNearEdge(childIndex, 0.2349);
46
- if (q !== undefined)
47
- return q;
70
+ for (const fraction of this.searchFractions) {
71
+ const q = this.constructInteriorPointNearEdge(childIndex, fraction);
72
+ if (q !== undefined)
73
+ return q;
74
+ }
48
75
  }
49
76
  return undefined;
50
77
  }
@@ -60,27 +87,14 @@ class PolygonCarrier extends SimpleRegionCarrier {
60
87
  }
61
88
  constructInteriorPointNearEdge(edgeIndex, fractionAlong) {
62
89
  if (edgeIndex + 1 < this.data.length) {
63
- const point0 = this.data.getPoint3dAtUncheckedPointIndex(edgeIndex);
64
- const point1 = this.data.getPoint3dAtUncheckedPointIndex(edgeIndex + 1);
65
- const vector = point0.vectorTo(point1);
66
- const point = point0.interpolate(fractionAlong, point1);
67
- vector.rotate90CCWXY(vector);
68
- if (vector.normalizeInPlace()) {
69
- if (this._signedArea < 0)
70
- vector.scaleInPlace(-1.0);
71
- const refDistance = Math.sqrt(Math.abs(this._signedArea));
72
- for (let fraction = 1.0e-5; fraction < 3; fraction *= 5.0) {
73
- const candidatePoint = point.plusScaled(vector, fraction * refDistance);
74
- if (1 === this.classifyPointXY(candidatePoint))
75
- return candidatePoint;
76
- }
77
- }
90
+ const ray = Ray3d.createCapture(this.data.interpolateIndexIndex(edgeIndex, fractionAlong, edgeIndex + 1), this.data.vectorIndexIndex(edgeIndex, edgeIndex + 1));
91
+ return this.constructInteriorPoint(ray);
78
92
  }
79
93
  return undefined;
80
94
  }
81
95
  }
82
96
  /**
83
- * Implement `LoopCarrier` queries with the area as a strongly typed `Loop`
97
+ * Implement `SimpleRegionCarrier` queries with the area as a strongly typed `Loop`.
84
98
  */
85
99
  class LoopCarrier extends SimpleRegionCarrier {
86
100
  data;
@@ -102,28 +116,19 @@ class LoopCarrier extends SimpleRegionCarrier {
102
116
  }
103
117
  constructInteriorPointNearChild(childIndex, fractionAlong) {
104
118
  if (childIndex < this.data.children.length) {
105
- const primitive = this.data.children[childIndex];
106
- const ray = primitive.fractionToPointAndUnitTangent(fractionAlong);
107
- ray.direction.rotate90CCWXY(ray.direction);
108
- if (this._signedArea < 0.0)
109
- ray.direction.scaleInPlace(-1.0);
110
- const refDistance = Math.sqrt(Math.abs(this._signedArea));
111
- for (let fraction = 1.0e-5; fraction < 3; fraction *= 5.0) {
112
- const candidatePoint = ray.fractionToPoint(fraction * refDistance);
113
- if (1 === this.classifyPointXY(candidatePoint))
114
- return candidatePoint;
115
- }
119
+ const ray = this.data.children[childIndex].fractionToPointAndDerivative(fractionAlong);
120
+ return this.constructInteriorPoint(ray);
116
121
  }
117
122
  return undefined;
118
123
  }
119
- /** Return some point "inside"
120
- * NEEDS WORK: this returns a point ON --
121
- */
124
+ /** Return some point "inside". */
122
125
  getAnyInteriorPoint() {
123
126
  for (let childIndex = 0; childIndex < this.data.children.length; childIndex++) {
124
- const q = this.constructInteriorPointNearChild(childIndex, 0.2349);
125
- if (q !== undefined)
126
- return q;
127
+ for (const fraction of this.searchFractions) {
128
+ const q = this.constructInteriorPointNearChild(childIndex, fraction);
129
+ if (q !== undefined)
130
+ return q;
131
+ }
127
132
  }
128
133
  return undefined;
129
134
  }
@@ -151,7 +156,7 @@ class LoopCarrier extends SimpleRegionCarrier {
151
156
  }
152
157
  }
153
158
  /**
154
- * A `SortablePolygon` carries a (single) loop with data useful for sorting for inner-outer structure.
159
+ * A `SortablePolygon` carries a (single) xy-loop with data useful for sorting for inner-outer structure.
155
160
  * @internal
156
161
  */
157
162
  export class SortablePolygon {