@itwin/core-geometry 4.1.0-dev.7 → 4.1.0-dev.70

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 (542) hide show
  1. package/CHANGELOG.md +82 -1
  2. package/lib/cjs/Geometry.js.map +1 -1
  3. package/lib/cjs/bspline/BSplineCurve.d.ts +1 -1
  4. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  5. package/lib/cjs/bspline/BSplineCurve.js +2 -2
  6. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  7. package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
  8. package/lib/cjs/bspline/BSplineSurface.js +1 -1
  9. package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
  10. package/lib/cjs/bspline/BezierCurveBase.d.ts +1 -1
  11. package/lib/cjs/bspline/BezierCurveBase.d.ts.map +1 -1
  12. package/lib/cjs/bspline/BezierCurveBase.js +2 -2
  13. package/lib/cjs/bspline/BezierCurveBase.js.map +1 -1
  14. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  15. package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
  16. package/lib/cjs/clipping/ClipPrimitive.js +2 -0
  17. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  18. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  19. package/lib/cjs/core-geometry.d.ts +3 -1
  20. package/lib/cjs/core-geometry.d.ts.map +1 -1
  21. package/lib/cjs/core-geometry.js +3 -1
  22. package/lib/cjs/core-geometry.js.map +1 -1
  23. package/lib/cjs/curve/Arc3d.d.ts +2 -1
  24. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  25. package/lib/cjs/curve/Arc3d.js +3 -2
  26. package/lib/cjs/curve/Arc3d.js.map +1 -1
  27. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +62 -42
  28. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  29. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +71 -48
  30. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  31. package/lib/cjs/curve/CurveCollection.d.ts +36 -26
  32. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  33. package/lib/cjs/curve/CurveCollection.js +46 -39
  34. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  35. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  36. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  37. package/lib/cjs/curve/CurveFactory.d.ts +67 -3
  38. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  39. package/lib/cjs/curve/CurveFactory.js +75 -7
  40. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  41. package/lib/cjs/curve/CurveLocationDetail.d.ts +6 -6
  42. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  43. package/lib/cjs/curve/CurveLocationDetail.js +9 -7
  44. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  45. package/lib/cjs/curve/CurveOps.d.ts +77 -0
  46. package/lib/cjs/curve/CurveOps.d.ts.map +1 -0
  47. package/lib/cjs/curve/CurveOps.js +160 -0
  48. package/lib/cjs/curve/CurveOps.js.map +1 -0
  49. package/lib/cjs/curve/CurvePrimitive.d.ts +17 -16
  50. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  51. package/lib/cjs/curve/CurvePrimitive.js +4 -3
  52. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  53. package/lib/cjs/curve/GeometryQuery.d.ts +2 -2
  54. package/lib/cjs/curve/GeometryQuery.d.ts.map +1 -1
  55. package/lib/cjs/curve/GeometryQuery.js +2 -2
  56. package/lib/cjs/curve/GeometryQuery.js.map +1 -1
  57. package/lib/cjs/curve/LineSegment3d.d.ts +7 -5
  58. package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
  59. package/lib/cjs/curve/LineSegment3d.js +6 -6
  60. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  61. package/lib/cjs/curve/LineString3d.d.ts +2 -2
  62. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  63. package/lib/cjs/curve/LineString3d.js +3 -3
  64. package/lib/cjs/curve/LineString3d.js.map +1 -1
  65. package/lib/cjs/curve/Loop.d.ts +7 -5
  66. package/lib/cjs/curve/Loop.d.ts.map +1 -1
  67. package/lib/cjs/curve/Loop.js +18 -6
  68. package/lib/cjs/curve/Loop.js.map +1 -1
  69. package/lib/cjs/curve/OffsetOptions.d.ts +97 -0
  70. package/lib/cjs/curve/OffsetOptions.d.ts.map +1 -0
  71. package/lib/cjs/curve/OffsetOptions.js +166 -0
  72. package/lib/cjs/curve/OffsetOptions.js.map +1 -0
  73. package/lib/cjs/curve/ParityRegion.d.ts +7 -7
  74. package/lib/cjs/curve/ParityRegion.d.ts.map +1 -1
  75. package/lib/cjs/curve/ParityRegion.js +19 -11
  76. package/lib/cjs/curve/ParityRegion.js.map +1 -1
  77. package/lib/cjs/curve/Path.d.ts +6 -6
  78. package/lib/cjs/curve/Path.d.ts.map +1 -1
  79. package/lib/cjs/curve/Path.js +15 -9
  80. package/lib/cjs/curve/Path.js.map +1 -1
  81. package/lib/cjs/curve/ProxyCurve.d.ts +5 -7
  82. package/lib/cjs/curve/ProxyCurve.d.ts.map +1 -1
  83. package/lib/cjs/curve/ProxyCurve.js +7 -7
  84. package/lib/cjs/curve/ProxyCurve.js.map +1 -1
  85. package/lib/cjs/curve/Query/StrokeCountMap.js.map +1 -1
  86. package/lib/cjs/curve/RegionOps.d.ts +76 -56
  87. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  88. package/lib/cjs/curve/RegionOps.js +83 -60
  89. package/lib/cjs/curve/RegionOps.js.map +1 -1
  90. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +2 -2
  91. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  92. package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
  93. package/lib/cjs/curve/StrokeOptions.js +6 -2
  94. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  95. package/lib/cjs/curve/UnionRegion.d.ts +6 -5
  96. package/lib/cjs/curve/UnionRegion.d.ts.map +1 -1
  97. package/lib/cjs/curve/UnionRegion.js +17 -8
  98. package/lib/cjs/curve/UnionRegion.js.map +1 -1
  99. package/lib/cjs/curve/{ChainCollectorContext.d.ts → internalContexts/ChainCollectorContext.d.ts} +4 -4
  100. package/lib/cjs/curve/internalContexts/ChainCollectorContext.d.ts.map +1 -0
  101. package/lib/cjs/curve/{ChainCollectorContext.js → internalContexts/ChainCollectorContext.js} +4 -4
  102. package/lib/cjs/curve/internalContexts/ChainCollectorContext.js.map +1 -0
  103. package/lib/cjs/curve/internalContexts/GapSearchContext.d.ts +2 -1
  104. package/lib/cjs/curve/internalContexts/GapSearchContext.d.ts.map +1 -1
  105. package/lib/cjs/curve/internalContexts/GapSearchContext.js +6 -2
  106. package/lib/cjs/curve/internalContexts/GapSearchContext.js.map +1 -1
  107. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +59 -70
  108. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
  109. package/lib/cjs/curve/internalContexts/MultiChainCollector.js +130 -220
  110. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  111. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.d.ts +14 -8
  112. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.d.ts.map +1 -1
  113. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js +14 -8
  114. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
  115. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts +23 -95
  116. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
  117. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js +89 -178
  118. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  119. package/lib/cjs/curve/internalContexts/SumLengthsContext.d.ts.map +1 -1
  120. package/lib/cjs/curve/internalContexts/SumLengthsContext.js +4 -1
  121. package/lib/cjs/curve/internalContexts/SumLengthsContext.js.map +1 -1
  122. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +1 -1
  123. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  124. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +1 -1
  125. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  126. package/lib/cjs/curve/spiral/TransitionSpiral3d.js +2 -2
  127. package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
  128. package/lib/cjs/curve/spiral/XYCurveEvaluator.js +1 -1
  129. package/lib/cjs/curve/spiral/XYCurveEvaluator.js.map +1 -1
  130. package/lib/cjs/geometry3d/Angle.d.ts +9 -0
  131. package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
  132. package/lib/cjs/geometry3d/Angle.js +13 -0
  133. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  134. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  135. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  136. package/lib/cjs/geometry3d/BilinearPatch.d.ts +43 -48
  137. package/lib/cjs/geometry3d/BilinearPatch.d.ts.map +1 -1
  138. package/lib/cjs/geometry3d/BilinearPatch.js +51 -55
  139. package/lib/cjs/geometry3d/BilinearPatch.js.map +1 -1
  140. package/lib/cjs/geometry3d/Ellipsoid.d.ts +1 -1
  141. package/lib/cjs/geometry3d/Ellipsoid.js +1 -1
  142. package/lib/cjs/geometry3d/Ellipsoid.js.map +1 -1
  143. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  144. package/lib/cjs/geometry3d/FrameBuilder.js +13 -11
  145. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  146. package/lib/cjs/geometry3d/GeometryHandler.d.ts +5 -5
  147. package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
  148. package/lib/cjs/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
  149. package/lib/cjs/geometry3d/GrowableBlockedArray.js +1 -1
  150. package/lib/cjs/geometry3d/GrowableBlockedArray.js.map +1 -1
  151. package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
  152. package/lib/cjs/geometry3d/GrowableFloat64Array.js +1 -1
  153. package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
  154. package/lib/cjs/geometry3d/Matrix3d.d.ts +18 -0
  155. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  156. package/lib/cjs/geometry3d/Matrix3d.js +32 -5
  157. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  158. package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
  159. package/lib/cjs/geometry3d/Plane3d.d.ts +41 -32
  160. package/lib/cjs/geometry3d/Plane3d.d.ts.map +1 -1
  161. package/lib/cjs/geometry3d/Plane3d.js +11 -8
  162. package/lib/cjs/geometry3d/Plane3d.js.map +1 -1
  163. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +37 -34
  164. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
  165. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js +65 -43
  166. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
  167. package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.d.ts +36 -32
  168. package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.d.ts.map +1 -1
  169. package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js +37 -32
  170. package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
  171. package/lib/cjs/geometry3d/Point2dVector2d.d.ts +8 -9
  172. package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
  173. package/lib/cjs/geometry3d/Point2dVector2d.js +9 -10
  174. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  175. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  176. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +12 -4
  177. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  178. package/lib/cjs/geometry3d/Point3dVector3d.js +18 -5
  179. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  180. package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
  181. package/lib/cjs/geometry3d/PointHelpers.js +5 -5
  182. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  183. package/lib/cjs/geometry3d/PolygonOps.d.ts +1 -2
  184. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  185. package/lib/cjs/geometry3d/PolygonOps.js +2 -3
  186. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  187. package/lib/cjs/geometry3d/PolylineOps.d.ts +16 -1
  188. package/lib/cjs/geometry3d/PolylineOps.d.ts.map +1 -1
  189. package/lib/cjs/geometry3d/PolylineOps.js +55 -0
  190. package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
  191. package/lib/cjs/geometry3d/Range.d.ts +134 -94
  192. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  193. package/lib/cjs/geometry3d/Range.js +297 -145
  194. package/lib/cjs/geometry3d/Range.js.map +1 -1
  195. package/lib/cjs/geometry3d/Ray2d.d.ts +69 -0
  196. package/lib/cjs/geometry3d/Ray2d.d.ts.map +1 -0
  197. package/lib/cjs/geometry3d/Ray2d.js +146 -0
  198. package/lib/cjs/geometry3d/Ray2d.js.map +1 -0
  199. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  200. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  201. package/lib/cjs/geometry3d/Transform.d.ts +10 -3
  202. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  203. package/lib/cjs/geometry3d/Transform.js +18 -6
  204. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  205. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  206. package/lib/cjs/numerics/ConvexPolygon2d.d.ts +7 -49
  207. package/lib/cjs/numerics/ConvexPolygon2d.d.ts.map +1 -1
  208. package/lib/cjs/numerics/ConvexPolygon2d.js +16 -107
  209. package/lib/cjs/numerics/ConvexPolygon2d.js.map +1 -1
  210. package/lib/cjs/numerics/Newton.js.map +1 -1
  211. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  212. package/lib/cjs/numerics/Polynomials.js +0 -2
  213. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  214. package/lib/cjs/numerics/Quadrature.js +5 -5
  215. package/lib/cjs/numerics/Quadrature.js.map +1 -1
  216. package/lib/cjs/polyface/IndexedEdgeMatcher.js +1 -1
  217. package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
  218. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  219. package/lib/cjs/polyface/PolyfaceBuilder.js +2 -2
  220. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  221. package/lib/cjs/polyface/PolyfaceQuery.d.ts +73 -12
  222. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  223. package/lib/cjs/polyface/PolyfaceQuery.js +117 -31
  224. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  225. package/lib/cjs/polyface/TaggedNumericData.js +1 -1
  226. package/lib/cjs/polyface/TaggedNumericData.js.map +1 -1
  227. package/lib/cjs/polyface/multiclip/BuildAverageNormalsContext.js +2 -2
  228. package/lib/cjs/polyface/multiclip/BuildAverageNormalsContext.js.map +1 -1
  229. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  230. package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.d.ts +11 -0
  231. package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.d.ts.map +1 -1
  232. package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js +79 -1
  233. package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
  234. package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
  235. package/lib/cjs/serialization/GeometrySamples.d.ts +11 -0
  236. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  237. package/lib/cjs/serialization/GeometrySamples.js +30 -0
  238. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  239. package/lib/cjs/serialization/IModelJsonSchema.d.ts +2 -7
  240. package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
  241. package/lib/cjs/serialization/IModelJsonSchema.js +2 -7
  242. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  243. package/lib/cjs/solid/LinearSweep.d.ts +2 -1
  244. package/lib/cjs/solid/LinearSweep.d.ts.map +1 -1
  245. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  246. package/lib/cjs/solid/RotationalSweep.d.ts +2 -1
  247. package/lib/cjs/solid/RotationalSweep.d.ts.map +1 -1
  248. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  249. package/lib/cjs/solid/RuledSweep.d.ts +2 -1
  250. package/lib/cjs/solid/RuledSweep.d.ts.map +1 -1
  251. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  252. package/lib/cjs/solid/SweepContour.d.ts +2 -2
  253. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  254. package/lib/cjs/solid/SweepContour.js +9 -0
  255. package/lib/cjs/solid/SweepContour.js.map +1 -1
  256. package/lib/cjs/topology/ChainMerge.js +1 -1
  257. package/lib/cjs/topology/ChainMerge.js.map +1 -1
  258. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  259. package/lib/cjs/topology/HalfEdgeGraphSearch.js +1 -1
  260. package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
  261. package/lib/cjs/topology/HalfEdgeGraphSpineContext.js +1 -1
  262. package/lib/cjs/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  263. package/lib/cjs/topology/HalfEdgePriorityQueue.d.ts.map +1 -1
  264. package/lib/cjs/topology/HalfEdgePriorityQueue.js +1 -1
  265. package/lib/cjs/topology/HalfEdgePriorityQueue.js.map +1 -1
  266. package/lib/cjs/topology/RegularizeFace.js +3 -3
  267. package/lib/cjs/topology/RegularizeFace.js.map +1 -1
  268. package/lib/cjs/topology/Triangulation.js +1 -1
  269. package/lib/cjs/topology/Triangulation.js.map +1 -1
  270. package/lib/esm/Geometry.js.map +1 -1
  271. package/lib/esm/bspline/BSplineCurve.d.ts +1 -1
  272. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  273. package/lib/esm/bspline/BSplineCurve.js +1 -1
  274. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  275. package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
  276. package/lib/esm/bspline/BSplineSurface.js +1 -1
  277. package/lib/esm/bspline/BSplineSurface.js.map +1 -1
  278. package/lib/esm/bspline/BezierCurveBase.d.ts +1 -1
  279. package/lib/esm/bspline/BezierCurveBase.d.ts.map +1 -1
  280. package/lib/esm/bspline/BezierCurveBase.js +1 -1
  281. package/lib/esm/bspline/BezierCurveBase.js.map +1 -1
  282. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  283. package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
  284. package/lib/esm/clipping/ClipPrimitive.js +2 -0
  285. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  286. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  287. package/lib/esm/core-geometry.d.ts +3 -1
  288. package/lib/esm/core-geometry.d.ts.map +1 -1
  289. package/lib/esm/core-geometry.js +3 -1
  290. package/lib/esm/core-geometry.js.map +1 -1
  291. package/lib/esm/curve/Arc3d.d.ts +2 -1
  292. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  293. package/lib/esm/curve/Arc3d.js +2 -1
  294. package/lib/esm/curve/Arc3d.js.map +1 -1
  295. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +62 -42
  296. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  297. package/lib/esm/curve/CurveChainWithDistanceIndex.js +70 -47
  298. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  299. package/lib/esm/curve/CurveCollection.d.ts +36 -26
  300. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  301. package/lib/esm/curve/CurveCollection.js +46 -39
  302. package/lib/esm/curve/CurveCollection.js.map +1 -1
  303. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  304. package/lib/esm/curve/CurveCurve.js.map +1 -1
  305. package/lib/esm/curve/CurveFactory.d.ts +67 -3
  306. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  307. package/lib/esm/curve/CurveFactory.js +74 -6
  308. package/lib/esm/curve/CurveFactory.js.map +1 -1
  309. package/lib/esm/curve/CurveLocationDetail.d.ts +6 -6
  310. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  311. package/lib/esm/curve/CurveLocationDetail.js +9 -7
  312. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  313. package/lib/esm/curve/CurveOps.d.ts +77 -0
  314. package/lib/esm/curve/CurveOps.d.ts.map +1 -0
  315. package/lib/esm/curve/CurveOps.js +156 -0
  316. package/lib/esm/curve/CurveOps.js.map +1 -0
  317. package/lib/esm/curve/CurvePrimitive.d.ts +17 -16
  318. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  319. package/lib/esm/curve/CurvePrimitive.js +4 -3
  320. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  321. package/lib/esm/curve/GeometryQuery.d.ts +2 -2
  322. package/lib/esm/curve/GeometryQuery.d.ts.map +1 -1
  323. package/lib/esm/curve/GeometryQuery.js +2 -2
  324. package/lib/esm/curve/GeometryQuery.js.map +1 -1
  325. package/lib/esm/curve/LineSegment3d.d.ts +7 -5
  326. package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
  327. package/lib/esm/curve/LineSegment3d.js +5 -5
  328. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  329. package/lib/esm/curve/LineString3d.d.ts +2 -2
  330. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  331. package/lib/esm/curve/LineString3d.js +2 -2
  332. package/lib/esm/curve/LineString3d.js.map +1 -1
  333. package/lib/esm/curve/Loop.d.ts +7 -5
  334. package/lib/esm/curve/Loop.d.ts.map +1 -1
  335. package/lib/esm/curve/Loop.js +18 -6
  336. package/lib/esm/curve/Loop.js.map +1 -1
  337. package/lib/esm/curve/OffsetOptions.d.ts +97 -0
  338. package/lib/esm/curve/OffsetOptions.d.ts.map +1 -0
  339. package/lib/esm/curve/OffsetOptions.js +161 -0
  340. package/lib/esm/curve/OffsetOptions.js.map +1 -0
  341. package/lib/esm/curve/ParityRegion.d.ts +7 -7
  342. package/lib/esm/curve/ParityRegion.d.ts.map +1 -1
  343. package/lib/esm/curve/ParityRegion.js +19 -11
  344. package/lib/esm/curve/ParityRegion.js.map +1 -1
  345. package/lib/esm/curve/Path.d.ts +6 -6
  346. package/lib/esm/curve/Path.d.ts.map +1 -1
  347. package/lib/esm/curve/Path.js +15 -9
  348. package/lib/esm/curve/Path.js.map +1 -1
  349. package/lib/esm/curve/ProxyCurve.d.ts +5 -7
  350. package/lib/esm/curve/ProxyCurve.d.ts.map +1 -1
  351. package/lib/esm/curve/ProxyCurve.js +7 -7
  352. package/lib/esm/curve/ProxyCurve.js.map +1 -1
  353. package/lib/esm/curve/Query/StrokeCountMap.js.map +1 -1
  354. package/lib/esm/curve/RegionOps.d.ts +76 -56
  355. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  356. package/lib/esm/curve/RegionOps.js +84 -61
  357. package/lib/esm/curve/RegionOps.js.map +1 -1
  358. package/lib/esm/curve/RegionOpsClassificationSweeps.js +2 -2
  359. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  360. package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
  361. package/lib/esm/curve/StrokeOptions.js +6 -2
  362. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  363. package/lib/esm/curve/UnionRegion.d.ts +6 -5
  364. package/lib/esm/curve/UnionRegion.d.ts.map +1 -1
  365. package/lib/esm/curve/UnionRegion.js +17 -8
  366. package/lib/esm/curve/UnionRegion.js.map +1 -1
  367. package/lib/esm/curve/{ChainCollectorContext.d.ts → internalContexts/ChainCollectorContext.d.ts} +4 -4
  368. package/lib/esm/curve/internalContexts/ChainCollectorContext.d.ts.map +1 -0
  369. package/lib/esm/curve/{ChainCollectorContext.js → internalContexts/ChainCollectorContext.js} +4 -4
  370. package/lib/esm/curve/internalContexts/ChainCollectorContext.js.map +1 -0
  371. package/lib/esm/curve/internalContexts/GapSearchContext.d.ts +2 -1
  372. package/lib/esm/curve/internalContexts/GapSearchContext.d.ts.map +1 -1
  373. package/lib/esm/curve/internalContexts/GapSearchContext.js +6 -2
  374. package/lib/esm/curve/internalContexts/GapSearchContext.js.map +1 -1
  375. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +59 -70
  376. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
  377. package/lib/esm/curve/internalContexts/MultiChainCollector.js +129 -218
  378. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  379. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.d.ts +14 -8
  380. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.d.ts.map +1 -1
  381. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js +14 -8
  382. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
  383. package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts +23 -95
  384. package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
  385. package/lib/esm/curve/internalContexts/PolygonOffsetContext.js +86 -173
  386. package/lib/esm/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  387. package/lib/esm/curve/internalContexts/SumLengthsContext.d.ts.map +1 -1
  388. package/lib/esm/curve/internalContexts/SumLengthsContext.js +4 -1
  389. package/lib/esm/curve/internalContexts/SumLengthsContext.js.map +1 -1
  390. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +1 -1
  391. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  392. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +1 -1
  393. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  394. package/lib/esm/curve/spiral/TransitionSpiral3d.js +1 -1
  395. package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
  396. package/lib/esm/curve/spiral/XYCurveEvaluator.js +1 -1
  397. package/lib/esm/curve/spiral/XYCurveEvaluator.js.map +1 -1
  398. package/lib/esm/geometry3d/Angle.d.ts +9 -0
  399. package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
  400. package/lib/esm/geometry3d/Angle.js +13 -0
  401. package/lib/esm/geometry3d/Angle.js.map +1 -1
  402. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  403. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  404. package/lib/esm/geometry3d/BilinearPatch.d.ts +43 -48
  405. package/lib/esm/geometry3d/BilinearPatch.d.ts.map +1 -1
  406. package/lib/esm/geometry3d/BilinearPatch.js +51 -55
  407. package/lib/esm/geometry3d/BilinearPatch.js.map +1 -1
  408. package/lib/esm/geometry3d/Ellipsoid.d.ts +1 -1
  409. package/lib/esm/geometry3d/Ellipsoid.js +1 -1
  410. package/lib/esm/geometry3d/Ellipsoid.js.map +1 -1
  411. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  412. package/lib/esm/geometry3d/FrameBuilder.js +13 -11
  413. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  414. package/lib/esm/geometry3d/GeometryHandler.d.ts +5 -5
  415. package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
  416. package/lib/esm/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
  417. package/lib/esm/geometry3d/GrowableBlockedArray.js +1 -1
  418. package/lib/esm/geometry3d/GrowableBlockedArray.js.map +1 -1
  419. package/lib/esm/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
  420. package/lib/esm/geometry3d/GrowableFloat64Array.js +1 -1
  421. package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
  422. package/lib/esm/geometry3d/Matrix3d.d.ts +18 -0
  423. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  424. package/lib/esm/geometry3d/Matrix3d.js +32 -5
  425. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  426. package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
  427. package/lib/esm/geometry3d/Plane3d.d.ts +41 -32
  428. package/lib/esm/geometry3d/Plane3d.d.ts.map +1 -1
  429. package/lib/esm/geometry3d/Plane3d.js +11 -8
  430. package/lib/esm/geometry3d/Plane3d.js.map +1 -1
  431. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +37 -34
  432. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
  433. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js +65 -43
  434. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
  435. package/lib/esm/geometry3d/Plane3dByOriginAndVectors.d.ts +36 -32
  436. package/lib/esm/geometry3d/Plane3dByOriginAndVectors.d.ts.map +1 -1
  437. package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js +37 -32
  438. package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
  439. package/lib/esm/geometry3d/Point2dVector2d.d.ts +8 -9
  440. package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
  441. package/lib/esm/geometry3d/Point2dVector2d.js +9 -10
  442. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  443. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  444. package/lib/esm/geometry3d/Point3dVector3d.d.ts +12 -4
  445. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  446. package/lib/esm/geometry3d/Point3dVector3d.js +18 -5
  447. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  448. package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
  449. package/lib/esm/geometry3d/PointHelpers.js +5 -5
  450. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  451. package/lib/esm/geometry3d/PolygonOps.d.ts +1 -2
  452. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  453. package/lib/esm/geometry3d/PolygonOps.js +2 -3
  454. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  455. package/lib/esm/geometry3d/PolylineOps.d.ts +16 -1
  456. package/lib/esm/geometry3d/PolylineOps.d.ts.map +1 -1
  457. package/lib/esm/geometry3d/PolylineOps.js +56 -1
  458. package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
  459. package/lib/esm/geometry3d/Range.d.ts +134 -94
  460. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  461. package/lib/esm/geometry3d/Range.js +297 -145
  462. package/lib/esm/geometry3d/Range.js.map +1 -1
  463. package/lib/esm/geometry3d/Ray2d.d.ts +69 -0
  464. package/lib/esm/geometry3d/Ray2d.d.ts.map +1 -0
  465. package/lib/esm/geometry3d/Ray2d.js +142 -0
  466. package/lib/esm/geometry3d/Ray2d.js.map +1 -0
  467. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  468. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  469. package/lib/esm/geometry3d/Transform.d.ts +10 -3
  470. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  471. package/lib/esm/geometry3d/Transform.js +18 -6
  472. package/lib/esm/geometry3d/Transform.js.map +1 -1
  473. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  474. package/lib/esm/numerics/ConvexPolygon2d.d.ts +7 -49
  475. package/lib/esm/numerics/ConvexPolygon2d.d.ts.map +1 -1
  476. package/lib/esm/numerics/ConvexPolygon2d.js +14 -104
  477. package/lib/esm/numerics/ConvexPolygon2d.js.map +1 -1
  478. package/lib/esm/numerics/Newton.js.map +1 -1
  479. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  480. package/lib/esm/numerics/Polynomials.js +0 -2
  481. package/lib/esm/numerics/Polynomials.js.map +1 -1
  482. package/lib/esm/numerics/Quadrature.js +5 -5
  483. package/lib/esm/numerics/Quadrature.js.map +1 -1
  484. package/lib/esm/polyface/IndexedEdgeMatcher.js +1 -1
  485. package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
  486. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  487. package/lib/esm/polyface/PolyfaceBuilder.js +2 -2
  488. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  489. package/lib/esm/polyface/PolyfaceQuery.d.ts +73 -12
  490. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  491. package/lib/esm/polyface/PolyfaceQuery.js +117 -32
  492. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  493. package/lib/esm/polyface/TaggedNumericData.js +1 -1
  494. package/lib/esm/polyface/TaggedNumericData.js.map +1 -1
  495. package/lib/esm/polyface/multiclip/BuildAverageNormalsContext.js +2 -2
  496. package/lib/esm/polyface/multiclip/BuildAverageNormalsContext.js.map +1 -1
  497. package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  498. package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.d.ts +11 -0
  499. package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.d.ts.map +1 -1
  500. package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js +78 -1
  501. package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
  502. package/lib/esm/serialization/BGFBWriter.js.map +1 -1
  503. package/lib/esm/serialization/GeometrySamples.d.ts +11 -0
  504. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  505. package/lib/esm/serialization/GeometrySamples.js +30 -0
  506. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  507. package/lib/esm/serialization/IModelJsonSchema.d.ts +2 -7
  508. package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
  509. package/lib/esm/serialization/IModelJsonSchema.js +2 -7
  510. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  511. package/lib/esm/solid/LinearSweep.d.ts +2 -1
  512. package/lib/esm/solid/LinearSweep.d.ts.map +1 -1
  513. package/lib/esm/solid/LinearSweep.js.map +1 -1
  514. package/lib/esm/solid/RotationalSweep.d.ts +2 -1
  515. package/lib/esm/solid/RotationalSweep.d.ts.map +1 -1
  516. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  517. package/lib/esm/solid/RuledSweep.d.ts +2 -1
  518. package/lib/esm/solid/RuledSweep.d.ts.map +1 -1
  519. package/lib/esm/solid/RuledSweep.js.map +1 -1
  520. package/lib/esm/solid/SweepContour.d.ts +2 -2
  521. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  522. package/lib/esm/solid/SweepContour.js +9 -0
  523. package/lib/esm/solid/SweepContour.js.map +1 -1
  524. package/lib/esm/topology/ChainMerge.js +1 -1
  525. package/lib/esm/topology/ChainMerge.js.map +1 -1
  526. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  527. package/lib/esm/topology/HalfEdgeGraphSearch.js +1 -1
  528. package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
  529. package/lib/esm/topology/HalfEdgeGraphSpineContext.js +1 -1
  530. package/lib/esm/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  531. package/lib/esm/topology/HalfEdgePriorityQueue.d.ts.map +1 -1
  532. package/lib/esm/topology/HalfEdgePriorityQueue.js +1 -1
  533. package/lib/esm/topology/HalfEdgePriorityQueue.js.map +1 -1
  534. package/lib/esm/topology/RegularizeFace.js +3 -3
  535. package/lib/esm/topology/RegularizeFace.js.map +1 -1
  536. package/lib/esm/topology/Triangulation.js +1 -1
  537. package/lib/esm/topology/Triangulation.js.map +1 -1
  538. package/package.json +6 -17
  539. package/lib/cjs/curve/ChainCollectorContext.d.ts.map +0 -1
  540. package/lib/cjs/curve/ChainCollectorContext.js.map +0 -1
  541. package/lib/esm/curve/ChainCollectorContext.d.ts.map +0 -1
  542. package/lib/esm/curve/ChainCollectorContext.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,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,sBAAsB;IAiBjC;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,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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AAC;QAC9B,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,QAAQ,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","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,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,sBAAsB;IAiBjC;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,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;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AE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAG,QAAQ,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","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"]}
@@ -9,32 +9,32 @@ import { Range3d } from "./Range";
9
9
  import { Ray3d } from "./Ray3d";
10
10
  import { Transform } from "./Transform";
11
11
  /**
12
- * * A Bilinear patch is defined by its 4 corner points.
13
- * * the corner points do not have to be coplanar
14
- *
15
- * * v direction (up)
16
- * |
17
- * |
18
- * |
19
- * point01---A1-----------point11
20
- * | | |
21
- * B0----X------------B1
22
- * | | |
23
- * point00--A0-----------point10 -----------> u direction
24
- *
25
- * * To evaluate aa point at (u,v), the following are equivalent:
26
- * * interpolate with u to get both A0 and A1, viz
12
+ * A bilinear patch is a surface defined by its 4 corner points.
13
+ * * The corner points do not have to be coplanar, but if they are, the quadrilateral should be convex to avoid a self-intersecting surface.
14
+ * ```
15
+ * equation
16
+ * \begin{matrix}
17
+ * v\text{-direction}\\
18
+ * \uparrow\\
19
+ * \text{point01} &\cdots &\text{A1} &\cdots &\text{point11}\\
20
+ * \vdots &&\vdots &&\vdots\\
21
+ * \text{B0} &\cdots &\text{X} &\cdots &\text{B1}\\
22
+ * \vdots &&\vdots &&\vdots\\
23
+ * \text{point00} &\cdots &\text{A0} &\cdots &\text{point10} &\rightarrow~u\text{-direction}
24
+ * \end{matrix}
25
+ * ```
26
+ * * To evaluate the point at (u,v), the following are equivalent:
27
+ * * interpolate first with u then with v:
27
28
  * * A0 = interpolate between point00 and point10 at fraction u
28
29
  * * A1 = interpolate between point01 and point11 at fraction u
29
30
  * * X = interpolate between A0 and A1 at fraction v
30
- * * interpolate first with v to get B0 and B1, viz
31
+ * * interpolate first with v then with u:
31
32
  * * B0 = interpolate between point00 and point01 at fraction v
32
33
  * * B1 = interpolate between point10 and point11 at fraction v
33
34
  * * X = interpolate between B0 and B1 at fraction u
34
- * * sum all at once as
35
- * * X = (1-u)* (1-v) *point00 + (1-u)*v * point01 + u * (1-v) *point10 + u* v * point11
36
- *
37
- * @internal
35
+ * * sum all at once:
36
+ * * X = (1-u)(1-v)point00 + (1-u)(v)point01 + (u)(1-v)point10 + (u)(v)point11
37
+ * @public
38
38
  */
39
39
  export declare class BilinearPatch implements UVSurface {
40
40
  /** corner at parametric coordinate (0,0) */
@@ -46,62 +46,57 @@ export declare class BilinearPatch implements UVSurface {
46
46
  /** corner at parametric coordinate (1,1) */
47
47
  point11: Point3d;
48
48
  /**
49
- * Capture (not clone) corner points, in u direction at v=0, then in same direction at v=1
49
+ * Capture (not clone) corners to create a new BilinearPatch.
50
50
  * @param point00 Point at uv=0,0
51
51
  * @param point10 Point at uv=1,0
52
52
  * @param point10 Point at uv=0,1
53
- * @param point11 Point at uv=11
53
+ * @param point11 Point at uv=1,1
54
54
  */
55
55
  constructor(point00: Point3d, point10: Point3d, point01: Point3d, point11: Point3d);
56
- /** clone (not capture) corners to create a new BilinearPatch
56
+ /**
57
+ * Clone (not capture) corners to create a new BilinearPatch.
57
58
  * @param point00 Point at uv=0,0
58
59
  * @param point10 Point at uv=1,0
59
60
  * @param point10 Point at uv=0,1
60
- * @param point11 Point at uv=11
61
+ * @param point11 Point at uv=1,1
61
62
  */
62
63
  static create(point00: Point3d, point10: Point3d, point01: Point3d, point11: Point3d): BilinearPatch;
63
- /** create a patch with from xyz values of the 4 corners
64
- */
64
+ /** Create a patch from xyz values of the 4 corners. */
65
65
  static createXYZ(x00: number, y00: number, z00: number, x10: number, y10: number, z10: number, x01: number, y01: number, z01: number, x11: number, y11: number, z11: number): BilinearPatch;
66
- /** return a clone with same coordinates */
66
+ /** Return a cloned patch. */
67
67
  clone(): BilinearPatch;
68
- /** test equality of the 4 points */
68
+ /** Test equality of the 4 points. */
69
69
  isAlmostEqual(other: BilinearPatch): boolean;
70
- /** Apply the transform to each point */
70
+ /** Apply the transform to each point. */
71
71
  tryTransformInPlace(transform: Transform): boolean;
72
- /**
73
- * return a cloned and transformed patch.
74
- * @param transform
75
- */
72
+ /** Return a cloned and transformed patch. */
76
73
  cloneTransformed(transform: Transform): BilinearPatch | undefined;
77
- /** Extend a range by the range of the(optionally transformed) patch
78
- */
74
+ /** Extend a range by the range of the (optionally transformed) patch. */
79
75
  extendRange(range: Range3d, transform?: Transform): void;
80
- /** Evaluate as a uv surface
81
- * @param u fractional position in minor (phi)
82
- * @param v fractional position on major (theta) arc
76
+ /**
77
+ * Convert fractional u and v coordinates to surface point
78
+ * @param u fractional coordinate in u direction
79
+ * @param v fractional coordinate in v direction
80
+ * @param result optional pre-allocated point
83
81
  */
84
82
  uvFractionToPoint(u: number, v: number, result?: Point3d): Point3d;
85
83
  /** Evaluate as a uv surface, returning point and two derivative vectors.
86
- * @param u fractional position
87
- * @param v fractional position
84
+ * @param u fractional coordinate in u direction
85
+ * @param v fractional coordinate in v direction
86
+ * @param result optional pre-allocated carrier for point and vectors
88
87
  */
89
88
  uvFractionToPointAndTangents(u: number, v: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors;
90
- /** if data[ib][pivotColumn] is larger (abs) than data[ia][pivotColumn] swap the iA and iB arrays */
89
+ /** If data[iB][pivotColumn] is larger in absolute value than data[iA][pivotColumn], then swap rows iA and iB. */
91
90
  private static conditionalPivot;
92
91
  /**
93
- * Compute the (points of) intersection with a ray.
92
+ * Compute the points of intersection with a ray.
94
93
  * @param ray ray in space
95
94
  * @returns 1 or 2 points if there are intersections, undefined if no intersections
96
95
  */
97
96
  intersectRay(ray: Ray3d): CurveAndSurfaceLocationDetail[] | undefined;
98
- /**
99
- * Returns the larger of the u-direction edge lengths at v=0 and v=1
100
- */
97
+ /** Returns the larger of the u-direction edge lengths at v=0 and v=1. */
101
98
  maxUEdgeLength(): number;
102
- /**
103
- * Returns the larger of the v-direction edge lengths at u=0 and u=1
104
- */
99
+ /** Returns the larger of the v-direction edge lengths at u=0 and u=1. */
105
100
  maxVEdgeLength(): number;
106
101
  }
107
102
  //# sourceMappingURL=BilinearPatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BilinearPatch.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/BilinearPatch.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,6BAA6B,EAA2B,MAAM,kCAAkC,CAAC;AAI1G,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC7C,4CAA4C;IACrC,OAAO,EAAE,OAAO,CAAC;IACxB,4CAA4C;IACrC,OAAO,EAAE,OAAO,CAAC;IACxB,4CAA4C;IACrC,OAAO,EAAE,OAAO,CAAC;IACxB,4CAA4C;IACrC,OAAO,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;gBACgB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;IAMzF;;;;;OAKG;WACW,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,E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AQ7B,qCAAqC;IAC9B,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAMnD,yCAAyC;IAClC,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAOzD,6CAA6C;IACtC,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS;IAKxE,yEAAyE;IAClE,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,SAAS;IAaxD;;;;;OAKG;IACI,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAYzE;;;;OAIG;IACI,4BAA4B,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,yBAAyB,GAAG,yBAAyB;IAsBxH,iHAAiH;IACjH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAO/B;;;;OAIG;IACI,YAAY,CAAC,GAAG,EAAE,KAAK,GAAG,6BAA6B,EAAE,GAAG,SAAS;IAsC5E,yEAAyE;IAClE,cAAc,IAAI,MAAM;IAG/B,yEAAyE;IAClE,cAAc,IAAI,MAAM;CAGhC"}
@@ -11,41 +11,42 @@ import { Geometry } from "../Geometry";
11
11
  import { SmallSystem } from "../numerics/Polynomials";
12
12
  import { Plane3dByOriginAndVectors } from "./Plane3dByOriginAndVectors";
13
13
  import { Point3d } from "./Point3dVector3d";
14
+ // cspell:word uparrow, rightarrow
14
15
  /**
15
- * * A Bilinear patch is defined by its 4 corner points.
16
- * * the corner points do not have to be coplanar
17
- *
18
- * * v direction (up)
19
- * |
20
- * |
21
- * |
22
- * point01---A1-----------point11
23
- * | | |
24
- * B0----X------------B1
25
- * | | |
26
- * point00--A0-----------point10 -----------> u direction
27
- *
28
- * * To evaluate aa point at (u,v), the following are equivalent:
29
- * * interpolate with u to get both A0 and A1, viz
16
+ * A bilinear patch is a surface defined by its 4 corner points.
17
+ * * The corner points do not have to be coplanar, but if they are, the quadrilateral should be convex to avoid a self-intersecting surface.
18
+ * ```
19
+ * equation
20
+ * \begin{matrix}
21
+ * v\text{-direction}\\
22
+ * \uparrow\\
23
+ * \text{point01} &\cdots &\text{A1} &\cdots &\text{point11}\\
24
+ * \vdots &&\vdots &&\vdots\\
25
+ * \text{B0} &\cdots &\text{X} &\cdots &\text{B1}\\
26
+ * \vdots &&\vdots &&\vdots\\
27
+ * \text{point00} &\cdots &\text{A0} &\cdots &\text{point10} &\rightarrow~u\text{-direction}
28
+ * \end{matrix}
29
+ * ```
30
+ * * To evaluate the point at (u,v), the following are equivalent:
31
+ * * interpolate first with u then with v:
30
32
  * * A0 = interpolate between point00 and point10 at fraction u
31
33
  * * A1 = interpolate between point01 and point11 at fraction u
32
34
  * * X = interpolate between A0 and A1 at fraction v
33
- * * interpolate first with v to get B0 and B1, viz
35
+ * * interpolate first with v then with u:
34
36
  * * B0 = interpolate between point00 and point01 at fraction v
35
37
  * * B1 = interpolate between point10 and point11 at fraction v
36
38
  * * X = interpolate between B0 and B1 at fraction u
37
- * * sum all at once as
38
- * * X = (1-u)* (1-v) *point00 + (1-u)*v * point01 + u * (1-v) *point10 + u* v * point11
39
- *
40
- * @internal
39
+ * * sum all at once:
40
+ * * X = (1-u)(1-v)point00 + (1-u)(v)point01 + (u)(1-v)point10 + (u)(v)point11
41
+ * @public
41
42
  */
42
43
  export class BilinearPatch {
43
44
  /**
44
- * Capture (not clone) corner points, in u direction at v=0, then in same direction at v=1
45
+ * Capture (not clone) corners to create a new BilinearPatch.
45
46
  * @param point00 Point at uv=0,0
46
47
  * @param point10 Point at uv=1,0
47
48
  * @param point10 Point at uv=0,1
48
- * @param point11 Point at uv=11
49
+ * @param point11 Point at uv=1,1
49
50
  */
50
51
  constructor(point00, point10, point01, point11) {
51
52
  this.point00 = point00;
@@ -53,32 +54,32 @@ export class BilinearPatch {
53
54
  this.point01 = point01;
54
55
  this.point11 = point11;
55
56
  }
56
- /** clone (not capture) corners to create a new BilinearPatch
57
+ /**
58
+ * Clone (not capture) corners to create a new BilinearPatch.
57
59
  * @param point00 Point at uv=0,0
58
60
  * @param point10 Point at uv=1,0
59
61
  * @param point10 Point at uv=0,1
60
- * @param point11 Point at uv=11
62
+ * @param point11 Point at uv=1,1
61
63
  */
62
64
  static create(point00, point10, point01, point11) {
63
65
  return new BilinearPatch(point00.clone(), point10.clone(), point01.clone(), point11.clone());
64
66
  }
65
- /** create a patch with from xyz values of the 4 corners
66
- */
67
+ /** Create a patch from xyz values of the 4 corners. */
67
68
  static createXYZ(x00, y00, z00, x10, y10, z10, x01, y01, z01, x11, y11, z11) {
68
69
  return new BilinearPatch(Point3d.create(x00, y00, z00), Point3d.create(x10, y10, z10), Point3d.create(x01, y01, z01), Point3d.create(x11, y11, z11));
69
70
  }
70
- /** return a clone with same coordinates */
71
+ /** Return a cloned patch. */
71
72
  clone() {
72
73
  return new BilinearPatch(this.point00.clone(), this.point10.clone(), this.point01.clone(), this.point11.clone());
73
74
  }
74
- /** test equality of the 4 points */
75
+ /** Test equality of the 4 points. */
75
76
  isAlmostEqual(other) {
76
77
  return this.point00.isAlmostEqual(other.point00)
77
78
  && this.point10.isAlmostEqual(other.point10)
78
79
  && this.point01.isAlmostEqual(other.point01)
79
80
  && this.point11.isAlmostEqual(other.point11);
80
81
  }
81
- /** Apply the transform to each point */
82
+ /** Apply the transform to each point. */
82
83
  tryTransformInPlace(transform) {
83
84
  transform.multiplyPoint3d(this.point00, this.point00);
84
85
  transform.multiplyPoint3d(this.point10, this.point10);
@@ -86,17 +87,13 @@ export class BilinearPatch {
86
87
  transform.multiplyPoint3d(this.point11, this.point11);
87
88
  return true;
88
89
  }
89
- /**
90
- * return a cloned and transformed patch.
91
- * @param transform
92
- */
90
+ /** Return a cloned and transformed patch. */
93
91
  cloneTransformed(transform) {
94
92
  const result = this.clone();
95
93
  result.tryTransformInPlace(transform);
96
94
  return result;
97
95
  }
98
- /** Extend a range by the range of the(optionally transformed) patch
99
- */
96
+ /** Extend a range by the range of the (optionally transformed) patch. */
100
97
  extendRange(range, transform) {
101
98
  if (transform) {
102
99
  range.extendTransformedPoint(transform, this.point00);
@@ -111,9 +108,11 @@ export class BilinearPatch {
111
108
  range.extendPoint(this.point11);
112
109
  }
113
110
  }
114
- /** Evaluate as a uv surface
115
- * @param u fractional position in minor (phi)
116
- * @param v fractional position on major (theta) arc
111
+ /**
112
+ * Convert fractional u and v coordinates to surface point
113
+ * @param u fractional coordinate in u direction
114
+ * @param v fractional coordinate in v direction
115
+ * @param result optional pre-allocated point
117
116
  */
118
117
  uvFractionToPoint(u, v, result) {
119
118
  const f00 = (1.0 - u) * (1.0 - v);
@@ -123,8 +122,9 @@ export class BilinearPatch {
123
122
  return Point3d.create(f00 * this.point00.x + f10 * this.point10.x + f01 * this.point01.x + f11 * this.point11.x, f00 * this.point00.y + f10 * this.point10.y + f01 * this.point01.y + f11 * this.point11.y, f00 * this.point00.z + f10 * this.point10.z + f01 * this.point01.z + f11 * this.point11.z, result);
124
123
  }
125
124
  /** Evaluate as a uv surface, returning point and two derivative vectors.
126
- * @param u fractional position
127
- * @param v fractional position
125
+ * @param u fractional coordinate in u direction
126
+ * @param v fractional coordinate in v direction
127
+ * @param result optional pre-allocated carrier for point and vectors
128
128
  */
129
129
  uvFractionToPointAndTangents(u, v, result) {
130
130
  const u0 = 1.0 - u;
@@ -139,7 +139,7 @@ export class BilinearPatch {
139
139
  // v derivative ..
140
140
  u0 * (this.point01.x - this.point00.x) + u * (this.point11.x - this.point10.x), u0 * (this.point01.y - this.point00.y) + u * (this.point11.y - this.point10.y), u0 * (this.point01.z - this.point00.z) + u * (this.point11.z - this.point10.z), result);
141
141
  }
142
- /** if data[ib][pivotColumn] is larger (abs) than data[ia][pivotColumn] swap the iA and iB arrays */
142
+ /** If data[iB][pivotColumn] is larger in absolute value than data[iA][pivotColumn], then swap rows iA and iB. */
143
143
  static conditionalPivot(pivotColumn, data, iA, iB) {
144
144
  if (Math.abs(data[iB][pivotColumn]) > Math.abs(data[iA][pivotColumn])) {
145
145
  const q = data[iA];
@@ -148,7 +148,7 @@ export class BilinearPatch {
148
148
  }
149
149
  }
150
150
  /**
151
- * Compute the (points of) intersection with a ray.
151
+ * Compute the points of intersection with a ray.
152
152
  * @param ray ray in space
153
153
  * @returns 1 or 2 points if there are intersections, undefined if no intersections
154
154
  */
@@ -157,17 +157,17 @@ export class BilinearPatch {
157
157
  const vectorV = this.point01.minus(this.point00);
158
158
  const vectorW = this.point11.minus(this.point10);
159
159
  vectorW.subtractInPlace(vectorV);
160
- // coefficients of (each component of)
161
- // `ray.origin + t * ray.direction = point00 + u * vectorU + v * vectorV + u*v*vectorW`
162
- // for x as typical direction as x, the scalar equation with coefficient order for arrays is
163
- // `0 = -ray.origin.x * t + (point00.x - ray.origin.x) + u * vectorU.x + v * vectorV.x + u * v * vectorW.x`
164
- // (and that particular equation is invoked to isolate t when uv is known)
160
+ // We seek t, u, v such that:
161
+ // `ray.origin + t*ray.direction = point00 + u*vectorU + v*vectorV + u*v*vectorW`
162
+ // For typical direction as x, the scalar equation with coefficient order for arrays is:
163
+ // `0 = -t*ray.direction.x + (point00.x - ray.origin.x) + u*vectorU.x + v*vectorV.x + u*v*vectorW.x`
164
+ // and this particular equation is invoked to compute t when u and v are known.
165
165
  const coffs = [
166
166
  new Float64Array([-ray.direction.x, this.point00.x - ray.origin.x, vectorU.x, vectorV.x, vectorW.x]),
167
167
  new Float64Array([-ray.direction.y, this.point00.y - ray.origin.y, vectorU.y, vectorV.y, vectorW.y]),
168
- new Float64Array([-ray.direction.z, this.point00.z - ray.origin.z, vectorU.z, vectorV.z, vectorW.z])
168
+ new Float64Array([-ray.direction.z, this.point00.z - ray.origin.z, vectorU.z, vectorV.z, vectorW.z]),
169
169
  ];
170
- // bring the largest ray.direction coefficient to the 0 equation.
170
+ // swap rows so that the equation with largest ray.direction coefficient is first.
171
171
  BilinearPatch.conditionalPivot(0, coffs, 0, 1);
172
172
  BilinearPatch.conditionalPivot(0, coffs, 0, 2);
173
173
  SmallSystem.eliminateFromPivot(coffs[0], 0, coffs[1], -1.0);
@@ -184,15 +184,11 @@ export class BilinearPatch {
184
184
  }
185
185
  return undefined;
186
186
  }
187
- /**
188
- * Returns the larger of the u-direction edge lengths at v=0 and v=1
189
- */
187
+ /** Returns the larger of the u-direction edge lengths at v=0 and v=1. */
190
188
  maxUEdgeLength() {
191
189
  return Geometry.maxXY(this.point00.distance(this.point10), this.point01.distance(this.point11));
192
190
  }
193
- /**
194
- * Returns the larger of the v-direction edge lengths at u=0 and u=1
195
- */
191
+ /** Returns the larger of the v-direction edge lengths at u=0 and u=1. */
196
192
  maxVEdgeLength() {
197
193
  return Geometry.maxXY(this.point00.distance(this.point01), this.point10.distance(this.point11));
198
194
  }