@itwin/core-geometry 4.2.0-dev.9 → 4.3.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (478) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Geometry.d.ts +4 -4
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +2 -2
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts +4 -3
  7. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  8. package/lib/cjs/clipping/AlternatingConvexClipTree.js +1 -1
  9. package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
  10. package/lib/cjs/clipping/BooleanClipNode.d.ts +4 -3
  11. package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
  12. package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
  13. package/lib/cjs/clipping/ClipPlane.d.ts +2 -1
  14. package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
  15. package/lib/cjs/clipping/ClipPlane.js.map +1 -1
  16. package/lib/cjs/clipping/ClipUtils.d.ts +17 -11
  17. package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
  18. package/lib/cjs/clipping/ClipUtils.js +14 -8
  19. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  20. package/lib/cjs/clipping/ClipVector.d.ts +6 -5
  21. package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
  22. package/lib/cjs/clipping/ClipVector.js +1 -1
  23. package/lib/cjs/clipping/ClipVector.js.map +1 -1
  24. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +3 -2
  25. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  26. package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
  27. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  28. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  29. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  30. package/lib/cjs/core-geometry.d.ts +1 -3
  31. package/lib/cjs/core-geometry.d.ts.map +1 -1
  32. package/lib/cjs/core-geometry.js +1 -3
  33. package/lib/cjs/core-geometry.js.map +1 -1
  34. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  35. package/lib/cjs/curve/Arc3d.js +4 -4
  36. package/lib/cjs/curve/Arc3d.js.map +1 -1
  37. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  38. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  39. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +171 -152
  40. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  41. package/lib/cjs/curve/CurveCollection.d.ts +19 -19
  42. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  43. package/lib/cjs/curve/CurveCollection.js +20 -22
  44. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  45. package/lib/cjs/curve/CurveCurve.d.ts +47 -30
  46. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  47. package/lib/cjs/curve/CurveCurve.js +81 -46
  48. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  49. package/lib/cjs/curve/CurveFactory.d.ts +1 -1
  50. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  51. package/lib/cjs/curve/CurveLocationDetail.d.ts +17 -5
  52. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  53. package/lib/cjs/curve/CurveLocationDetail.js +14 -2
  54. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  55. package/lib/cjs/curve/CurveOps.d.ts +1 -1
  56. package/lib/cjs/curve/CurveOps.js.map +1 -1
  57. package/lib/cjs/curve/CurvePrimitive.d.ts +1 -2
  58. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  59. package/lib/cjs/curve/CurvePrimitive.js +2 -2
  60. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  61. package/lib/cjs/curve/CurveProcessor.d.ts +1 -1
  62. package/lib/cjs/curve/CurveProcessor.js.map +1 -1
  63. package/lib/cjs/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  64. package/lib/cjs/curve/CurveTypes.d.ts.map +1 -0
  65. package/lib/cjs/curve/{CurveChain.js → CurveTypes.js} +1 -1
  66. package/lib/cjs/curve/CurveTypes.js.map +1 -0
  67. package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts +1 -1
  68. package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
  69. package/lib/cjs/curve/ParityRegion.d.ts +3 -3
  70. package/lib/cjs/curve/ParityRegion.d.ts.map +1 -1
  71. package/lib/cjs/curve/ParityRegion.js +2 -2
  72. package/lib/cjs/curve/ParityRegion.js.map +1 -1
  73. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  74. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  75. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +2 -2
  76. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  77. package/lib/cjs/curve/Query/CurveSplitContext.d.ts +1 -1
  78. package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
  79. package/lib/cjs/curve/Query/CylindricalRange.d.ts +1 -1
  80. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  81. package/lib/cjs/curve/Query/InOutTests.d.ts +1 -1
  82. package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
  83. package/lib/cjs/curve/Query/StrokeCountChain.d.ts +1 -1
  84. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  85. package/lib/cjs/curve/RegionOps.d.ts +54 -5
  86. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  87. package/lib/cjs/curve/RegionOps.js +154 -3
  88. package/lib/cjs/curve/RegionOps.js.map +1 -1
  89. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  90. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  91. package/lib/cjs/curve/StrokeOptions.d.ts +20 -11
  92. package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
  93. package/lib/cjs/curve/StrokeOptions.js +22 -11
  94. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  95. package/lib/cjs/curve/UnionRegion.d.ts +3 -3
  96. package/lib/cjs/curve/UnionRegion.d.ts.map +1 -1
  97. package/lib/cjs/curve/UnionRegion.js +2 -2
  98. package/lib/cjs/curve/UnionRegion.js.map +1 -1
  99. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  100. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  101. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  102. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  103. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  104. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  105. package/lib/cjs/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  106. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  107. package/lib/{esm/curve → cjs/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  108. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  109. package/lib/cjs/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +104 -115
  110. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  111. package/lib/cjs/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  112. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  113. package/lib/cjs/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  114. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  115. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  116. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  117. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  118. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  119. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  120. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  121. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +1 -0
  122. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  123. package/lib/cjs/geometry3d/BarycentricTriangle.js +1 -0
  124. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  125. package/lib/cjs/geometry3d/FrameBuilder.d.ts +28 -11
  126. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  127. package/lib/cjs/geometry3d/FrameBuilder.js +57 -45
  128. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  129. package/lib/cjs/geometry3d/GeometryHandler.d.ts +15 -26
  130. package/lib/cjs/geometry3d/GeometryHandler.d.ts.map +1 -1
  131. package/lib/cjs/geometry3d/GeometryHandler.js +23 -32
  132. package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
  133. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +0 -8
  134. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  135. package/lib/cjs/geometry3d/GrowableXYZArray.js +0 -16
  136. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  137. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +4 -4
  138. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  139. package/lib/cjs/geometry3d/IndexedXYZCollection.js +12 -0
  140. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  141. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  142. package/lib/cjs/geometry3d/Matrix3d.js +3 -6
  143. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  144. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  145. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  146. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -2
  147. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  148. package/lib/cjs/geometry3d/Point3dVector3d.js +0 -1
  149. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  150. package/lib/cjs/geometry3d/PolygonOps.d.ts +2 -2
  151. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  152. package/lib/cjs/geometry3d/PolygonOps.js +2 -3
  153. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  154. package/lib/cjs/geometry3d/Range.d.ts +1 -1
  155. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  156. package/lib/cjs/geometry3d/Range.js +1 -1
  157. package/lib/cjs/geometry3d/Range.js.map +1 -1
  158. package/lib/cjs/geometry3d/Ray3d.d.ts +3 -1
  159. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  160. package/lib/cjs/geometry3d/Ray3d.js +4 -3
  161. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  162. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts +2 -1
  163. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  164. package/lib/cjs/geometry3d/ReusableObjectCache.js +1 -1
  165. package/lib/cjs/geometry3d/ReusableObjectCache.js.map +1 -1
  166. package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -1
  167. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  168. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  169. package/lib/cjs/geometry3d/Transform.js +4 -6
  170. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  171. package/lib/cjs/geometry3d/YawPitchRollAngles.js +1 -1
  172. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  173. package/lib/cjs/geometry4d/Map4d.d.ts +14 -8
  174. package/lib/cjs/geometry4d/Map4d.d.ts.map +1 -1
  175. package/lib/cjs/geometry4d/Map4d.js +38 -16
  176. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  177. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  178. package/lib/cjs/geometry4d/Matrix4d.js +4 -2
  179. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  180. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  181. package/lib/cjs/numerics/Polynomials.d.ts +2 -2
  182. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  183. package/lib/cjs/numerics/Polynomials.js +2 -2
  184. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  185. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +18 -6
  186. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  187. package/lib/cjs/polyface/PolyfaceBuilder.js +55 -25
  188. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  189. package/lib/cjs/polyface/PolyfaceClip.d.ts +16 -7
  190. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  191. package/lib/cjs/polyface/PolyfaceClip.js +38 -7
  192. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  193. package/lib/cjs/polyface/PolyfaceData.d.ts +5 -39
  194. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  195. package/lib/cjs/polyface/PolyfaceData.js +7 -41
  196. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  197. package/lib/cjs/polyface/PolyfaceQuery.d.ts +10 -8
  198. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  199. package/lib/cjs/polyface/PolyfaceQuery.js +64 -18
  200. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  201. package/lib/cjs/serialization/GeometrySamples.d.ts +6 -0
  202. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  203. package/lib/cjs/serialization/GeometrySamples.js +68 -2
  204. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  205. package/lib/cjs/solid/LinearSweep.d.ts +1 -1
  206. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  207. package/lib/cjs/solid/RotationalSweep.d.ts +1 -1
  208. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  209. package/lib/cjs/solid/RuledSweep.d.ts +1 -1
  210. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  211. package/lib/cjs/solid/SweepContour.d.ts +35 -26
  212. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  213. package/lib/cjs/solid/SweepContour.js +84 -100
  214. package/lib/cjs/solid/SweepContour.js.map +1 -1
  215. package/lib/cjs/topology/Graph.d.ts +29 -11
  216. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  217. package/lib/cjs/topology/Graph.js +45 -26
  218. package/lib/cjs/topology/Graph.js.map +1 -1
  219. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts +2 -2
  220. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  221. package/lib/cjs/topology/HalfEdgeMarkSet.js +4 -4
  222. package/lib/cjs/topology/HalfEdgeMarkSet.js.map +1 -1
  223. package/lib/cjs/topology/Merging.d.ts +3 -0
  224. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  225. package/lib/cjs/topology/Merging.js +19 -5
  226. package/lib/cjs/topology/Merging.js.map +1 -1
  227. package/lib/cjs/topology/Triangulation.d.ts +15 -7
  228. package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
  229. package/lib/cjs/topology/Triangulation.js +89 -47
  230. package/lib/cjs/topology/Triangulation.js.map +1 -1
  231. package/lib/esm/Geometry.d.ts +4 -4
  232. package/lib/esm/Geometry.d.ts.map +1 -1
  233. package/lib/esm/Geometry.js +2 -2
  234. package/lib/esm/Geometry.js.map +1 -1
  235. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts +4 -3
  236. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  237. package/lib/esm/clipping/AlternatingConvexClipTree.js +1 -1
  238. package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
  239. package/lib/esm/clipping/BooleanClipNode.d.ts +4 -3
  240. package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
  241. package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
  242. package/lib/esm/clipping/ClipPlane.d.ts +2 -1
  243. package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
  244. package/lib/esm/clipping/ClipPlane.js.map +1 -1
  245. package/lib/esm/clipping/ClipUtils.d.ts +17 -11
  246. package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
  247. package/lib/esm/clipping/ClipUtils.js +14 -8
  248. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  249. package/lib/esm/clipping/ClipVector.d.ts +6 -5
  250. package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
  251. package/lib/esm/clipping/ClipVector.js +1 -1
  252. package/lib/esm/clipping/ClipVector.js.map +1 -1
  253. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +3 -2
  254. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  255. package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
  256. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  257. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  258. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  259. package/lib/esm/core-geometry.d.ts +1 -3
  260. package/lib/esm/core-geometry.d.ts.map +1 -1
  261. package/lib/esm/core-geometry.js +1 -3
  262. package/lib/esm/core-geometry.js.map +1 -1
  263. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  264. package/lib/esm/curve/Arc3d.js +4 -4
  265. package/lib/esm/curve/Arc3d.js.map +1 -1
  266. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  267. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  268. package/lib/esm/curve/CurveChainWithDistanceIndex.js +171 -152
  269. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  270. package/lib/esm/curve/CurveCollection.d.ts +19 -19
  271. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  272. package/lib/esm/curve/CurveCollection.js +19 -20
  273. package/lib/esm/curve/CurveCollection.js.map +1 -1
  274. package/lib/esm/curve/CurveCurve.d.ts +47 -30
  275. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  276. package/lib/esm/curve/CurveCurve.js +81 -46
  277. package/lib/esm/curve/CurveCurve.js.map +1 -1
  278. package/lib/esm/curve/CurveFactory.d.ts +1 -1
  279. package/lib/esm/curve/CurveFactory.js.map +1 -1
  280. package/lib/esm/curve/CurveLocationDetail.d.ts +17 -5
  281. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  282. package/lib/esm/curve/CurveLocationDetail.js +12 -1
  283. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  284. package/lib/esm/curve/CurveOps.d.ts +1 -1
  285. package/lib/esm/curve/CurveOps.js.map +1 -1
  286. package/lib/esm/curve/CurvePrimitive.d.ts +1 -2
  287. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  288. package/lib/esm/curve/CurvePrimitive.js +2 -2
  289. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  290. package/lib/esm/curve/CurveProcessor.d.ts +1 -1
  291. package/lib/esm/curve/CurveProcessor.js.map +1 -1
  292. package/lib/esm/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  293. package/lib/esm/curve/CurveTypes.d.ts.map +1 -0
  294. package/lib/esm/curve/{CurveChain.js → CurveTypes.js} +1 -1
  295. package/lib/esm/curve/CurveTypes.js.map +1 -0
  296. package/lib/esm/curve/CurveWireMomentsXYZ.d.ts +1 -1
  297. package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
  298. package/lib/esm/curve/ParityRegion.d.ts +3 -3
  299. package/lib/esm/curve/ParityRegion.d.ts.map +1 -1
  300. package/lib/esm/curve/ParityRegion.js +2 -2
  301. package/lib/esm/curve/ParityRegion.js.map +1 -1
  302. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  303. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  304. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +1 -1
  305. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  306. package/lib/esm/curve/Query/CurveSplitContext.d.ts +1 -1
  307. package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
  308. package/lib/esm/curve/Query/CylindricalRange.d.ts +1 -1
  309. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  310. package/lib/esm/curve/Query/InOutTests.d.ts +1 -1
  311. package/lib/esm/curve/Query/InOutTests.js.map +1 -1
  312. package/lib/esm/curve/Query/StrokeCountChain.d.ts +1 -1
  313. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  314. package/lib/esm/curve/RegionOps.d.ts +54 -5
  315. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  316. package/lib/esm/curve/RegionOps.js +153 -3
  317. package/lib/esm/curve/RegionOps.js.map +1 -1
  318. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  319. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  320. package/lib/esm/curve/StrokeOptions.d.ts +20 -11
  321. package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
  322. package/lib/esm/curve/StrokeOptions.js +22 -11
  323. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  324. package/lib/esm/curve/UnionRegion.d.ts +3 -3
  325. package/lib/esm/curve/UnionRegion.d.ts.map +1 -1
  326. package/lib/esm/curve/UnionRegion.js +2 -2
  327. package/lib/esm/curve/UnionRegion.js.map +1 -1
  328. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  329. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  330. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  331. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  332. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  333. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  334. package/lib/esm/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  335. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  336. package/lib/{cjs/curve → esm/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  337. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  338. package/lib/esm/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +103 -113
  339. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  340. package/lib/esm/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  341. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  342. package/lib/esm/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  343. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  344. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  345. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  346. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  347. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  348. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  349. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  350. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +1 -0
  351. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  352. package/lib/esm/geometry3d/BarycentricTriangle.js +1 -0
  353. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  354. package/lib/esm/geometry3d/FrameBuilder.d.ts +28 -11
  355. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  356. package/lib/esm/geometry3d/FrameBuilder.js +57 -45
  357. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  358. package/lib/esm/geometry3d/GeometryHandler.d.ts +15 -26
  359. package/lib/esm/geometry3d/GeometryHandler.d.ts.map +1 -1
  360. package/lib/esm/geometry3d/GeometryHandler.js +23 -32
  361. package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
  362. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +0 -8
  363. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  364. package/lib/esm/geometry3d/GrowableXYZArray.js +0 -16
  365. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  366. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +4 -4
  367. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  368. package/lib/esm/geometry3d/IndexedXYZCollection.js +12 -0
  369. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  370. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  371. package/lib/esm/geometry3d/Matrix3d.js +3 -6
  372. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  373. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  374. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  375. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -2
  376. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  377. package/lib/esm/geometry3d/Point3dVector3d.js +0 -1
  378. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  379. package/lib/esm/geometry3d/PolygonOps.d.ts +2 -2
  380. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  381. package/lib/esm/geometry3d/PolygonOps.js +2 -3
  382. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  383. package/lib/esm/geometry3d/Range.d.ts +1 -1
  384. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  385. package/lib/esm/geometry3d/Range.js +1 -1
  386. package/lib/esm/geometry3d/Range.js.map +1 -1
  387. package/lib/esm/geometry3d/Ray3d.d.ts +3 -1
  388. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  389. package/lib/esm/geometry3d/Ray3d.js +4 -3
  390. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  391. package/lib/esm/geometry3d/ReusableObjectCache.d.ts +2 -1
  392. package/lib/esm/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  393. package/lib/esm/geometry3d/ReusableObjectCache.js +1 -1
  394. package/lib/esm/geometry3d/ReusableObjectCache.js.map +1 -1
  395. package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -1
  396. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  397. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  398. package/lib/esm/geometry3d/Transform.js +4 -6
  399. package/lib/esm/geometry3d/Transform.js.map +1 -1
  400. package/lib/esm/geometry3d/YawPitchRollAngles.js +1 -1
  401. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  402. package/lib/esm/geometry4d/Map4d.d.ts +14 -8
  403. package/lib/esm/geometry4d/Map4d.d.ts.map +1 -1
  404. package/lib/esm/geometry4d/Map4d.js +38 -16
  405. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  406. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  407. package/lib/esm/geometry4d/Matrix4d.js +4 -2
  408. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  409. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  410. package/lib/esm/numerics/Polynomials.d.ts +2 -2
  411. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  412. package/lib/esm/numerics/Polynomials.js +2 -2
  413. package/lib/esm/numerics/Polynomials.js.map +1 -1
  414. package/lib/esm/polyface/PolyfaceBuilder.d.ts +18 -6
  415. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  416. package/lib/esm/polyface/PolyfaceBuilder.js +55 -25
  417. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  418. package/lib/esm/polyface/PolyfaceClip.d.ts +16 -7
  419. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  420. package/lib/esm/polyface/PolyfaceClip.js +38 -7
  421. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  422. package/lib/esm/polyface/PolyfaceData.d.ts +5 -39
  423. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  424. package/lib/esm/polyface/PolyfaceData.js +7 -41
  425. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  426. package/lib/esm/polyface/PolyfaceQuery.d.ts +10 -8
  427. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  428. package/lib/esm/polyface/PolyfaceQuery.js +64 -18
  429. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  430. package/lib/esm/serialization/GeometrySamples.d.ts +6 -0
  431. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  432. package/lib/esm/serialization/GeometrySamples.js +68 -2
  433. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  434. package/lib/esm/solid/LinearSweep.d.ts +1 -1
  435. package/lib/esm/solid/LinearSweep.js.map +1 -1
  436. package/lib/esm/solid/RotationalSweep.d.ts +1 -1
  437. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  438. package/lib/esm/solid/RuledSweep.d.ts +1 -1
  439. package/lib/esm/solid/RuledSweep.js.map +1 -1
  440. package/lib/esm/solid/SweepContour.d.ts +35 -26
  441. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  442. package/lib/esm/solid/SweepContour.js +84 -100
  443. package/lib/esm/solid/SweepContour.js.map +1 -1
  444. package/lib/esm/topology/Graph.d.ts +29 -11
  445. package/lib/esm/topology/Graph.d.ts.map +1 -1
  446. package/lib/esm/topology/Graph.js +45 -26
  447. package/lib/esm/topology/Graph.js.map +1 -1
  448. package/lib/esm/topology/HalfEdgeMarkSet.d.ts +2 -2
  449. package/lib/esm/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  450. package/lib/esm/topology/HalfEdgeMarkSet.js +2 -2
  451. package/lib/esm/topology/HalfEdgeMarkSet.js.map +1 -1
  452. package/lib/esm/topology/Merging.d.ts +3 -0
  453. package/lib/esm/topology/Merging.d.ts.map +1 -1
  454. package/lib/esm/topology/Merging.js +19 -5
  455. package/lib/esm/topology/Merging.js.map +1 -1
  456. package/lib/esm/topology/Triangulation.d.ts +15 -7
  457. package/lib/esm/topology/Triangulation.d.ts.map +1 -1
  458. package/lib/esm/topology/Triangulation.js +89 -47
  459. package/lib/esm/topology/Triangulation.js.map +1 -1
  460. package/package.json +4 -4
  461. package/lib/cjs/curve/CurveChain.d.ts.map +0 -1
  462. package/lib/cjs/curve/CurveChain.js.map +0 -1
  463. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  464. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  465. package/lib/cjs/curve/CurveCurveCloseApproachXY.js.map +0 -1
  466. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  467. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +0 -1
  468. package/lib/cjs/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  469. package/lib/cjs/curve/CurveCurveIntersectXYZ.js.map +0 -1
  470. package/lib/esm/curve/CurveChain.d.ts.map +0 -1
  471. package/lib/esm/curve/CurveChain.js.map +0 -1
  472. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  473. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  474. package/lib/esm/curve/CurveCurveCloseApproachXY.js.map +0 -1
  475. package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  476. package/lib/esm/curve/CurveCurveIntersectXY.js.map +0 -1
  477. package/lib/esm/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  478. package/lib/esm/curve/CurveCurveIntersectXYZ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"BarycentricTriangle.js","sourceRoot":"","sources":["../../../src/geometry3d/BarycentricTriangle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAE7C,0CAAwD;AACxD,yCAAsC;AACtC,uDAAsD;AACtD,mCAAgC;AAGhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,sBAAsB;IAiBjC;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IACD,4DAA4D;IACrD,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC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,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,mBAAQ,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;IACD,4DAA4D;IACrD,aAAa,CAAC,KAA0B,EAAE,GAAY;QAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eACpD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eAClD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF;AA/hBD,kDA+hBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\n\r\nimport { Geometry, PolygonLocation } from \"../Geometry\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n/**\r\n * Carries data about a location in the plane of a triangle.\r\n * * Each instance carries both world and barycentric coordinates for the point, and provides query\r\n * services on the latter.\r\n * * No tolerance is used when querying barycentric coordinates (e.g., `isInsideOrOn`, `classify`). Use\r\n * [[BarycentricTriangle.snapLocationToEdge]] to adjust the barycentric coordinates to a triangle edge\r\n * if they lie within a distance or parametric tolerance.\r\n *\r\n * Properties of the barycentric coordinates `(b0, b1, b2)` of a point `p` in the plane of a triangle\r\n * `T` with vertices `v0, v1, v2`:\r\n * * `1 = b0 + b1 + b2`\r\n * * `p = b0 * v0 + b1 * v1 + b2 * v2`\r\n * * If T is spanned by the vectors `U = v1 - v0` and `V = v2 - v0`, then the vector `P = p - v0` can\r\n * be written `P = b1 * U + b2 * V`.\r\n * * The coordinates are all nonnegative if and only if `p` is inside or on `T`.\r\n * * Exactly one coordinate is zero if and only if `p` lies on an (infinitely extended) edge of `T`.\r\n * * Exactly two coordinates are zero if and only if `p` coincides with a vertex of `T`.\r\n * * Note that if `p` can be written as a linear combination of the vertices of `T` using scales that do\r\n * NOT sum to 1, then `p` is not coplanar with `T`\r\n * @public\r\n */\r\nexport class TriangleLocationDetail {\r\n /** The Cartesian coordinates of the point p. */\r\n public world: Point3d;\r\n /** The barycentric coordinates of p with respect to the triangle. Assumed to sum to one. */\r\n public local: Point3d;\r\n /** Application-specific number */\r\n public a: number;\r\n /** Index of the triangle vertex at the start of the closest edge to p. */\r\n public closestEdgeIndex: number;\r\n /**\r\n * The parameter f along the closest edge to p of its projection q.\r\n * * We have q = v_i + f * (v_j - v_i) where i = closestEdgeIndex and j = (i + 1) % 3 are the indices\r\n * of the start vertex v_i and end vertex v_j of the closest edge to p.\r\n * * Note that 0 <= f <= 1.\r\n */\r\n public closestEdgeParam: number;\r\n\r\n private constructor() {\r\n this.world = new Point3d();\r\n this.local = new Point3d();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /** Invalidate this detail (set all attributes to zero) . */\r\n public invalidate() {\r\n this.world.setZero();\r\n this.local.setZero();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /**\r\n * Create an invalid detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(result?: TriangleLocationDetail): TriangleLocationDetail {\r\n if (undefined === result)\r\n result = new TriangleLocationDetail();\r\n else\r\n result.invalidate();\r\n return result;\r\n }\r\n /**\r\n * Set the instance contents from the `other` detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: TriangleLocationDetail) {\r\n this.world.setFrom(other.world);\r\n this.local.setFrom(other.local);\r\n this.a = other.a;\r\n this.closestEdgeIndex = other.closestEdgeIndex;\r\n this.closestEdgeParam = other.closestEdgeParam;\r\n }\r\n /** Whether this detail is invalid. */\r\n public get isValid(): boolean {\r\n return !this.local.isZero;\r\n }\r\n /**\r\n * Queries the barycentric coordinates to determine whether this instance specifies a location inside or\r\n * on the triangle.\r\n * @see classify\r\n */\r\n public get isInsideOrOn(): boolean {\r\n return this.isValid && this.local.x >= 0.0 && this.local.y >= 0.0 && this.local.z >= 0.0;\r\n }\r\n /**\r\n * Queries this detail to classify the location of this instance with respect to the triangle.\r\n * @returns location code\r\n * @see isInsideOrOn\r\n */\r\n public get classify(): PolygonLocation {\r\n if (!this.isValid)\r\n return PolygonLocation.Unknown;\r\n if (this.isInsideOrOn) {\r\n let numZero = 0;\r\n if (Math.abs(this.local.x) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.y) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.z) === 0.0)\r\n ++numZero;\r\n if (2 === numZero)\r\n return PolygonLocation.OnPolygonVertex;\r\n if (1 === numZero)\r\n return PolygonLocation.OnPolygonEdgeInterior;\r\n return PolygonLocation.InsidePolygonProjectsToEdgeInterior;\r\n }\r\n return (this.closestEdgeParam === 0.0) ?\r\n PolygonLocation.OutsidePolygonProjectsToVertex :\r\n PolygonLocation.OutsidePolygonProjectsToEdgeInterior;\r\n }\r\n}\r\n\r\n/**\r\n * 3 points defining a triangle to be evaluated with barycentric coordinates.\r\n * @public\r\n */\r\nexport class BarycentricTriangle {\r\n /** Array of 3 point coordinates for the triangle. */\r\n public points: Point3d[];\r\n /** Edge length squared cache, indexed by opposite vertex index */\r\n protected edgeLength2: number[];\r\n // private attributes\r\n private static _workPoint?: Point3d;\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workRay?: Ray3d;\r\n private static _workMatrix?: Matrix3d;\r\n /**\r\n * Constructor.\r\n * * Point references are CAPTURED\r\n */\r\n protected constructor(point0: Point3d, point1: Point3d, point2: Point3d) {\r\n this.points = [];\r\n this.points.push(point0);\r\n this.points.push(point1);\r\n this.points.push(point2);\r\n this.edgeLength2 = [];\r\n this.edgeLength2.push(point1.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point1));\r\n }\r\n /**\r\n * Copy contents of (not pointers to) the given points. A vertex is zeroed if its corresponding input point\r\n * is undefined.\r\n */\r\n public set(point0: Point3d | undefined, point1: Point3d | undefined, point2: Point3d | undefined) {\r\n this.points[0].setFromPoint3d(point0);\r\n this.points[1].setFromPoint3d(point1);\r\n this.points[2].setFromPoint3d(point2);\r\n this.edgeLength2[0] = this.points[1].distanceSquared(this.points[2]);\r\n this.edgeLength2[1] = this.points[0].distanceSquared(this.points[2]);\r\n this.edgeLength2[2] = this.points[0].distanceSquared(this.points[1]);\r\n }\r\n /** Copy all values from `other` */\r\n public setFrom(other: BarycentricTriangle) {\r\n for (let i = 0; i < 3; ++i) {\r\n this.points[i].setFromPoint3d(other.points[i]);\r\n this.edgeLength2[i] = other.edgeLength2[i];\r\n }\r\n }\r\n /**\r\n * Create a `BarycentricTriangle` with coordinates given by enumerated x,y,z of the 3 points.\r\n * @param result optional pre-allocated triangle.\r\n */\r\n public static createXYZXYZXYZ(\r\n x0: number, y0: number, z0: number,\r\n x1: number, y1: number, z1: number,\r\n x2: number, y2: number, z2: number,\r\n result?: BarycentricTriangle,\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(Point3d.create(x0, y0, z0), Point3d.create(x1, y1, z1), Point3d.create(x2, y2, z2));\r\n result.points[0].set(x0, y0, z0);\r\n result.points[1].set(x1, y1, z1);\r\n result.points[2].set(x2, y2, z2);\r\n return result;\r\n }\r\n /** Create a triangle with coordinates cloned from given points. */\r\n public static create(\r\n point0: Point3d, point1: Point3d, point2: Point3d, result?: BarycentricTriangle,\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(point0.clone(), point1.clone(), point2.clone());\r\n result.set(point0, point1, point2);\r\n return result;\r\n }\r\n /** Return a new `BarycentricTriangle` with the same coordinates. */\r\n public clone(result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(this.points[0], this.points[1], this.points[2], result);\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(\r\n transform.multiplyPoint3d(this.points[0], result?.points[0]),\r\n transform.multiplyPoint3d(this.points[1], result?.points[1]),\r\n transform.multiplyPoint3d(this.points[2], result?.points[2]),\r\n result,\r\n );\r\n }\r\n /** Return the area of the triangle. */\r\n public get area(): number {\r\n // The magnitude of the cross product A × B is the area of the parallelogram spanned by A and B.\r\n return 0.5 * this.points[0].crossProductToPointsMagnitude(this.points[1], this.points[2]);\r\n }\r\n /**\r\n * Compute squared length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLengthSquared(oppositeVertexIndex: number): number {\r\n return this.edgeLength2[Geometry.cyclic3dAxis(oppositeVertexIndex)];\r\n }\r\n /**\r\n * Compute length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLength(oppositeVertexIndex: number): number {\r\n return Math.sqrt(this.edgeLengthSquared(oppositeVertexIndex));\r\n }\r\n /** Return area divided by sum of squared lengths. */\r\n public get aspectRatio(): number {\r\n return Geometry.safeDivideFraction(\r\n this.area, this.edgeLengthSquared(0) + this.edgeLengthSquared(1) + this.edgeLengthSquared(2), 0,\r\n );\r\n }\r\n /** Return the perimeter of the triangle. */\r\n public get perimeter(): number {\r\n return this.edgeLength(0) + this.edgeLength(1) + this.edgeLength(2);\r\n }\r\n /**\r\n * Return the unit normal of the triangle.\r\n * @param result optional pre-allocated vector to fill and return.\r\n * @returns unit normal, or undefined if cross product length is too small.\r\n */\r\n public normal(result?: Vector3d): Vector3d | undefined {\r\n const cross = this.points[0].crossProductToPoints(this.points[1], this.points[2], result);\r\n if (cross.tryNormalizeInPlace())\r\n return cross;\r\n return undefined;\r\n }\r\n /**\r\n * Sum the triangle points with given scales.\r\n * * If the scales sum to 1, they are barycentric coordinates, and hence the result point is in the plane of\r\n * the triangle. If all coordinates are non-negative then the result point is inside the triangle.\r\n * * If the scales do not sum to 1, the point is inside the triangle scaled (by the scale sum) from the origin.\r\n * @param b0 scale to apply to vertex 0\r\n * @param b1 scale to apply to vertex 1\r\n * @param b2 scale to apply to vertex 2\r\n * @param result optional pre-allocated point to fill and return\r\n * @return linear combination of the vertices of this triangle\r\n * @see [[pointToFraction]]\r\n */\r\n public fractionToPoint(b0: number, b1: number, b2: number, result?: Point3d): Point3d {\r\n // p = b0 * v0 + b1 * v1 + b2 * v2\r\n return Point3d.createAdd3Scaled(this.points[0], b0, this.points[1], b1, this.points[2], b2, result);\r\n }\r\n /**\r\n * Compute the projection of the given `point` onto the plane of this triangle.\r\n * @param point point p to project\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the projection point `P = d.world`:\r\n * * `d.isValid` returns true if and only if `this.normal()` is defined.\r\n * * `d.classify` can be used to determine where P lies with respect to the triangle.\r\n * * `d.a` is the signed projection distance: `P = p + a * this.normal()`.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BarycentricTriangle\r\n * @see [[fractionToPoint]]\r\n */\r\n public pointToFraction(point: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n const normal = BarycentricTriangle._workVector0 = this.normal(BarycentricTriangle._workVector0);\r\n if (undefined === normal)\r\n return TriangleLocationDetail.create(result);\r\n const ray = BarycentricTriangle._workRay = Ray3d.create(point, normal, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(ray, result); // intersectRay3d is free to use workVector0\r\n }\r\n /** Convert from opposite-vertex to start-vertex edge indexing. */\r\n public static edgeOppositeVertexIndexToStartVertexIndex(edgeIndex: number): number {\r\n return Geometry.cyclic3dAxis(edgeIndex + 1);\r\n }\r\n /** Convert from start-vertex to opposite-vertex edge indexing. */\r\n public static edgeStartVertexIndexToOppositeVertexIndex(startVertexIndex: number): number {\r\n return Geometry.cyclic3dAxis(startVertexIndex - 1);\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle but not on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is strictly inside the triangle.\r\n */\r\n public static isInsideTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 > 0 && b1 > 0 && b2 > 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle or on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is inside or on the triangle.\r\n */\r\n public static isInsideOrOnTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 >= 0 && b1 >= 0 && b2 >= 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside an edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i < 0 and b_j >= 0, and b_k >= 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondEdge(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives smaller regions)\r\n if (b0 < 0 && b1 >= 0 && b2 >= 0)\r\n return 0;\r\n if (b0 >= 0 && b1 < 0 && b2 >= 0)\r\n return 1;\r\n if (b0 >= 0 && b1 >= 0 && b2 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_j < 0 and b_k < 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondVertex(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives larger regions)\r\n if (b1 < 0 && b2 < 0)\r\n return 0;\r\n if (b0 < 0 && b2 < 0)\r\n return 1;\r\n if (b0 < 0 && b1 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_i = 1 and b_j = b_k = 0. Otherwise, returns -1.\r\n */\r\n private static isOnVertex(b0: number, b1: number, b2: number): number {\r\n if (b0 === 1 && b1 === 0 && b2 === 0)\r\n return 0;\r\n if (b0 === 0 && b1 === 1 && b2 === 0)\r\n return 1;\r\n if (b0 === 0 && b1 === 0 && b2 === 1)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a bounded edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i = 0, b_j > 0, and b_k > 0. Otherwise, returns -1.\r\n */\r\n private static isOnBoundedEdge(b0: number, b1: number, b2: number): number {\r\n if (b0 === 0 && b1 > 0 && b2 > 0)\r\n return 0;\r\n if (b0 > 0 && b1 === 0 && b2 > 0)\r\n return 1;\r\n if (b0 > 0 && b1 > 0 && b2 === 0)\r\n return 2;\r\n return -1;\r\n }\r\n /** @returns edge/vertex index (0,1,2) for which the function has a minimum value */\r\n private static indexOfMinimum(fn: (index: number) => number): number {\r\n let i = 0;\r\n let min = fn(0);\r\n const val = fn(1);\r\n if (min > val) {\r\n i = 1;\r\n min = val;\r\n }\r\n if (min > fn(2))\r\n i = 2;\r\n return i;\r\n }\r\n /**\r\n * Compute the squared distance between two points given by their barycentric coordinates.\r\n * * It is assumed that a0 + a1 + a2 = b0 + b1 + b2 = 1.\r\n */\r\n public distanceSquared(a0: number, a1: number, a2: number, b0: number, b1: number, b2: number): number {\r\n // The barycentric displacement vector distance formula\r\n // More details can be found at https://web.evanchen.cc/handouts/bary/bary-full.pdf\r\n return -this.edgeLengthSquared(0) * (b1 - a1) * (b2 - a2)\r\n - this.edgeLengthSquared(1) * (b2 - a2) * (b0 - a0)\r\n - this.edgeLengthSquared(2) * (b0 - a0) * (b1 - a1);\r\n }\r\n /** Return the index of the closest triangle vertex to the point given by its barycentric coordinates. */\r\n public closestVertexIndex(b0: number, b1: number, b2: number): number {\r\n return BarycentricTriangle.indexOfMinimum((i: number) => {\r\n const a = BarycentricTriangle._workPoint = Point3d.createZero(BarycentricTriangle._workPoint);\r\n a.setAt(i, 1.0); // \"a\" is (1,0,0) or (0,1,0) or (0,0,1) so \"a\" represents vertex i\r\n return this.distanceSquared(a.x, a.y, a.z, b0, b1, b2); // distance between the point and vertex i\r\n });\r\n }\r\n /** Compute dot product of the edge vectors based at the vertex with the given index. */\r\n public dotProductOfEdgeVectorsAtVertex(baseVertexIndex: number): number {\r\n const i = Geometry.cyclic3dAxis(baseVertexIndex);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n const k = Geometry.cyclic3dAxis(j + 1);\r\n return Geometry.dotProductXYZXYZ(\r\n this.points[j].x - this.points[i].x, this.points[j].y - this.points[i].y, this.points[j].z - this.points[i].z,\r\n this.points[k].x - this.points[i].x, this.points[k].y - this.points[i].y, this.points[k].z - this.points[i].z,\r\n );\r\n }\r\n /**\r\n * Compute the projection of barycentric point p onto the (unbounded) edge e_k(v_i,v_j) of the triangle T(v_i,v_j,v_k).\r\n * @param k vertex v_k is opposite the edge e_k\r\n * @param b barycentric coordinates of point to project\r\n * @returns parameter f along e_k, such that:\r\n * * the projection point is q = v_i + f * (v_j - v_i)\r\n * * the barycentric coords of the projection are q_ijk = (1 - f, f, 0)\r\n */\r\n private computeProjectionToEdge(k: number, b: number[]): number {\r\n /**\r\n * We know p = (b_i*v_i) + (b_j*v_j) + (b_k*v_k) and 1 = b_i + b_j + b_k.\r\n * Let U = v_j - v_i and V = v_k - v_i and P = p - v_i.\r\n * First we prove P = b_jU + b_kV.\r\n * P = (b_i * v_i) + (b_j * v_j) + (b_k * v_k) - v_i\r\n * = (b_i * v_i) + (b_j * (v_j-v_i)) + (b_j * v_i) + (b_k * (v_k-v_i)) + (b_k * v_i) - v_i\r\n * = (b_i * v_i) + (b_j * U) + (b_j * v_i) + (b_k * V) + (b_k * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + ((b_i + b_j + b_k) * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + v_i - v_i\r\n * = (b_j * U) + (b_k * V)\r\n * So we know p - v_i = b_jU + b_kV and q - v_i = fU\r\n * Therefore, 0 = (p - q).(v_j - v_i)\r\n * = ((p-v_i) - (q-v_i)).(v_j - v_i)\r\n * = (b_jU + b_kV - fU).U\r\n * = b_jU.U + b_kU.V - fU.U\r\n * Thus f = b_j + b_k(U.V/U.U)\r\n */\r\n k = Geometry.cyclic3dAxis(k);\r\n const i = Geometry.cyclic3dAxis(k + 1);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n return b[j] + b[k] * this.dotProductOfEdgeVectorsAtVertex(i) / this.edgeLengthSquared(k);\r\n }\r\n /**\r\n * Compute the projection of a barycentric point p to the triangle T(v_0,v_1,v_2).\r\n * @param b0 barycentric coordinate of p corresponding to v_0\r\n * @param b1 barycentric coordinate of p corresponding to v_1\r\n * @param b2 barycentric coordinate of p corresponding to v_2\r\n * @returns closest edge start vertex index i and projection parameter f such that the projection\r\n * q = v_i + f * (v_j - v_i).\r\n */\r\n public closestPoint(b0: number, b1: number, b2: number): { closestEdgeIndex: number, closestEdgeParam: number } {\r\n const b: number[] = [b0, b1, b2];\r\n let edgeIndex = -1; // opposite-vertex index\r\n let edgeParam = 0.0;\r\n if (BarycentricTriangle.isInsideTriangle(b0, b1, b2)) { // projects to any edge\r\n edgeIndex = BarycentricTriangle.indexOfMinimum((i: number) => {\r\n // We want smallest projection distance d_i of p to e_i.\r\n // Since b_i=d_i|e_i|/2A we can compare quantities b_i/|e_i|.\r\n return b[i] * b[i] / this.edgeLengthSquared(i); // avoid sqrt\r\n });\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondVertex(b0, b1, b2)) >= 0) { // projects to other edges, or any vertex\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(this.closestVertexIndex(b0, b1, b2));\r\n }\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondEdge(b0, b1, b2)) >= 0) { // projects to the edge or its vertices\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0) {\r\n edgeParam = 0.0; // start of this edge\r\n } else if (edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1); // end of this edge = start of next edge\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isOnBoundedEdge(b0, b1, b2)) >= 0) {\r\n edgeParam = 1 - b[BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex)];\r\n } else if ((edgeIndex = BarycentricTriangle.isOnVertex(b0, b1, b2)) >= 0) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(edgeIndex);\r\n }\r\n // invalid edgeIndex shouldn't happen, but propagate it anyway\r\n assert(edgeIndex === 0 || edgeIndex === 1 || edgeIndex === 2);\r\n return {\r\n closestEdgeIndex: (edgeIndex < 0) ? -1 : BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex),\r\n closestEdgeParam: edgeParam,\r\n };\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a ray) with the plane of this triangle.\r\n * @param ray infinite line to intersect, as a ray\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.a` is the intersection parameter along the ray.\r\n * * The line intersects the plane of the triangle if and only if `d.isValid` returns true.\r\n * * The ray intersects the plane of the triangle if and only if `d.isValid` returns true and `d.a` >= 0.\r\n * * The ray intersects the triangle if and only if `d.isValid` returns true, `d.a` >= 0, and `d.isInsideOrOn`\r\n * returns true.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/RayTriangleIntersection\r\n * @see [[pointToFraction]]\r\n */\r\n public intersectRay3d(ray: Ray3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n result = TriangleLocationDetail.create(result);\r\n /**\r\n * Let r0 = ray.origin and d = ray.direction. Write intersection point p two ways for unknown scalars s,b0,b1,b2:\r\n * r0 + s*d = p = b0*v0 + b1*v1 + b2*v2\r\n * Subtract v0 from both ends, let u=v1-v0, v=v2-v0, c=r0-v0, and enforce b0+b1+b2=1:\r\n * b1*u + b2*v - s*d = c\r\n * This is a linear system Mx = c where M has columns u,v,d and solution x=(b1,b2,-s).\r\n */\r\n const r0 = ray.origin;\r\n const d = ray.direction;\r\n const u = BarycentricTriangle._workVector0 = Vector3d.createStartEnd(\r\n this.points[0], this.points[1], BarycentricTriangle._workVector0,\r\n );\r\n const v = BarycentricTriangle._workVector1 = Vector3d.createStartEnd(\r\n this.points[0], this.points[2], BarycentricTriangle._workVector1,\r\n );\r\n const M = BarycentricTriangle._workMatrix = Matrix3d.createColumns(u, v, d, BarycentricTriangle._workMatrix);\r\n const c = Vector3d.createStartEnd(this.points[0], r0, BarycentricTriangle._workVector0); // reuse workVector0\r\n const solution = BarycentricTriangle._workVector1; // reuse workVector1\r\n if (undefined === M.multiplyInverse(c, solution))\r\n return result; // invalid\r\n result.a = -solution.z; // = -(-s) = s\r\n ray.fractionToPoint(result.a, result.world);\r\n result.local.set(1.0 - solution.x - solution.y, solution.x, solution.y); // = (1 - b1 - b2, b1, b2) = (b0 , b1, b2)\r\n const proj = this.closestPoint(result.local.x, result.local.y, result.local.z);\r\n result.closestEdgeIndex = proj.closestEdgeIndex;\r\n result.closestEdgeParam = proj.closestEdgeParam;\r\n return result;\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a line segment) with the plane of this triangle.\r\n * @param point0 start point of segment on line to intersect\r\n * @param point1 end point of segment on line to intersect\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.isValid` returns true if and only if the line intersects the plane.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * `d.a` is the intersection parameter. If `d.a` is in [0,1], the segment intersects the plane of the triangle.\r\n * @see [[intersectRay3d]]\r\n */\r\n public intersectSegment(point0: Point3d, point1: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n BarycentricTriangle._workRay = Ray3d.createStartEnd(point0, point1, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(BarycentricTriangle._workRay, result);\r\n }\r\n /**\r\n * Adjust the location to the closest edge of the triangle if within either given tolerance.\r\n * @param location details of a point in the plane of the triangle (note that `location.local` and\r\n * `location.world` possibly updated to lie on the triangle closest edge)\r\n * @param distanceTolerance absolute distance tolerance (or zero to ignore)\r\n * @param parameterTolerance barycentric coordinate fractional tolerance (or zero to ignore)\r\n * @return whether the location was adjusted\r\n */\r\n public snapLocationToEdge(\r\n location: TriangleLocationDetail,\r\n distanceTolerance: number = Geometry.smallMetricDistance,\r\n parameterTolerance: number = Geometry.smallFloatingPoint,\r\n ): boolean {\r\n if (!location.isValid)\r\n return false;\r\n // first try parametric tol to zero barycentric coordinate (no vertices or world distances used!)\r\n if (parameterTolerance > 0.0) {\r\n let numSnapped = 0;\r\n let newSum = 0.0;\r\n for (let i = 0; i < 3; i++) {\r\n const barycentricDist = Math.abs(location.local.at(i));\r\n if (barycentricDist > 0.0 && barycentricDist < parameterTolerance) {\r\n location.local.setAt(i, 0.0);\r\n numSnapped++;\r\n }\r\n newSum += location.local.at(i);\r\n }\r\n if (numSnapped > 0 && newSum > 0.0) {\r\n location.local.scaleInPlace(1.0 / newSum);\r\n if (1 === numSnapped) {\r\n location.closestEdgeIndex = BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(\r\n BarycentricTriangle.isOnBoundedEdge(location.local.x, location.local.y, location.local.z),\r\n );\r\n location.closestEdgeParam = 1.0 - location.local.at(location.closestEdgeIndex);\r\n } else { // 2 snapped, at vertex\r\n location.closestEdgeIndex = BarycentricTriangle.isOnVertex(\r\n location.local.x, location.local.y, location.local.z,\r\n );\r\n location.closestEdgeParam = 0.0;\r\n }\r\n this.fractionToPoint(location.local.x, location.local.y, location.local.z, location.world);\r\n return true;\r\n }\r\n }\r\n // failing that, try distance tol to closest edge projection\r\n if (distanceTolerance > 0.0) {\r\n const i = location.closestEdgeIndex;\r\n const j = (i + 1) % 3;\r\n const k = (j + 1) % 3;\r\n const edgeProjection = BarycentricTriangle._workPoint = this.points[i].interpolate(\r\n location.closestEdgeParam, this.points[j], BarycentricTriangle._workPoint,\r\n );\r\n const dist = location.world.distance(edgeProjection);\r\n if (dist > 0.0 && dist < distanceTolerance) {\r\n location.local.setAt(i, 1.0 - location.closestEdgeParam);\r\n location.local.setAt(j, location.closestEdgeParam);\r\n location.local.setAt(k, 0.0);\r\n location.world.setFrom(edgeProjection);\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return the dot product of the scaled normals of the two triangles.\r\n * * The sign of the return value is useful for determining the triangles' relative orientation:\r\n * positive (negative) means the normals point into the same (opposite) half-space determined by\r\n * one of the triangles' planes; zero means the triangles are perpendicular.\r\n */\r\n public dotProductOfCrossProductsFromOrigin(other: BarycentricTriangle): number {\r\n BarycentricTriangle._workVector0 = this.points[0].crossProductToPoints(\r\n this.points[1], this.points[2], BarycentricTriangle._workVector0,\r\n );\r\n BarycentricTriangle._workVector1 = other.points[0].crossProductToPoints(\r\n other.points[1], other.points[2], BarycentricTriangle._workVector1,\r\n );\r\n return BarycentricTriangle._workVector0.dotProduct(BarycentricTriangle._workVector1);\r\n }\r\n /** Return the centroid of the 3 points. */\r\n public centroid(result?: Point3d): Point3d {\r\n // Do the scale as true division (rather than multiply by precomputed 1/3). This might protect one bit of result.\r\n return Point3d.create(\r\n (this.points[0].x + this.points[1].x + this.points[2].x) / 3.0,\r\n (this.points[0].y + this.points[1].y + this.points[2].y) / 3.0,\r\n (this.points[0].z + this.points[1].z + this.points[2].z) / 3.0,\r\n result,\r\n );\r\n }\r\n /** Return the incenter of the triangle. */\r\n public incenter(result?: Point3d): Point3d {\r\n const a = this.edgeLength(0);\r\n const b = this.edgeLength(1);\r\n const c = this.edgeLength(2);\r\n const scale = Geometry.safeDivideFraction(1.0, a + b + c, 0.0);\r\n return this.fractionToPoint(scale * a, scale * b, scale * c, result);\r\n }\r\n /** Return the circumcenter of the triangle. */\r\n public circumcenter(result?: Point3d): Point3d {\r\n const a2 = this.edgeLengthSquared(0);\r\n const b2 = this.edgeLengthSquared(1);\r\n const c2 = this.edgeLengthSquared(2);\r\n const x = a2 * (b2 + c2 - a2);\r\n const y = b2 * (c2 + a2 - b2);\r\n const z = c2 * (a2 + b2 - c2);\r\n const scale = Geometry.safeDivideFraction(1.0, x + y + z, 0.0);\r\n return this.fractionToPoint(scale * x, scale * y, scale * z, result);\r\n }\r\n /** Test for point-by-point `isAlmostEqual` relationship. */\r\n public isAlmostEqual(other: BarycentricTriangle, tol?: number): boolean {\r\n return this.points[0].isAlmostEqual(other.points[0], tol)\r\n && this.points[1].isAlmostEqual(other.points[1], tol)\r\n && this.points[2].isAlmostEqual(other.points[2], tol);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BarycentricTriangle.js","sourceRoot":"","sources":["../../../src/geometry3d/BarycentricTriangle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAE7C,0CAAwD;AACxD,yCAAsC;AACtC,uDAAsD;AACtD,mCAAgC;AAGhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,sBAAsB;IAiBjC;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IACD,4DAA4D;IACrD,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,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AAC;QAC9B,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,mBAAQ,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;IACD,4DAA4D;IACrD,aAAa,CAAC,KAA0B,EAAE,GAAY;QAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eACpD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eAClD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF;AAhiBD,kDAgiBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\n\r\nimport { Geometry, PolygonLocation } from \"../Geometry\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n/**\r\n * Carries data about a location in the plane of a triangle.\r\n * * Each instance carries both world and barycentric coordinates for the point, and provides query\r\n * services on the latter.\r\n * * No tolerance is used when querying barycentric coordinates (e.g., `isInsideOrOn`, `classify`). Use\r\n * [[BarycentricTriangle.snapLocationToEdge]] to adjust the barycentric coordinates to a triangle edge\r\n * if they lie within a distance or parametric tolerance.\r\n *\r\n * Properties of the barycentric coordinates `(b0, b1, b2)` of a point `p` in the plane of a triangle\r\n * `T` with vertices `v0, v1, v2`:\r\n * * `1 = b0 + b1 + b2`\r\n * * `p = b0 * v0 + b1 * v1 + b2 * v2`\r\n * * If T is spanned by the vectors `U = v1 - v0` and `V = v2 - v0`, then the vector `P = p - v0` can\r\n * be written `P = b1 * U + b2 * V`.\r\n * * The coordinates are all nonnegative if and only if `p` is inside or on `T`.\r\n * * Exactly one coordinate is zero if and only if `p` lies on an (infinitely extended) edge of `T`.\r\n * * Exactly two coordinates are zero if and only if `p` coincides with a vertex of `T`.\r\n * * Note that if `p` can be written as a linear combination of the vertices of `T` using scales that do\r\n * NOT sum to 1, then `p` is not coplanar with `T`\r\n * @public\r\n */\r\nexport class TriangleLocationDetail {\r\n /** The Cartesian coordinates of the point p. */\r\n public world: Point3d;\r\n /** The barycentric coordinates of p with respect to the triangle. Assumed to sum to one. */\r\n public local: Point3d;\r\n /** Application-specific number */\r\n public a: number;\r\n /** Index of the triangle vertex at the start of the closest edge to p. */\r\n public closestEdgeIndex: number;\r\n /**\r\n * The parameter f along the closest edge to p of its projection q.\r\n * * We have q = v_i + f * (v_j - v_i) where i = closestEdgeIndex and j = (i + 1) % 3 are the indices\r\n * of the start vertex v_i and end vertex v_j of the closest edge to p.\r\n * * Note that 0 <= f <= 1.\r\n */\r\n public closestEdgeParam: number;\r\n\r\n private constructor() {\r\n this.world = new Point3d();\r\n this.local = new Point3d();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /** Invalidate this detail (set all attributes to zero) . */\r\n public invalidate() {\r\n this.world.setZero();\r\n this.local.setZero();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /**\r\n * Create an invalid detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(result?: TriangleLocationDetail): TriangleLocationDetail {\r\n if (undefined === result)\r\n result = new TriangleLocationDetail();\r\n else\r\n result.invalidate();\r\n return result;\r\n }\r\n /**\r\n * Set the instance contents from the `other` detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: TriangleLocationDetail) {\r\n this.world.setFrom(other.world);\r\n this.local.setFrom(other.local);\r\n this.a = other.a;\r\n this.closestEdgeIndex = other.closestEdgeIndex;\r\n this.closestEdgeParam = other.closestEdgeParam;\r\n }\r\n /** Whether this detail is invalid. */\r\n public get isValid(): boolean {\r\n return !this.local.isZero;\r\n }\r\n /**\r\n * Queries the barycentric coordinates to determine whether this instance specifies a location inside or\r\n * on the triangle.\r\n * @see classify\r\n */\r\n public get isInsideOrOn(): boolean {\r\n return this.isValid && this.local.x >= 0.0 && this.local.y >= 0.0 && this.local.z >= 0.0;\r\n }\r\n /**\r\n * Queries this detail to classify the location of this instance with respect to the triangle.\r\n * @returns location code\r\n * @see isInsideOrOn\r\n */\r\n public get classify(): PolygonLocation {\r\n if (!this.isValid)\r\n return PolygonLocation.Unknown;\r\n if (this.isInsideOrOn) {\r\n let numZero = 0;\r\n if (Math.abs(this.local.x) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.y) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.z) === 0.0)\r\n ++numZero;\r\n if (2 === numZero)\r\n return PolygonLocation.OnPolygonVertex;\r\n if (1 === numZero)\r\n return PolygonLocation.OnPolygonEdgeInterior;\r\n return PolygonLocation.InsidePolygonProjectsToEdgeInterior;\r\n }\r\n return (this.closestEdgeParam === 0.0) ?\r\n PolygonLocation.OutsidePolygonProjectsToVertex :\r\n PolygonLocation.OutsidePolygonProjectsToEdgeInterior;\r\n }\r\n}\r\n\r\n/**\r\n * 3 points defining a triangle to be evaluated with barycentric coordinates.\r\n * @public\r\n */\r\nexport class BarycentricTriangle {\r\n /** Array of 3 point coordinates for the triangle. */\r\n public points: Point3d[];\r\n /** Edge length squared cache, indexed by opposite vertex index */\r\n protected edgeLength2: number[];\r\n // private attributes\r\n private static _workPoint?: Point3d;\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workRay?: Ray3d;\r\n private static _workMatrix?: Matrix3d;\r\n /**\r\n * Constructor.\r\n * * Point references are CAPTURED\r\n */\r\n protected constructor(point0: Point3d, point1: Point3d, point2: Point3d) {\r\n this.points = [];\r\n this.points.push(point0);\r\n this.points.push(point1);\r\n this.points.push(point2);\r\n this.edgeLength2 = [];\r\n this.edgeLength2.push(point1.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point1));\r\n }\r\n /**\r\n * Copy contents of (not pointers to) the given points. A vertex is zeroed if its corresponding input point\r\n * is undefined.\r\n */\r\n public set(point0: Point3d | undefined, point1: Point3d | undefined, point2: Point3d | undefined) {\r\n this.points[0].setFromPoint3d(point0);\r\n this.points[1].setFromPoint3d(point1);\r\n this.points[2].setFromPoint3d(point2);\r\n this.edgeLength2[0] = this.points[1].distanceSquared(this.points[2]);\r\n this.edgeLength2[1] = this.points[0].distanceSquared(this.points[2]);\r\n this.edgeLength2[2] = this.points[0].distanceSquared(this.points[1]);\r\n }\r\n /** Copy all values from `other` */\r\n public setFrom(other: BarycentricTriangle) {\r\n for (let i = 0; i < 3; ++i) {\r\n this.points[i].setFromPoint3d(other.points[i]);\r\n this.edgeLength2[i] = other.edgeLength2[i];\r\n }\r\n }\r\n /**\r\n * Create a `BarycentricTriangle` with coordinates given by enumerated x,y,z of the 3 points.\r\n * @param result optional pre-allocated triangle.\r\n */\r\n public static createXYZXYZXYZ(\r\n x0: number, y0: number, z0: number,\r\n x1: number, y1: number, z1: number,\r\n x2: number, y2: number, z2: number,\r\n result?: BarycentricTriangle,\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(Point3d.create(x0, y0, z0), Point3d.create(x1, y1, z1), Point3d.create(x2, y2, z2));\r\n result.points[0].set(x0, y0, z0);\r\n result.points[1].set(x1, y1, z1);\r\n result.points[2].set(x2, y2, z2);\r\n return result;\r\n }\r\n /** Create a triangle with coordinates cloned from given points. */\r\n public static create(\r\n point0: Point3d, point1: Point3d, point2: Point3d, result?: BarycentricTriangle,\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(point0.clone(), point1.clone(), point2.clone());\r\n result.set(point0, point1, point2);\r\n return result;\r\n }\r\n /** Return a new `BarycentricTriangle` with the same coordinates. */\r\n public clone(result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(this.points[0], this.points[1], this.points[2], result);\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(\r\n transform.multiplyPoint3d(this.points[0], result?.points[0]),\r\n transform.multiplyPoint3d(this.points[1], result?.points[1]),\r\n transform.multiplyPoint3d(this.points[2], result?.points[2]),\r\n result,\r\n );\r\n }\r\n /** Return the area of the triangle. */\r\n public get area(): number {\r\n // The magnitude of the cross product A × B is the area of the parallelogram spanned by A and B.\r\n return 0.5 * this.points[0].crossProductToPointsMagnitude(this.points[1], this.points[2]);\r\n }\r\n /**\r\n * Compute squared length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLengthSquared(oppositeVertexIndex: number): number {\r\n return this.edgeLength2[Geometry.cyclic3dAxis(oppositeVertexIndex)];\r\n }\r\n /**\r\n * Compute length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLength(oppositeVertexIndex: number): number {\r\n return Math.sqrt(this.edgeLengthSquared(oppositeVertexIndex));\r\n }\r\n /** Return area divided by sum of squared lengths. */\r\n public get aspectRatio(): number {\r\n return Geometry.safeDivideFraction(\r\n this.area, this.edgeLengthSquared(0) + this.edgeLengthSquared(1) + this.edgeLengthSquared(2), 0,\r\n );\r\n }\r\n /** Return the perimeter of the triangle. */\r\n public get perimeter(): number {\r\n return this.edgeLength(0) + this.edgeLength(1) + this.edgeLength(2);\r\n }\r\n /**\r\n * Return the unit normal of the triangle.\r\n * @param result optional pre-allocated vector to fill and return.\r\n * @returns unit normal, or undefined if cross product length is too small.\r\n */\r\n public normal(result?: Vector3d): Vector3d | undefined {\r\n const cross = this.points[0].crossProductToPoints(this.points[1], this.points[2], result);\r\n if (cross.tryNormalizeInPlace())\r\n return cross;\r\n return undefined;\r\n }\r\n /**\r\n * Sum the triangle points with given scales.\r\n * * If the scales sum to 1, they are barycentric coordinates, and hence the result point is in the plane of\r\n * the triangle. If all coordinates are non-negative then the result point is inside the triangle.\r\n * * If the scales do not sum to 1, the point is inside the triangle scaled (by the scale sum) from the origin.\r\n * @param b0 scale to apply to vertex 0\r\n * @param b1 scale to apply to vertex 1\r\n * @param b2 scale to apply to vertex 2\r\n * @param result optional pre-allocated point to fill and return\r\n * @return linear combination of the vertices of this triangle\r\n * @see [[pointToFraction]]\r\n */\r\n public fractionToPoint(b0: number, b1: number, b2: number, result?: Point3d): Point3d {\r\n // p = b0 * v0 + b1 * v1 + b2 * v2\r\n return Point3d.createAdd3Scaled(this.points[0], b0, this.points[1], b1, this.points[2], b2, result);\r\n }\r\n /**\r\n * Compute the projection of the given `point` onto the plane of this triangle.\r\n * @param point point p to project\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the projection point `P = d.world`:\r\n * * `d.isValid` returns true if and only if `this.normal()` is defined.\r\n * * `d.classify` can be used to determine where P lies with respect to the triangle.\r\n * * `d.a` is the signed projection distance: `P = p + a * this.normal()`.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BarycentricTriangle\r\n * @see [[fractionToPoint]]\r\n */\r\n public pointToFraction(point: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n const normal = BarycentricTriangle._workVector0 = this.normal(BarycentricTriangle._workVector0);\r\n if (undefined === normal)\r\n return TriangleLocationDetail.create(result);\r\n const ray = BarycentricTriangle._workRay = Ray3d.create(point, normal, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(ray, result); // intersectRay3d is free to use workVector0\r\n }\r\n /** Convert from opposite-vertex to start-vertex edge indexing. */\r\n public static edgeOppositeVertexIndexToStartVertexIndex(edgeIndex: number): number {\r\n return Geometry.cyclic3dAxis(edgeIndex + 1);\r\n }\r\n /** Convert from start-vertex to opposite-vertex edge indexing. */\r\n public static edgeStartVertexIndexToOppositeVertexIndex(startVertexIndex: number): number {\r\n return Geometry.cyclic3dAxis(startVertexIndex - 1);\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle but not on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is strictly inside the triangle.\r\n */\r\n public static isInsideTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 > 0 && b1 > 0 && b2 > 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle or on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is inside or on the triangle.\r\n */\r\n public static isInsideOrOnTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 >= 0 && b1 >= 0 && b2 >= 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside an edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i < 0 and b_j >= 0, and b_k >= 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondEdge(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives smaller regions)\r\n if (b0 < 0 && b1 >= 0 && b2 >= 0)\r\n return 0;\r\n if (b0 >= 0 && b1 < 0 && b2 >= 0)\r\n return 1;\r\n if (b0 >= 0 && b1 >= 0 && b2 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_j < 0 and b_k < 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondVertex(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives larger regions)\r\n if (b1 < 0 && b2 < 0)\r\n return 0;\r\n if (b0 < 0 && b2 < 0)\r\n return 1;\r\n if (b0 < 0 && b1 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_i = 1 and b_j = b_k = 0. Otherwise, returns -1.\r\n */\r\n private static isOnVertex(b0: number, b1: number, b2: number): number {\r\n if (b0 === 1 && b1 === 0 && b2 === 0)\r\n return 0;\r\n if (b0 === 0 && b1 === 1 && b2 === 0)\r\n return 1;\r\n if (b0 === 0 && b1 === 0 && b2 === 1)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a bounded edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i = 0, b_j > 0, and b_k > 0. Otherwise, returns -1.\r\n */\r\n private static isOnBoundedEdge(b0: number, b1: number, b2: number): number {\r\n if (b0 === 0 && b1 > 0 && b2 > 0)\r\n return 0;\r\n if (b0 > 0 && b1 === 0 && b2 > 0)\r\n return 1;\r\n if (b0 > 0 && b1 > 0 && b2 === 0)\r\n return 2;\r\n return -1;\r\n }\r\n /** @returns edge/vertex index (0,1,2) for which the function has a minimum value */\r\n private static indexOfMinimum(fn: (index: number) => number): number {\r\n let i = 0;\r\n let min = fn(0);\r\n const val = fn(1);\r\n if (min > val) {\r\n i = 1;\r\n min = val;\r\n }\r\n if (min > fn(2))\r\n i = 2;\r\n return i;\r\n }\r\n /**\r\n * Compute the squared distance between two points given by their barycentric coordinates.\r\n * * It is assumed that a0 + a1 + a2 = b0 + b1 + b2 = 1.\r\n */\r\n public distanceSquared(a0: number, a1: number, a2: number, b0: number, b1: number, b2: number): number {\r\n // The barycentric displacement vector distance formula\r\n // More details can be found at https://web.evanchen.cc/handouts/bary/bary-full.pdf\r\n return -this.edgeLengthSquared(0) * (b1 - a1) * (b2 - a2)\r\n - this.edgeLengthSquared(1) * (b2 - a2) * (b0 - a0)\r\n - this.edgeLengthSquared(2) * (b0 - a0) * (b1 - a1);\r\n }\r\n /** Return the index of the closest triangle vertex to the point given by its barycentric coordinates. */\r\n public closestVertexIndex(b0: number, b1: number, b2: number): number {\r\n return BarycentricTriangle.indexOfMinimum((i: number) => {\r\n const a = BarycentricTriangle._workPoint = Point3d.createZero(BarycentricTriangle._workPoint);\r\n a.setAt(i, 1.0); // \"a\" is (1,0,0) or (0,1,0) or (0,0,1) so \"a\" represents vertex i\r\n return this.distanceSquared(a.x, a.y, a.z, b0, b1, b2); // distance between the point and vertex i\r\n });\r\n }\r\n /** Compute dot product of the edge vectors based at the vertex with the given index. */\r\n public dotProductOfEdgeVectorsAtVertex(baseVertexIndex: number): number {\r\n const i = Geometry.cyclic3dAxis(baseVertexIndex);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n const k = Geometry.cyclic3dAxis(j + 1);\r\n return Geometry.dotProductXYZXYZ(\r\n this.points[j].x - this.points[i].x, this.points[j].y - this.points[i].y, this.points[j].z - this.points[i].z,\r\n this.points[k].x - this.points[i].x, this.points[k].y - this.points[i].y, this.points[k].z - this.points[i].z,\r\n );\r\n }\r\n /**\r\n * Compute the projection of barycentric point p onto the (unbounded) edge e_k(v_i,v_j) of the triangle T(v_i,v_j,v_k).\r\n * @param k vertex v_k is opposite the edge e_k\r\n * @param b barycentric coordinates of point to project\r\n * @returns parameter f along e_k, such that:\r\n * * the projection point is q = v_i + f * (v_j - v_i)\r\n * * the barycentric coords of the projection are q_ijk = (1 - f, f, 0)\r\n */\r\n private computeProjectionToEdge(k: number, b: number[]): number {\r\n /**\r\n * We know p = (b_i*v_i) + (b_j*v_j) + (b_k*v_k) and 1 = b_i + b_j + b_k.\r\n * Let U = v_j - v_i and V = v_k - v_i and P = p - v_i.\r\n * First we prove P = b_jU + b_kV.\r\n * P = (b_i * v_i) + (b_j * v_j) + (b_k * v_k) - v_i\r\n * = (b_i * v_i) + (b_j * (v_j-v_i)) + (b_j * v_i) + (b_k * (v_k-v_i)) + (b_k * v_i) - v_i\r\n * = (b_i * v_i) + (b_j * U) + (b_j * v_i) + (b_k * V) + (b_k * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + ((b_i + b_j + b_k) * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + v_i - v_i\r\n * = (b_j * U) + (b_k * V)\r\n * So we know p - v_i = b_jU + b_kV and q - v_i = fU\r\n * Therefore, 0 = (p - q).(v_j - v_i)\r\n * = ((p-v_i) - (q-v_i)).(v_j - v_i)\r\n * = (b_jU + b_kV - fU).U\r\n * = b_jU.U + b_kU.V - fU.U\r\n * Thus f = b_j + b_k(U.V/U.U)\r\n */\r\n k = Geometry.cyclic3dAxis(k);\r\n const i = Geometry.cyclic3dAxis(k + 1);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n return b[j] + b[k] * this.dotProductOfEdgeVectorsAtVertex(i) / this.edgeLengthSquared(k);\r\n }\r\n /**\r\n * Compute the projection of a barycentric point p to the triangle T(v_0,v_1,v_2).\r\n * @param b0 barycentric coordinate of p corresponding to v_0\r\n * @param b1 barycentric coordinate of p corresponding to v_1\r\n * @param b2 barycentric coordinate of p corresponding to v_2\r\n * @returns closest edge start vertex index i and projection parameter f such that the projection\r\n * q = v_i + f * (v_j - v_i).\r\n */\r\n public closestPoint(b0: number, b1: number, b2: number): { closestEdgeIndex: number, closestEdgeParam: number } {\r\n const b: number[] = [b0, b1, b2];\r\n let edgeIndex = -1; // opposite-vertex index\r\n let edgeParam = 0.0;\r\n if (BarycentricTriangle.isInsideTriangle(b0, b1, b2)) { // projects to any edge\r\n edgeIndex = BarycentricTriangle.indexOfMinimum((i: number) => {\r\n // We want smallest projection distance d_i of p to e_i.\r\n // Since b_i=d_i|e_i|/2A we can compare quantities b_i/|e_i|.\r\n return b[i] * b[i] / this.edgeLengthSquared(i); // avoid sqrt\r\n });\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondVertex(b0, b1, b2)) >= 0) { // projects to other edges, or any vertex\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(this.closestVertexIndex(b0, b1, b2));\r\n }\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondEdge(b0, b1, b2)) >= 0) { // projects to the edge or its vertices\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0) {\r\n edgeParam = 0.0; // start of this edge\r\n } else if (edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1); // end of this edge = start of next edge\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isOnBoundedEdge(b0, b1, b2)) >= 0) {\r\n edgeParam = 1 - b[BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex)];\r\n } else if ((edgeIndex = BarycentricTriangle.isOnVertex(b0, b1, b2)) >= 0) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(edgeIndex);\r\n }\r\n // invalid edgeIndex shouldn't happen, but propagate it anyway\r\n assert(edgeIndex === 0 || edgeIndex === 1 || edgeIndex === 2);\r\n return {\r\n closestEdgeIndex: (edgeIndex < 0) ? -1 : BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex),\r\n closestEdgeParam: edgeParam,\r\n };\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a ray) with the plane of this triangle.\r\n * * This method is slower than `Ray3d.intersectionWithTriangle`.\r\n * @param ray infinite line to intersect, as a ray\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.a` is the intersection parameter along the ray.\r\n * * The line intersects the plane of the triangle if and only if `d.isValid` returns true.\r\n * * The ray intersects the plane of the triangle if and only if `d.isValid` returns true and `d.a` >= 0.\r\n * * The ray intersects the triangle if and only if `d.isValid` returns true, `d.a` >= 0, and `d.isInsideOrOn`\r\n * returns true.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/RayTriangleIntersection\r\n * @see [[pointToFraction]]\r\n */\r\n public intersectRay3d(ray: Ray3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n result = TriangleLocationDetail.create(result);\r\n /**\r\n * Let r0 = ray.origin and d = ray.direction. Write intersection point p two ways for unknown scalars s,b0,b1,b2:\r\n * r0 + s*d = p = b0*v0 + b1*v1 + b2*v2\r\n * Subtract v0 from both ends, let u=v1-v0, v=v2-v0, c=r0-v0, and enforce b0+b1+b2=1:\r\n * b1*u + b2*v - s*d = c\r\n * This is a linear system Mx = c where M has columns u,v,d and solution x=(b1,b2,-s).\r\n */\r\n const r0 = ray.origin;\r\n const d = ray.direction;\r\n const u = BarycentricTriangle._workVector0 = Vector3d.createStartEnd(\r\n this.points[0], this.points[1], BarycentricTriangle._workVector0,\r\n );\r\n const v = BarycentricTriangle._workVector1 = Vector3d.createStartEnd(\r\n this.points[0], this.points[2], BarycentricTriangle._workVector1,\r\n );\r\n const M = BarycentricTriangle._workMatrix = Matrix3d.createColumns(u, v, d, BarycentricTriangle._workMatrix);\r\n const c = Vector3d.createStartEnd(this.points[0], r0, BarycentricTriangle._workVector0); // reuse workVector0\r\n const solution = BarycentricTriangle._workVector1; // reuse workVector1\r\n if (undefined === M.multiplyInverse(c, solution))\r\n return result; // invalid\r\n result.a = -solution.z; // = -(-s) = s\r\n ray.fractionToPoint(result.a, result.world);\r\n result.local.set(1.0 - solution.x - solution.y, solution.x, solution.y); // = (1 - b1 - b2, b1, b2) = (b0 , b1, b2)\r\n const proj = this.closestPoint(result.local.x, result.local.y, result.local.z);\r\n result.closestEdgeIndex = proj.closestEdgeIndex;\r\n result.closestEdgeParam = proj.closestEdgeParam;\r\n return result;\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a line segment) with the plane of this triangle.\r\n * @param point0 start point of segment on line to intersect\r\n * @param point1 end point of segment on line to intersect\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.isValid` returns true if and only if the line intersects the plane.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * `d.a` is the intersection parameter. If `d.a` is in [0,1], the segment intersects the plane of the triangle.\r\n * @see [[intersectRay3d]]\r\n */\r\n public intersectSegment(point0: Point3d, point1: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n BarycentricTriangle._workRay = Ray3d.createStartEnd(point0, point1, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(BarycentricTriangle._workRay, result);\r\n }\r\n /**\r\n * Adjust the location to the closest edge of the triangle if within either given tolerance.\r\n * @param location details of a point in the plane of the triangle (note that `location.local` and\r\n * `location.world` possibly updated to lie on the triangle closest edge)\r\n * @param distanceTolerance absolute distance tolerance (or zero to ignore)\r\n * @param parameterTolerance barycentric coordinate fractional tolerance (or zero to ignore)\r\n * @return whether the location was adjusted\r\n */\r\n public snapLocationToEdge(\r\n location: TriangleLocationDetail,\r\n distanceTolerance: number = Geometry.smallMetricDistance,\r\n parameterTolerance: number = Geometry.smallFloatingPoint,\r\n ): boolean {\r\n if (!location.isValid)\r\n return false;\r\n // first try parametric tol to zero barycentric coordinate (no vertices or world distances used!)\r\n if (parameterTolerance > 0.0) {\r\n let numSnapped = 0;\r\n let newSum = 0.0;\r\n for (let i = 0; i < 3; i++) {\r\n const barycentricDist = Math.abs(location.local.at(i));\r\n if (barycentricDist > 0.0 && barycentricDist < parameterTolerance) {\r\n location.local.setAt(i, 0.0);\r\n numSnapped++;\r\n }\r\n newSum += location.local.at(i);\r\n }\r\n if (numSnapped > 0 && newSum > 0.0) {\r\n location.local.scaleInPlace(1.0 / newSum);\r\n if (1 === numSnapped) {\r\n location.closestEdgeIndex = BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(\r\n BarycentricTriangle.isOnBoundedEdge(location.local.x, location.local.y, location.local.z),\r\n );\r\n location.closestEdgeParam = 1.0 - location.local.at(location.closestEdgeIndex);\r\n } else { // 2 snapped, at vertex\r\n location.closestEdgeIndex = BarycentricTriangle.isOnVertex(\r\n location.local.x, location.local.y, location.local.z,\r\n );\r\n location.closestEdgeParam = 0.0;\r\n }\r\n this.fractionToPoint(location.local.x, location.local.y, location.local.z, location.world);\r\n return true;\r\n }\r\n }\r\n // failing that, try distance tol to closest edge projection\r\n if (distanceTolerance > 0.0) {\r\n const i = location.closestEdgeIndex;\r\n const j = (i + 1) % 3;\r\n const k = (j + 1) % 3;\r\n const edgeProjection = BarycentricTriangle._workPoint = this.points[i].interpolate(\r\n location.closestEdgeParam, this.points[j], BarycentricTriangle._workPoint,\r\n );\r\n const dist = location.world.distance(edgeProjection);\r\n if (dist > 0.0 && dist < distanceTolerance) {\r\n location.local.setAt(i, 1.0 - location.closestEdgeParam);\r\n location.local.setAt(j, location.closestEdgeParam);\r\n location.local.setAt(k, 0.0);\r\n location.world.setFrom(edgeProjection);\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return the dot product of the scaled normals of the two triangles.\r\n * * The sign of the return value is useful for determining the triangles' relative orientation:\r\n * positive (negative) means the normals point into the same (opposite) half-space determined by\r\n * one of the triangles' planes; zero means the triangles are perpendicular.\r\n */\r\n public dotProductOfCrossProductsFromOrigin(other: BarycentricTriangle): number {\r\n BarycentricTriangle._workVector0 = this.points[0].crossProductToPoints(\r\n this.points[1], this.points[2], BarycentricTriangle._workVector0,\r\n );\r\n BarycentricTriangle._workVector1 = other.points[0].crossProductToPoints(\r\n other.points[1], other.points[2], BarycentricTriangle._workVector1,\r\n );\r\n return BarycentricTriangle._workVector0.dotProduct(BarycentricTriangle._workVector1);\r\n }\r\n /** Return the centroid of the 3 points. */\r\n public centroid(result?: Point3d): Point3d {\r\n // Do the scale as true division (rather than multiply by precomputed 1/3). This might protect one bit of result.\r\n return Point3d.create(\r\n (this.points[0].x + this.points[1].x + this.points[2].x) / 3.0,\r\n (this.points[0].y + this.points[1].y + this.points[2].y) / 3.0,\r\n (this.points[0].z + this.points[1].z + this.points[2].z) / 3.0,\r\n result,\r\n );\r\n }\r\n /** Return the incenter of the triangle. */\r\n public incenter(result?: Point3d): Point3d {\r\n const a = this.edgeLength(0);\r\n const b = this.edgeLength(1);\r\n const c = this.edgeLength(2);\r\n const scale = Geometry.safeDivideFraction(1.0, a + b + c, 0.0);\r\n return this.fractionToPoint(scale * a, scale * b, scale * c, result);\r\n }\r\n /** Return the circumcenter of the triangle. */\r\n public circumcenter(result?: Point3d): Point3d {\r\n const a2 = this.edgeLengthSquared(0);\r\n const b2 = this.edgeLengthSquared(1);\r\n const c2 = this.edgeLengthSquared(2);\r\n const x = a2 * (b2 + c2 - a2);\r\n const y = b2 * (c2 + a2 - b2);\r\n const z = c2 * (a2 + b2 - c2);\r\n const scale = Geometry.safeDivideFraction(1.0, x + y + z, 0.0);\r\n return this.fractionToPoint(scale * x, scale * y, scale * z, result);\r\n }\r\n /** Test for point-by-point `isAlmostEqual` relationship. */\r\n public isAlmostEqual(other: BarycentricTriangle, tol?: number): boolean {\r\n return this.points[0].isAlmostEqual(other.points[0], tol)\r\n && this.points[1].isAlmostEqual(other.points[1], tol)\r\n && this.points[2].isAlmostEqual(other.points[2], tol);\r\n }\r\n}\r\n"]}
@@ -23,6 +23,10 @@ export declare class FrameBuilder {
23
23
  private _vector0;
24
24
  private _vector1;
25
25
  private _vector2;
26
+ private static _workMatrix?;
27
+ private static _workVector0?;
28
+ private static _workVector1?;
29
+ private static _workPoint?;
26
30
  private areStronglyIndependentVectors;
27
31
  /** Clear all accumulated point and vector data */
28
32
  clear(): void;
@@ -32,7 +36,7 @@ export declare class FrameBuilder {
32
36
  * * If allowLeftHanded is false, vector0 and vector1 determine a right handed coordinate system.
33
37
  * * if allowLeftHanded is true, the z vector of the right handed system can be flipped to agree with vector2 direction.
34
38
  */
35
- getValidatedFrame(allowLeftHanded?: boolean): Transform | undefined;
39
+ getValidatedFrame(allowLeftHanded?: boolean, result?: Transform): Transform | undefined;
36
40
  /** If vector0 is known but vector1 is not, make vector1 the cross of the up-vector and vector0 */
37
41
  applyDefaultUpVector(vector?: Vector3d): void;
38
42
  /** Ask if there is a defined origin for the evolving frame */
@@ -57,6 +61,11 @@ export declare class FrameBuilder {
57
61
  * * origin is at first point.
58
62
  * * x axis in direction of first nonzero vector present or implied by the input.
59
63
  * * y axis is perpendicular to x and contains (in positive side) the next vector present or implied by the input.
64
+ * * The calculation favors the first points found. It does not try to get a "best" plane.
65
+ * @param defaultUpVector optional vector to cross with vector0 to create vector1 when it is unknown
66
+ * @param params any number of geometric objects to examine in [[announce]] for point/vector data sufficient to construct a frame.
67
+ * If the last argument is a `Transform`, it is populated with the computed frame and returned.
68
+ * @returns computed localToWorld frame, or undefined if insufficient data.
60
69
  */
61
70
  static createRightHandedFrame(defaultUpVector: Vector3d | undefined, ...params: any[]): Transform | undefined;
62
71
  /**
@@ -64,6 +73,9 @@ export declare class FrameBuilder {
64
73
  * * The xy columns of the transform contain the first points or vectors of the data.
65
74
  * * The z column is perpendicular to that xy plane.
66
75
  * * The calculation favors the first points found. It does not try to get a "best" plane.
76
+ * @param params any number of geometric objects to examine in [[announce]] for point/vector data sufficient to construct a frame.
77
+ * If the last argument is a `Transform`, it is populated with the computed frame and returned.
78
+ * @returns computed localToWorld frame, or undefined if insufficient data.
67
79
  */
68
80
  static createRightHandedLocalToWorld(...params: any[]): Transform | undefined;
69
81
  /**
@@ -71,25 +83,30 @@ export declare class FrameBuilder {
71
83
  * * If 3 or more distinct points are present, the x axis is from the first point to the most distant, and y
72
84
  * direction is toward the point most distant from that line.
73
85
  * @param points array of points
86
+ * @param result optional pre-allocated Transform to populate and return
87
+ * @returns localToWorld frame for the points, or undefined if insufficient data
74
88
  */
75
- static createFrameToDistantPoints(points: Point3d[]): Transform | undefined;
89
+ static createFrameToDistantPoints(points: Point3d[], result?: Transform): Transform | undefined;
76
90
  /**
77
91
  * Try to create a frame whose xy plane is through points, with the points appearing CCW in the local frame.
78
- *
79
92
  * * If 3 or more distinct points are present, the x axis is from the first point to the most distant, and y
80
93
  * direction is toward the point most distant from that line.
81
94
  * @param points array of points
95
+ * @param result optional pre-allocated Transform to populate and return
96
+ * @returns localToWorld frame for the points, or undefined if insufficient data
82
97
  */
83
- static createFrameWithCCWPolygon(points: Point3d[]): Transform | undefined;
98
+ static createFrameWithCCWPolygon(points: Point3d[], result?: Transform): Transform | undefined;
84
99
  /**
85
100
  * Create the localToWorld transform from a range to axes of its parent coordinate system.
86
- * @param range [in] range to inspect
87
- * @param fractionX [in] fractional coordinate of frame origin x
88
- * @param fractionY [in] fractional coordinate of frame origin y
89
- * @param fractionZ [in] fractional coordinate of frame origin z
90
- * @param scaleSelect [in] selects size of localToWorld axes.
91
- * @param defaultAxisLength [in] if true and any axis length is 0, that axis vector takes this physical length.
101
+ * @param range range to inspect
102
+ * @param scaleSelect selects size of localToWorld axes.
103
+ * @param fractionX fractional coordinate of frame origin x
104
+ * @param fractionY fractional coordinate of frame origin y
105
+ * @param fractionZ fractional coordinate of frame origin z
106
+ * @param defaultAxisLength if true and any axis length is 0, that axis vector takes this physical length.
107
+ * @param result optional pre-allocated Transform to populate and return
108
+ * @returns localToWorld frame for the range
92
109
  */
93
- static createLocalToWorldTransformInRange(range: Range3d, scaleSelect?: AxisScaleSelect, fractionX?: number, fractionY?: number, fractionZ?: number, defaultAxisLength?: number): Transform;
110
+ static createLocalToWorldTransformInRange(range: Range3d, scaleSelect?: AxisScaleSelect, fractionX?: number, fractionY?: number, fractionZ?: number, defaultAxisLength?: number, result?: Transform): Transform;
94
111
  }
95
112
  //# sourceMappingURL=FrameBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FrameBuilder.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/FrameBuilder.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAa,eAAe,EAAY,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,QAAQ,CAAuB;IAEvC,OAAO,CAAC,6BAA6B;IASrC,kDAAkD;IAC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AAE,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS;IAatG;;;;;;;OAOG;WACW,yBAAyB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS;IAQrG;;;;;;;;;;OAUG;WACW,kCAAkC,CAC9C,KAAK,EAAE,OAAO,EACd,WAAW,GAAE,eAA4D,EACzE,SAAS,GAAE,MAAU,EACrB,SAAS,GAAE,MAAU,EACrB,SAAS,GAAE,MAAU,EACrB,iBAAiB,GAAE,MAAY,EAC/B,MAAM,CAAC,EAAE,SAAS,GACjB,SAAS;CAiBb"}
@@ -64,21 +64,24 @@ class FrameBuilder {
64
64
  * * If allowLeftHanded is false, vector0 and vector1 determine a right handed coordinate system.
65
65
  * * if allowLeftHanded is true, the z vector of the right handed system can be flipped to agree with vector2 direction.
66
66
  */
67
- getValidatedFrame(allowLeftHanded = false) {
67
+ getValidatedFrame(allowLeftHanded = false, result) {
68
68
  if (this._origin && this._vector0 && this._vector1) {
69
+ const createRigidMatrix = (v0, v1) => {
70
+ return FrameBuilder._workMatrix = Matrix3d_1.Matrix3d.createRigidFromColumns(v0, v1, Geometry_1.AxisOrder.XYZ, FrameBuilder._workMatrix);
71
+ };
69
72
  if (!allowLeftHanded) {
70
- const matrix = Matrix3d_1.Matrix3d.createRigidFromColumns(this._vector0, this._vector1, Geometry_1.AxisOrder.XYZ);
73
+ const matrix = createRigidMatrix(this._vector0, this._vector1);
71
74
  if (matrix)
72
- return Transform_1.Transform.createOriginAndMatrix(this._origin, matrix);
75
+ return Transform_1.Transform.createOriginAndMatrix(this._origin, matrix, result);
73
76
  // uh oh -- vector1 was not really independent. clear everything after vector0.
74
77
  this._vector1 = this._vector2 = undefined;
75
78
  }
76
79
  else if (this._vector2) {
77
- const matrix = Matrix3d_1.Matrix3d.createRigidFromColumns(this._vector0, this._vector1, Geometry_1.AxisOrder.XYZ);
80
+ const matrix = createRigidMatrix(this._vector0, this._vector1);
78
81
  if (matrix) {
79
82
  if (this._vector0.tripleProduct(this._vector1, this._vector2) < 0)
80
83
  matrix.scaleColumns(1.0, 1.0, -1.0);
81
- return Transform_1.Transform.createOriginAndMatrix(this._origin, matrix);
84
+ return Transform_1.Transform.createOriginAndMatrix(this._origin, matrix, result);
82
85
  }
83
86
  // uh oh again -- clear vector1 and vector2, re-announce vector2 as possible vector1??
84
87
  const vector2 = this._vector2;
@@ -157,6 +160,8 @@ class FrameBuilder {
157
160
  announce(data) {
158
161
  if (this.savedVectorCount() > 1)
159
162
  return;
163
+ if (data === undefined)
164
+ return;
160
165
  if (data instanceof Point3dVector3d_1.Point3d)
161
166
  this.announcePoint(data);
162
167
  else if (data instanceof Point3dVector3d_1.Vector3d)
@@ -238,35 +243,40 @@ class FrameBuilder {
238
243
  * * origin is at first point.
239
244
  * * x axis in direction of first nonzero vector present or implied by the input.
240
245
  * * y axis is perpendicular to x and contains (in positive side) the next vector present or implied by the input.
246
+ * * The calculation favors the first points found. It does not try to get a "best" plane.
247
+ * @param defaultUpVector optional vector to cross with vector0 to create vector1 when it is unknown
248
+ * @param params any number of geometric objects to examine in [[announce]] for point/vector data sufficient to construct a frame.
249
+ * If the last argument is a `Transform`, it is populated with the computed frame and returned.
250
+ * @returns computed localToWorld frame, or undefined if insufficient data.
241
251
  */
242
252
  static createRightHandedFrame(defaultUpVector, ...params) {
253
+ // if last arg is a Transform, remove it from the array and use for the return value
254
+ let frame = (params.length > 0 && params[params.length - 1] instanceof Transform_1.Transform) ? params.pop() : undefined;
243
255
  const builder = new FrameBuilder();
244
256
  for (const data of params) {
245
257
  builder.announce(data);
246
258
  builder.applyDefaultUpVector(defaultUpVector);
247
- const result = builder.getValidatedFrame(false);
248
- if (result !== undefined) {
259
+ if (frame = builder.getValidatedFrame(false, frame)) {
249
260
  if (defaultUpVector) {
250
- if (result.matrix.dotColumnZ(defaultUpVector) < 0.0)
251
- result.matrix.scaleColumnsInPlace(1, -1, -1);
261
+ if (frame.matrix.dotColumnZ(defaultUpVector) < 0.0)
262
+ frame.matrix.scaleColumnsInPlace(1, -1, -1);
252
263
  }
253
- return result;
264
+ return frame;
254
265
  }
255
266
  }
256
- const evaluatePrimitiveFrame = (curve) => {
257
- return curve.fractionToFrenetFrame(0.0);
267
+ const evaluatePrimitiveFrame = (curve, result) => {
268
+ return curve.fractionToFrenetFrame(0.0, result);
258
269
  };
259
270
  // try direct evaluation of curve primitives using the above lambda
260
271
  for (const data of params) {
261
272
  if (data instanceof CurvePrimitive_1.CurvePrimitive) {
262
- return evaluatePrimitiveFrame(data);
273
+ return evaluatePrimitiveFrame(data, frame);
263
274
  }
264
275
  else if (data instanceof CurveCollection_1.CurveCollection) {
265
276
  const children = data.collectCurvePrimitives();
266
277
  for (const curve of children) {
267
- const frenetFrame = evaluatePrimitiveFrame(curve);
268
- if (frenetFrame)
269
- return frenetFrame;
278
+ if (frame = evaluatePrimitiveFrame(curve, frame))
279
+ return frame;
270
280
  }
271
281
  }
272
282
  }
@@ -277,64 +287,64 @@ class FrameBuilder {
277
287
  * * The xy columns of the transform contain the first points or vectors of the data.
278
288
  * * The z column is perpendicular to that xy plane.
279
289
  * * The calculation favors the first points found. It does not try to get a "best" plane.
290
+ * @param params any number of geometric objects to examine in [[announce]] for point/vector data sufficient to construct a frame.
291
+ * If the last argument is a `Transform`, it is populated with the computed frame and returned.
292
+ * @returns computed localToWorld frame, or undefined if insufficient data.
280
293
  */
281
294
  static createRightHandedLocalToWorld(...params) {
282
- const builder = new FrameBuilder();
283
- for (const data of params) {
284
- builder.announce(data);
285
- const localToWorld = builder.getValidatedFrame(false);
286
- if (localToWorld !== undefined)
287
- return localToWorld;
288
- }
289
- return undefined;
295
+ return this.createRightHandedFrame(undefined, params);
290
296
  }
291
297
  /**
292
298
  * Try to create a frame whose xy plane is through points.
293
299
  * * If 3 or more distinct points are present, the x axis is from the first point to the most distant, and y
294
300
  * direction is toward the point most distant from that line.
295
301
  * @param points array of points
302
+ * @param result optional pre-allocated Transform to populate and return
303
+ * @returns localToWorld frame for the points, or undefined if insufficient data
296
304
  */
297
- static createFrameToDistantPoints(points) {
305
+ static createFrameToDistantPoints(points, result) {
298
306
  if (points.length > 2) {
299
- const origin = points[0].clone();
300
- const vector01 = Point3dVector3d_1.Vector3d.create();
307
+ const origin = points[0];
308
+ const vector01 = FrameBuilder._workVector0 ?? Point3dVector3d_1.Vector3d.create();
301
309
  PointHelpers_1.Point3dArray.indexOfMostDistantPoint(points, points[0], vector01);
302
- const vector02 = Point3dVector3d_1.Vector3d.create();
310
+ const vector02 = FrameBuilder._workVector1 ?? Point3dVector3d_1.Vector3d.create();
303
311
  PointHelpers_1.Point3dArray.indexOfPointWithMaxCrossProductMagnitude(points, origin, vector01, vector02);
304
- const matrix = Matrix3d_1.Matrix3d.createRigidFromColumns(vector01, vector02, Geometry_1.AxisOrder.XYZ);
312
+ const matrix = FrameBuilder._workMatrix = Matrix3d_1.Matrix3d.createRigidFromColumns(vector01, vector02, Geometry_1.AxisOrder.XYZ, FrameBuilder._workMatrix);
305
313
  if (matrix)
306
- return Transform_1.Transform.createRefs(origin, matrix);
314
+ return Transform_1.Transform.createOriginAndMatrix(origin, matrix, result);
307
315
  }
308
316
  return undefined;
309
317
  }
310
318
  /**
311
319
  * Try to create a frame whose xy plane is through points, with the points appearing CCW in the local frame.
312
- *
313
320
  * * If 3 or more distinct points are present, the x axis is from the first point to the most distant, and y
314
321
  * direction is toward the point most distant from that line.
315
322
  * @param points array of points
323
+ * @param result optional pre-allocated Transform to populate and return
324
+ * @returns localToWorld frame for the points, or undefined if insufficient data
316
325
  */
317
- static createFrameWithCCWPolygon(points) {
326
+ static createFrameWithCCWPolygon(points, result) {
318
327
  if (points.length > 2) {
319
- const ray = PolygonOps_1.PolygonOps.centroidAreaNormal(points);
320
- if (ray) {
321
- return ray.toRigidZFrame();
322
- }
328
+ const ray = PolygonOps_1.PolygonOps.centroidAreaNormal(points); // can't pass pre-allocated ray...
329
+ if (ray)
330
+ return ray.toRigidZFrame(result);
323
331
  }
324
332
  return undefined;
325
333
  }
326
334
  /**
327
335
  * Create the localToWorld transform from a range to axes of its parent coordinate system.
328
- * @param range [in] range to inspect
329
- * @param fractionX [in] fractional coordinate of frame origin x
330
- * @param fractionY [in] fractional coordinate of frame origin y
331
- * @param fractionZ [in] fractional coordinate of frame origin z
332
- * @param scaleSelect [in] selects size of localToWorld axes.
333
- * @param defaultAxisLength [in] if true and any axis length is 0, that axis vector takes this physical length.
336
+ * @param range range to inspect
337
+ * @param scaleSelect selects size of localToWorld axes.
338
+ * @param fractionX fractional coordinate of frame origin x
339
+ * @param fractionY fractional coordinate of frame origin y
340
+ * @param fractionZ fractional coordinate of frame origin z
341
+ * @param defaultAxisLength if true and any axis length is 0, that axis vector takes this physical length.
342
+ * @param result optional pre-allocated Transform to populate and return
343
+ * @returns localToWorld frame for the range
334
344
  */
335
- static createLocalToWorldTransformInRange(range, scaleSelect = Geometry_1.AxisScaleSelect.NonUniformRangeContainment, fractionX = 0, fractionY = 0, fractionZ = 0, defaultAxisLength = 1.0) {
345
+ static createLocalToWorldTransformInRange(range, scaleSelect = Geometry_1.AxisScaleSelect.NonUniformRangeContainment, fractionX = 0, fractionY = 0, fractionZ = 0, defaultAxisLength = 1.0, result) {
336
346
  if (range.isNull)
337
- return Transform_1.Transform.createIdentity();
347
+ return Transform_1.Transform.createIdentity(result);
338
348
  let a = 1.0;
339
349
  let b = 1.0;
340
350
  let c = 1.0;
@@ -346,7 +356,9 @@ class FrameBuilder {
346
356
  b = Geometry_1.Geometry.correctSmallMetricDistance(range.yLength(), defaultAxisLength) * Geometry_1.Geometry.maxAbsDiff(fractionY, 0, 1);
347
357
  c = Geometry_1.Geometry.correctSmallMetricDistance(range.zLength(), defaultAxisLength) * Geometry_1.Geometry.maxAbsDiff(fractionZ, 0, 1);
348
358
  }
349
- return Transform_1.Transform.createRefs(range.fractionToPoint(fractionX, fractionY, fractionZ), Matrix3d_1.Matrix3d.createScale(a, b, c));
359
+ const origin = FrameBuilder._workPoint = range.fractionToPoint(fractionX, fractionY, fractionZ, FrameBuilder._workPoint);
360
+ const matrix = FrameBuilder._workMatrix = Matrix3d_1.Matrix3d.createScale(a, b, c, FrameBuilder._workMatrix);
361
+ return Transform_1.Transform.createOriginAndMatrix(origin, matrix, result);
350
362
  }
351
363
  }
352
364
  exports.FrameBuilder = FrameBuilder;