@itwin/core-geometry 3.5.0-dev.7 → 3.5.0

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 (334) hide show
  1. package/CHANGELOG.md +78 -1
  2. package/lib/cjs/Geometry.d.ts +21 -5
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +17 -8
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/bspline/BSplineCurve.d.ts +11 -5
  7. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  8. package/lib/cjs/bspline/BSplineCurve.js +47 -18
  9. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  10. package/lib/cjs/bspline/BezierCurveBase.d.ts +10 -3
  11. package/lib/cjs/bspline/BezierCurveBase.d.ts.map +1 -1
  12. package/lib/cjs/bspline/BezierCurveBase.js +12 -4
  13. package/lib/cjs/bspline/BezierCurveBase.js.map +1 -1
  14. package/lib/cjs/bspline/InterpolationCurve3d.d.ts.map +1 -1
  15. package/lib/cjs/bspline/InterpolationCurve3d.js +4 -1
  16. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  17. package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
  18. package/lib/cjs/bspline/KnotVector.js +3 -0
  19. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  20. package/lib/cjs/curve/Arc3d.d.ts +8 -2
  21. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  22. package/lib/cjs/curve/Arc3d.js +15 -3
  23. package/lib/cjs/curve/Arc3d.js.map +1 -1
  24. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +15 -7
  25. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  26. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +46 -29
  27. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  28. package/lib/cjs/curve/CurveCollection.d.ts +13 -4
  29. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  30. package/lib/cjs/curve/CurveCollection.js +23 -2
  31. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  32. package/lib/cjs/curve/CurveCurveIntersectXY.js +1 -1
  33. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +1 -1
  34. package/lib/cjs/curve/CurveCurveIntersectXYZ.d.ts +4 -3
  35. package/lib/cjs/curve/CurveCurveIntersectXYZ.d.ts.map +1 -1
  36. package/lib/cjs/curve/CurveCurveIntersectXYZ.js +8 -6
  37. package/lib/cjs/curve/CurveCurveIntersectXYZ.js.map +1 -1
  38. package/lib/cjs/curve/CurvePrimitive.d.ts +20 -18
  39. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  40. package/lib/cjs/curve/CurvePrimitive.js +58 -339
  41. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  42. package/lib/cjs/curve/LineSegment3d.d.ts +8 -2
  43. package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
  44. package/lib/cjs/curve/LineSegment3d.js +9 -0
  45. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  46. package/lib/cjs/curve/LineString3d.d.ts +18 -2
  47. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  48. package/lib/cjs/curve/LineString3d.js +39 -23
  49. package/lib/cjs/curve/LineString3d.js.map +1 -1
  50. package/lib/cjs/curve/ProxyCurve.d.ts +9 -7
  51. package/lib/cjs/curve/ProxyCurve.d.ts.map +1 -1
  52. package/lib/cjs/curve/ProxyCurve.js +4 -0
  53. package/lib/cjs/curve/ProxyCurve.js.map +1 -1
  54. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +2 -1
  55. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  56. package/lib/cjs/curve/Query/PlanarSubdivision.js +5 -4
  57. package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
  58. package/lib/cjs/curve/RegionOps.d.ts +5 -0
  59. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  60. package/lib/cjs/curve/RegionOps.js +17 -3
  61. package/lib/cjs/curve/RegionOps.js.map +1 -1
  62. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +9 -6
  63. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  64. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +55 -47
  65. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  66. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +55 -0
  67. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -0
  68. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +143 -0
  69. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -0
  70. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +43 -0
  71. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -0
  72. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +146 -0
  73. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -0
  74. package/lib/cjs/curve/internalContexts/CurveLengthContext.d.ts +33 -0
  75. package/lib/cjs/curve/internalContexts/CurveLengthContext.d.ts.map +1 -0
  76. package/lib/cjs/curve/internalContexts/CurveLengthContext.js +91 -0
  77. package/lib/cjs/curve/internalContexts/CurveLengthContext.js.map +1 -0
  78. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +21 -0
  79. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +1 -0
  80. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js +34 -0
  81. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -0
  82. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.d.ts +31 -8
  83. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.d.ts.map +1 -1
  84. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js +77 -12
  85. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
  86. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +2 -2
  87. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  88. package/lib/cjs/curve/spiral/DirectSpiral3d.js +15 -8
  89. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  90. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +12 -7
  91. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  92. package/lib/cjs/curve/spiral/TransitionSpiral3d.js +12 -3
  93. package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
  94. package/lib/cjs/geometry3d/Angle.d.ts +20 -10
  95. package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
  96. package/lib/cjs/geometry3d/Angle.js +30 -15
  97. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  98. package/lib/cjs/geometry3d/Matrix3d.d.ts +25 -8
  99. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  100. package/lib/cjs/geometry3d/Matrix3d.js +67 -15
  101. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  102. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +1 -0
  103. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  104. package/lib/cjs/geometry3d/Point2dArrayCarrier.js +2 -1
  105. package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
  106. package/lib/cjs/geometry3d/Point2dVector2d.d.ts +86 -25
  107. package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
  108. package/lib/cjs/geometry3d/Point2dVector2d.js +230 -81
  109. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  110. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +14 -4
  111. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  112. package/lib/cjs/geometry3d/Point3dArrayCarrier.js +15 -5
  113. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  114. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +121 -67
  115. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  116. package/lib/cjs/geometry3d/Point3dVector3d.js +318 -137
  117. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  118. package/lib/cjs/geometry3d/Range.d.ts +1 -2
  119. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  120. package/lib/cjs/geometry3d/Range.js +1 -2
  121. package/lib/cjs/geometry3d/Range.js.map +1 -1
  122. package/lib/cjs/geometry3d/Ray3d.d.ts +5 -5
  123. package/lib/cjs/geometry3d/Ray3d.js +5 -5
  124. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  125. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  126. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  127. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  128. package/lib/cjs/numerics/Polynomials.js +0 -1
  129. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  130. package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts +4 -4
  131. package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
  132. package/lib/cjs/polyface/IndexedEdgeMatcher.js +3 -3
  133. package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
  134. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  135. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  136. package/lib/cjs/polyface/Polyface.d.ts +7 -2
  137. package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
  138. package/lib/cjs/polyface/Polyface.js +8 -1
  139. package/lib/cjs/polyface/Polyface.js.map +1 -1
  140. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  141. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  142. package/lib/cjs/polyface/PolyfaceQuery.d.ts +36 -8
  143. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  144. package/lib/cjs/polyface/PolyfaceQuery.js +112 -31
  145. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  146. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  147. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  148. package/lib/cjs/serialization/IModelJsonSchema.d.ts +1 -1
  149. package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
  150. package/lib/cjs/serialization/IModelJsonSchema.js +4 -3
  151. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  152. package/lib/cjs/solid/Sphere.d.ts +1 -1
  153. package/lib/cjs/solid/Sphere.js +3 -3
  154. package/lib/cjs/solid/Sphere.js.map +1 -1
  155. package/lib/cjs/solid/TorusPipe.d.ts +17 -13
  156. package/lib/cjs/solid/TorusPipe.d.ts.map +1 -1
  157. package/lib/cjs/solid/TorusPipe.js +67 -38
  158. package/lib/cjs/solid/TorusPipe.js.map +1 -1
  159. package/lib/cjs/topology/Graph.d.ts +1 -1
  160. package/lib/cjs/topology/Graph.js +1 -1
  161. package/lib/cjs/topology/Graph.js.map +1 -1
  162. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  163. package/lib/cjs/topology/Merging.js +9 -1
  164. package/lib/cjs/topology/Merging.js.map +1 -1
  165. package/lib/cjs/topology/Triangulation.d.ts +1 -1
  166. package/lib/cjs/topology/Triangulation.js +1 -1
  167. package/lib/cjs/topology/Triangulation.js.map +1 -1
  168. package/lib/esm/Geometry.d.ts +21 -5
  169. package/lib/esm/Geometry.d.ts.map +1 -1
  170. package/lib/esm/Geometry.js +17 -8
  171. package/lib/esm/Geometry.js.map +1 -1
  172. package/lib/esm/bspline/BSplineCurve.d.ts +11 -5
  173. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  174. package/lib/esm/bspline/BSplineCurve.js +47 -18
  175. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  176. package/lib/esm/bspline/BezierCurveBase.d.ts +10 -3
  177. package/lib/esm/bspline/BezierCurveBase.d.ts.map +1 -1
  178. package/lib/esm/bspline/BezierCurveBase.js +12 -4
  179. package/lib/esm/bspline/BezierCurveBase.js.map +1 -1
  180. package/lib/esm/bspline/InterpolationCurve3d.d.ts.map +1 -1
  181. package/lib/esm/bspline/InterpolationCurve3d.js +4 -1
  182. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  183. package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
  184. package/lib/esm/bspline/KnotVector.js +3 -0
  185. package/lib/esm/bspline/KnotVector.js.map +1 -1
  186. package/lib/esm/curve/Arc3d.d.ts +8 -2
  187. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  188. package/lib/esm/curve/Arc3d.js +15 -3
  189. package/lib/esm/curve/Arc3d.js.map +1 -1
  190. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +15 -7
  191. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  192. package/lib/esm/curve/CurveChainWithDistanceIndex.js +46 -29
  193. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  194. package/lib/esm/curve/CurveCollection.d.ts +13 -4
  195. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  196. package/lib/esm/curve/CurveCollection.js +23 -2
  197. package/lib/esm/curve/CurveCollection.js.map +1 -1
  198. package/lib/esm/curve/CurveCurveIntersectXY.js +1 -1
  199. package/lib/esm/curve/CurveCurveIntersectXY.js.map +1 -1
  200. package/lib/esm/curve/CurveCurveIntersectXYZ.d.ts +4 -3
  201. package/lib/esm/curve/CurveCurveIntersectXYZ.d.ts.map +1 -1
  202. package/lib/esm/curve/CurveCurveIntersectXYZ.js +8 -6
  203. package/lib/esm/curve/CurveCurveIntersectXYZ.js.map +1 -1
  204. package/lib/esm/curve/CurvePrimitive.d.ts +20 -18
  205. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  206. package/lib/esm/curve/CurvePrimitive.js +52 -333
  207. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  208. package/lib/esm/curve/LineSegment3d.d.ts +8 -2
  209. package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
  210. package/lib/esm/curve/LineSegment3d.js +9 -0
  211. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  212. package/lib/esm/curve/LineString3d.d.ts +18 -2
  213. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  214. package/lib/esm/curve/LineString3d.js +39 -23
  215. package/lib/esm/curve/LineString3d.js.map +1 -1
  216. package/lib/esm/curve/ProxyCurve.d.ts +9 -7
  217. package/lib/esm/curve/ProxyCurve.d.ts.map +1 -1
  218. package/lib/esm/curve/ProxyCurve.js +4 -0
  219. package/lib/esm/curve/ProxyCurve.js.map +1 -1
  220. package/lib/esm/curve/Query/PlanarSubdivision.d.ts +2 -1
  221. package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  222. package/lib/esm/curve/Query/PlanarSubdivision.js +5 -4
  223. package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
  224. package/lib/esm/curve/RegionOps.d.ts +5 -0
  225. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  226. package/lib/esm/curve/RegionOps.js +17 -3
  227. package/lib/esm/curve/RegionOps.js.map +1 -1
  228. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +9 -6
  229. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  230. package/lib/esm/curve/RegionOpsClassificationSweeps.js +56 -48
  231. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  232. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +55 -0
  233. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -0
  234. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +139 -0
  235. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -0
  236. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +43 -0
  237. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -0
  238. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +142 -0
  239. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -0
  240. package/lib/esm/curve/internalContexts/CurveLengthContext.d.ts +33 -0
  241. package/lib/esm/curve/internalContexts/CurveLengthContext.d.ts.map +1 -0
  242. package/lib/esm/curve/internalContexts/CurveLengthContext.js +87 -0
  243. package/lib/esm/curve/internalContexts/CurveLengthContext.js.map +1 -0
  244. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +21 -0
  245. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +1 -0
  246. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js +30 -0
  247. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -0
  248. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.d.ts +31 -8
  249. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.d.ts.map +1 -1
  250. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js +77 -12
  251. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
  252. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +2 -2
  253. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  254. package/lib/esm/curve/spiral/DirectSpiral3d.js +15 -8
  255. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  256. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +12 -7
  257. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  258. package/lib/esm/curve/spiral/TransitionSpiral3d.js +12 -3
  259. package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
  260. package/lib/esm/geometry3d/Angle.d.ts +20 -10
  261. package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
  262. package/lib/esm/geometry3d/Angle.js +30 -15
  263. package/lib/esm/geometry3d/Angle.js.map +1 -1
  264. package/lib/esm/geometry3d/Matrix3d.d.ts +25 -8
  265. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  266. package/lib/esm/geometry3d/Matrix3d.js +67 -15
  267. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  268. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +1 -0
  269. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  270. package/lib/esm/geometry3d/Point2dArrayCarrier.js +2 -1
  271. package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
  272. package/lib/esm/geometry3d/Point2dVector2d.d.ts +86 -25
  273. package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
  274. package/lib/esm/geometry3d/Point2dVector2d.js +230 -81
  275. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  276. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +14 -4
  277. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  278. package/lib/esm/geometry3d/Point3dArrayCarrier.js +15 -5
  279. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  280. package/lib/esm/geometry3d/Point3dVector3d.d.ts +121 -67
  281. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  282. package/lib/esm/geometry3d/Point3dVector3d.js +318 -137
  283. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  284. package/lib/esm/geometry3d/Range.d.ts +1 -2
  285. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  286. package/lib/esm/geometry3d/Range.js +1 -2
  287. package/lib/esm/geometry3d/Range.js.map +1 -1
  288. package/lib/esm/geometry3d/Ray3d.d.ts +5 -5
  289. package/lib/esm/geometry3d/Ray3d.js +5 -5
  290. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  291. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  292. package/lib/esm/geometry3d/Transform.js.map +1 -1
  293. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  294. package/lib/esm/numerics/Polynomials.js +0 -1
  295. package/lib/esm/numerics/Polynomials.js.map +1 -1
  296. package/lib/esm/polyface/IndexedEdgeMatcher.d.ts +4 -4
  297. package/lib/esm/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
  298. package/lib/esm/polyface/IndexedEdgeMatcher.js +3 -3
  299. package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
  300. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  301. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  302. package/lib/esm/polyface/Polyface.d.ts +7 -2
  303. package/lib/esm/polyface/Polyface.d.ts.map +1 -1
  304. package/lib/esm/polyface/Polyface.js +8 -1
  305. package/lib/esm/polyface/Polyface.js.map +1 -1
  306. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  307. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  308. package/lib/esm/polyface/PolyfaceQuery.d.ts +36 -8
  309. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  310. package/lib/esm/polyface/PolyfaceQuery.js +113 -32
  311. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  312. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  313. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  314. package/lib/esm/serialization/IModelJsonSchema.d.ts +1 -1
  315. package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
  316. package/lib/esm/serialization/IModelJsonSchema.js +4 -3
  317. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  318. package/lib/esm/solid/Sphere.d.ts +1 -1
  319. package/lib/esm/solid/Sphere.js +3 -3
  320. package/lib/esm/solid/Sphere.js.map +1 -1
  321. package/lib/esm/solid/TorusPipe.d.ts +17 -13
  322. package/lib/esm/solid/TorusPipe.d.ts.map +1 -1
  323. package/lib/esm/solid/TorusPipe.js +67 -38
  324. package/lib/esm/solid/TorusPipe.js.map +1 -1
  325. package/lib/esm/topology/Graph.d.ts +1 -1
  326. package/lib/esm/topology/Graph.js +1 -1
  327. package/lib/esm/topology/Graph.js.map +1 -1
  328. package/lib/esm/topology/Merging.d.ts.map +1 -1
  329. package/lib/esm/topology/Merging.js +9 -1
  330. package/lib/esm/topology/Merging.js.map +1 -1
  331. package/lib/esm/topology/Triangulation.d.ts +1 -1
  332. package/lib/esm/topology/Triangulation.js +1 -1
  333. package/lib/esm/topology/Triangulation.js.map +1 -1
  334. package/package.json +5 -5
@@ -6,6 +6,7 @@
6
6
  /** @packageDocumentation
7
7
  * @module CartesianGeometry
8
8
  */
9
+ // cspell:word CWXY
9
10
  Object.defineProperty(exports, "__esModule", { value: true });
10
11
  exports.Vector3d = exports.Point3d = exports.XYZ = void 0;
11
12
  const Geometry_1 = require("../Geometry");
@@ -20,24 +21,42 @@ const XYZProps_1 = require("./XYZProps");
20
21
  * @public
21
22
  */
22
23
  class XYZ {
23
- constructor(x = 0, y = 0, z = 0) { this.x = x; this.y = y; this.z = z; }
24
+ constructor(x = 0, y = 0, z = 0) {
25
+ this.x = x;
26
+ this.y = y;
27
+ this.z = z;
28
+ }
24
29
  /**
25
30
  * Set the x,y,z parts.
26
31
  * @param x (optional) x part
27
32
  * @param y (optional) y part
28
33
  * @param z (optional) z part
29
34
  */
30
- set(x = 0, y = 0, z = 0) { this.x = x; this.y = y; this.z = z; }
35
+ set(x = 0, y = 0, z = 0) {
36
+ this.x = x;
37
+ this.y = y;
38
+ this.z = z;
39
+ }
31
40
  /** Set the x,y,z parts to zero. */
32
- setZero() { this.x = 0; this.y = 0; this.z = 0; }
41
+ setZero() {
42
+ this.x = 0;
43
+ this.y = 0;
44
+ this.z = 0;
45
+ }
33
46
  /** Type guard for XAndY.
34
47
  * @note this will return true for an XYAndZ. If you wish to distinguish between the two, call isXYAndZ first.
35
48
  */
36
- static isXAndY(arg) { return arg.x !== undefined && arg.y !== undefined; }
49
+ static isXAndY(arg) {
50
+ return arg.x !== undefined && arg.y !== undefined;
51
+ }
37
52
  /** Type guard to determine whether an object has a member called "z" */
38
- static hasZ(arg) { return arg.z !== undefined; }
53
+ static hasZ(arg) {
54
+ return arg.z !== undefined;
55
+ }
39
56
  /** Type guard for XYAndZ. */
40
- static isXYAndZ(arg) { return this.isXAndY(arg) && this.hasZ(arg); }
57
+ static isXYAndZ(arg) {
58
+ return this.isXAndY(arg) && this.hasZ(arg);
59
+ }
41
60
  /** Test if arg is any of:
42
61
  * * XAndY
43
62
  * * XYAndZ
@@ -120,6 +139,7 @@ class XYZ {
120
139
  /**
121
140
  * Set the x,y,z parts from a Vector3d
122
141
  * This is the same effect as `setFrom(other)` with no pretesting of variant input type
142
+ * * Set to zeros if `other` is undefined.
123
143
  */
124
144
  setFromVector3d(other) {
125
145
  if (other) {
@@ -150,13 +170,21 @@ class XYZ {
150
170
  && Geometry_1.Geometry.isSameCoordinate(this.y, other.y, tol);
151
171
  }
152
172
  /** Return a JSON object as array `[x,y,z]` */
153
- toJSON() { return this.toArray(); }
173
+ toJSON() {
174
+ return this.toArray();
175
+ }
154
176
  /** Return as an array `[x,y,z]` */
155
- toArray() { return [this.x, this.y, this.z]; }
177
+ toArray() {
178
+ return [this.x, this.y, this.z];
179
+ }
156
180
  /** Return a JSON object as key value pairs `{x: value, y: value, z: value}` */
157
- toJSONXYZ() { return { x: this.x, y: this.y, z: this.z }; }
181
+ toJSONXYZ() {
182
+ return { x: this.x, y: this.y, z: this.z };
183
+ }
158
184
  /** Pack the x,y,z values in a Float64Array. */
159
- toFloat64Array() { return Float64Array.of(this.x, this.y, this.z); }
185
+ toFloat64Array() {
186
+ return Float64Array.of(this.x, this.y, this.z);
187
+ }
160
188
  /**
161
189
  * Set the x,y,z properties from one of several json forms:
162
190
  *
@@ -215,7 +243,7 @@ class XYZ {
215
243
  return this.y;
216
244
  }
217
245
  /**
218
- * Return the x,y, z component corresponding to 0,1,2.
246
+ * Set value at index 0 or 1 or 2.
219
247
  */
220
248
  setAt(index, value) {
221
249
  if (index < 0.5)
@@ -242,28 +270,54 @@ class XYZ {
242
270
  }
243
271
  /** Return true if the x,y,z components are all nearly zero to tolerance Geometry.smallMetricDistance */
244
272
  get isAlmostZero() {
245
- return Geometry_1.Geometry.isSmallMetricDistance(this.x) && Geometry_1.Geometry.isSmallMetricDistance(this.y) && Geometry_1.Geometry.isSmallMetricDistance(this.z);
273
+ return Geometry_1.Geometry.isSmallMetricDistance(this.x) &&
274
+ Geometry_1.Geometry.isSmallMetricDistance(this.y) &&
275
+ Geometry_1.Geometry.isSmallMetricDistance(this.z);
246
276
  }
247
277
  /** Return true if the x,y,z components are all exactly zero */
248
- get isZero() { return this.x === 0.0 && this.y === 0.0 && this.z === 0.0; }
278
+ get isZero() {
279
+ return this.x === 0.0 && this.y === 0.0 && this.z === 0.0;
280
+ }
249
281
  /** Return the largest absolute value of any component */
250
- maxAbs() { return Math.max(Math.abs(this.x), Math.abs(this.y), Math.abs(this.z)); }
282
+ maxAbs() {
283
+ return Math.max(Math.abs(this.x), Math.abs(this.y), Math.abs(this.z));
284
+ }
251
285
  /** Return the sqrt of the sum of squared x,y,z parts */
252
- magnitude() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); }
286
+ magnitude() {
287
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
288
+ }
253
289
  /** Return the sum of squared x,y,z parts */
254
- magnitudeSquared() { return this.x * this.x + this.y * this.y + this.z * this.z; }
290
+ magnitudeSquared() {
291
+ return this.x * this.x + this.y * this.y + this.z * this.z;
292
+ }
255
293
  /** Return sqrt of the sum of squared x,y parts */
256
- magnitudeXY() { return Math.sqrt(this.x * this.x + this.y * this.y); }
294
+ magnitudeXY() {
295
+ return Math.sqrt(this.x * this.x + this.y * this.y);
296
+ }
257
297
  /** Return the sum of squared x,y parts */
258
- magnitudeSquaredXY() { return this.x * this.x + this.y * this.y; }
298
+ magnitudeSquaredXY() {
299
+ return this.x * this.x + this.y * this.y;
300
+ }
259
301
  /** exact equality test. */
260
- isExactEqual(other) { return this.x === other.x && this.y === other.y && this.z === other.z; }
302
+ isExactEqual(other) {
303
+ return this.x === other.x && this.y === other.y && this.z === other.z;
304
+ }
261
305
  /** equality test with Geometry.smallMetricDistance tolerance */
262
- isAlmostEqualMetric(other) { return this.maxDiff(other) <= Geometry_1.Geometry.smallMetricDistance; }
306
+ isAlmostEqualMetric(other) {
307
+ return this.maxDiff(other) <= Geometry_1.Geometry.smallMetricDistance;
308
+ }
263
309
  /** add x,y,z from other in place. */
264
- addInPlace(other) { this.x += other.x; this.y += other.y; this.z += other.z; }
310
+ addInPlace(other) {
311
+ this.x += other.x;
312
+ this.y += other.y;
313
+ this.z += other.z;
314
+ }
265
315
  /** add x,y,z from other in place. */
266
- subtractInPlace(other) { this.x -= other.x; this.y -= other.y; this.z -= other.z; }
316
+ subtractInPlace(other) {
317
+ this.x -= other.x;
318
+ this.y -= other.y;
319
+ this.z -= other.z;
320
+ }
267
321
  /** add (in place) the scaled x,y,z of other */
268
322
  addScaledInPlace(other, scale) {
269
323
  this.x += scale * other.x;
@@ -271,11 +325,21 @@ class XYZ {
271
325
  this.z += scale * other.z;
272
326
  }
273
327
  /** Multiply the x, y, z parts by scale. */
274
- scaleInPlace(scale) { this.x *= scale; this.y *= scale; this.z *= scale; }
328
+ scaleInPlace(scale) {
329
+ this.x *= scale;
330
+ this.y *= scale;
331
+ this.z *= scale;
332
+ }
275
333
  /** add to x, y, z parts */
276
- addXYZInPlace(dx = 0.0, dy = 0.0, dz = 0.0) { this.x += dx; this.y += dy; this.z += dz; }
334
+ addXYZInPlace(dx = 0.0, dy = 0.0, dz = 0.0) {
335
+ this.x += dx;
336
+ this.y += dy;
337
+ this.z += dz;
338
+ }
277
339
  /** Clone strongly typed as Point3d */
278
- cloneAsPoint3d() { return Point3d.create(this.x, this.y, this.z); }
340
+ cloneAsPoint3d() {
341
+ return Point3d.create(this.x, this.y, this.z);
342
+ }
279
343
  /** Return a (full length) vector from this point to other */
280
344
  vectorTo(other, result) {
281
345
  return Vector3d.create(other.x - this.x, other.y - this.y, other.z - this.z, result);
@@ -288,9 +352,13 @@ class XYZ {
288
352
  * @param other target of created vector.
289
353
  * @param result optional result vector.
290
354
  */
291
- unitVectorTo(target, result) { return this.vectorTo(target, result).normalize(result); }
355
+ unitVectorTo(target, result) {
356
+ return this.vectorTo(target, result).normalize(result);
357
+ }
292
358
  /** Freeze this XYZ */
293
- freeze() { return Object.freeze(this); }
359
+ freeze() {
360
+ return Object.freeze(this);
361
+ }
294
362
  /** access x part of XYZProps (which may be .x or [0]) */
295
363
  static x(xyz, defaultValue = 0) {
296
364
  if (xyz === undefined)
@@ -328,7 +396,9 @@ exports.XYZ = XYZ;
328
396
  */
329
397
  class Point3d extends XYZ {
330
398
  /** Constructor for Point3d */
331
- constructor(x = 0, y = 0, z = 0) { super(x, y, z); }
399
+ constructor(x = 0, y = 0, z = 0) {
400
+ super(x, y, z);
401
+ }
332
402
  /**
333
403
  * Convert json to Point3d. Accepted forms are:
334
404
  * * `[1,2,3]` --- array of numbers
@@ -336,9 +406,15 @@ class Point3d extends XYZ {
336
406
  * * object with x,y, and (optional) z as numeric properties {x: xValue, y: yValue, z: zValue}
337
407
  * @param json json value.
338
408
  */
339
- static fromJSON(json) { const val = new Point3d(); val.setFromJSON(json); return val; }
409
+ static fromJSON(json) {
410
+ const val = new Point3d();
411
+ val.setFromJSON(json);
412
+ return val;
413
+ }
340
414
  /** Return a new Point3d with the same coordinates */
341
- clone(result) { return Point3d.create(this.x, this.y, this.z, result); }
415
+ clone(result) {
416
+ return Point3d.create(this.x, this.y, this.z, result);
417
+ }
342
418
  /** Create a new Point3d with given coordinates
343
419
  * @param x x part
344
420
  * @param y y part
@@ -384,7 +460,7 @@ class Point3d extends XYZ {
384
460
  /**
385
461
  * Copy and unweight xyzw.
386
462
  * @param xyzData flat array of x,y,z,w,x,y,z,w for multiple points
387
- * @param pointIndex index of point to extract. This index is multiplied by 4 to obtain starting index in the array.
463
+ * @param pointIndex index of point to extract. This index is multiplied by 4 to obtain starting index in the array.
388
464
  * @param result optional result point.
389
465
  */
390
466
  static createFromPackedXYZW(xyzData, pointIndex, result) {
@@ -409,7 +485,9 @@ class Point3d extends XYZ {
409
485
  return result;
410
486
  }
411
487
  /** Create a new point with 000 xyz */
412
- static createZero(result) { return Point3d.create(0, 0, 0, result); }
488
+ static createZero(result) {
489
+ return Point3d.create(0, 0, 0, result);
490
+ }
413
491
  /** Return the cross product of the vectors from this to pointA and pointB
414
492
  *
415
493
  * * the result is a vector
@@ -427,7 +505,7 @@ class Point3d extends XYZ {
427
505
  /** Return the triple product of the vectors from this to pointA, pointB, pointC
428
506
  *
429
507
  * * This is a scalar (number)
430
- * * This is 6 times the (signed) volume of the tetrahedron on the 4 points.
508
+ * * This is 6 times the (signed) volume of the tetrahedron on the 4 points.
431
509
  */
432
510
  tripleProductToPoints(pointA, pointB, pointC) {
433
511
  return Geometry_1.Geometry.tripleProduct(pointA.x - this.x, pointA.y - this.y, pointA.z - this.z, pointB.x - this.x, pointB.y - this.y, pointB.z - this.z, pointC.x - this.x, pointC.y - this.y, pointC.z - this.z);
@@ -441,7 +519,10 @@ class Point3d extends XYZ {
441
519
  crossProductToPointsXY(pointA, pointB) {
442
520
  return Geometry_1.Geometry.crossProductXYXY(pointA.x - this.x, pointA.y - this.y, pointB.x - this.x, pointB.y - this.y);
443
521
  }
444
- /** Return a point interpolated between this point and the right param. */
522
+ /**
523
+ * Return a point interpolated between `this` point and the `other` point.
524
+ * * fraction specifies where the interpolated point is located on the line passing `this` and `other`.
525
+ * */
445
526
  interpolate(fraction, other, result) {
446
527
  if (fraction <= 0.5)
447
528
  return Point3d.create(this.x + fraction * (other.x - this.x), this.y + fraction * (other.y - this.y), this.z + fraction * (other.z - this.z), result);
@@ -524,9 +605,7 @@ class Point3d extends XYZ {
524
605
  (targetA.y - this.y) * (targetB.y - this.y) +
525
606
  (targetA.z - this.z) * (targetB.z - this.z);
526
607
  }
527
- /** Return the fractional projection of this onto a line between points.
528
- *
529
- */
608
+ /** Return the fractional projection of this onto a line between points. */
530
609
  fractionOfProjectionToLine(startPoint, endPoint, defaultFraction = 0) {
531
610
  const denominator = startPoint.distanceSquared(endPoint);
532
611
  if (denominator < Geometry_1.Geometry.smallMetricDistanceSquared)
@@ -539,7 +618,9 @@ exports.Point3d = Point3d;
539
618
  * @public
540
619
  */
541
620
  class Vector3d extends XYZ {
542
- constructor(x = 0, y = 0, z = 0) { super(x, y, z); }
621
+ constructor(x = 0, y = 0, z = 0) {
622
+ super(x, y, z);
623
+ }
543
624
  /**
544
625
  * Return an array of vectors constructed from groups of 3 entries in a Float64Array.
545
626
  * Any incomplete group at the tail of the array is ignored.
@@ -554,7 +635,9 @@ class Vector3d extends XYZ {
554
635
  * Copy xyz from this instance to a new (or optionally reused) Vector3d
555
636
  * @param result optional instance to reuse.
556
637
  */
557
- clone(result) { return Vector3d.create(this.x, this.y, this.z, result); }
638
+ clone(result) {
639
+ return Vector3d.create(this.x, this.y, this.z, result);
640
+ }
558
641
  /**
559
642
  * return a Vector3d (new or reused from optional result)
560
643
  * @param x x component
@@ -643,7 +726,11 @@ class Vector3d extends XYZ {
643
726
  * * object with x,y, and (optional) z as numeric properties {x: xValue, y: yValue, z: zValue}
644
727
  * @param json json value.
645
728
  */
646
- static fromJSON(json) { const val = new Vector3d(); val.setFromJSON(json); return val; }
729
+ static fromJSON(json) {
730
+ const val = new Vector3d();
731
+ val.setFromJSON(json);
732
+ return val;
733
+ }
647
734
  /** Copy contents from another Point3d, Point2d, Vector2d, or Vector3d */
648
735
  static createFrom(data, result) {
649
736
  if (data instanceof Float64Array) {
@@ -719,7 +806,7 @@ class Vector3d extends XYZ {
719
806
  return undefined;
720
807
  }
721
808
  /**
722
- * Set (replace) xzz components so they are a vector from point0 to point1
809
+ * Set (replace) xyz components so they are a vector from point0 to point1
723
810
  * @param point0 start point of computed vector
724
811
  * @param point1 end point of computed vector.
725
812
  */
@@ -729,13 +816,21 @@ class Vector3d extends XYZ {
729
816
  this.z = point1.z - point0.z;
730
817
  }
731
818
  /** Return a vector with 000 xyz parts. */
732
- static createZero(result) { return Vector3d.create(0, 0, 0, result); }
819
+ static createZero(result) {
820
+ return Vector3d.create(0, 0, 0, result);
821
+ }
733
822
  /** Return a unit X vector optionally multiplied by a scale */
734
- static unitX(scale = 1) { return new Vector3d(scale, 0, 0); }
735
- /** Return a unit Y vector */
736
- static unitY(scale = 1) { return new Vector3d(0, scale, 0); }
737
- /** Return a unit Z vector */
738
- static unitZ(scale = 1) { return new Vector3d(0, 0, scale); }
823
+ static unitX(scale = 1) {
824
+ return new Vector3d(scale, 0, 0);
825
+ }
826
+ /** Return a unit Y vector optionally multiplied by a scale */
827
+ static unitY(scale = 1) {
828
+ return new Vector3d(0, scale, 0);
829
+ }
830
+ /** Return a unit Z vector optionally multiplied by a scale */
831
+ static unitZ(scale = 1) {
832
+ return new Vector3d(0, 0, scale);
833
+ }
739
834
  /** Divide by denominator, but return undefined if denominator is zero. */
740
835
  safeDivideOrNull(denominator, result) {
741
836
  if (denominator !== 0.0) {
@@ -744,8 +839,8 @@ class Vector3d extends XYZ {
744
839
  return undefined;
745
840
  }
746
841
  /**
747
- * Return a pair object containing (a) property `v` which is a unit vector in the direction
748
- * of the input and (b) property mag which is the magnitude (length) of the input (instance) prior to normalization.
842
+ * Return a pair object containing (a) property `v` which is a unit vector in the direction of the input
843
+ * and (b) property mag which is the magnitude (length) of the input (instance) prior to normalization.
749
844
  * If the instance (input) is a near zero length the `v` property of the output is undefined.
750
845
  * @param result optional result.
751
846
  */
@@ -758,7 +853,9 @@ class Vector3d extends XYZ {
758
853
  * Return a unit vector parallel with this. Return undefined if this.magnitude is near zero.
759
854
  * @param result optional result.
760
855
  */
761
- normalize(result) { return this.normalizeWithLength(result).v; }
856
+ normalize(result) {
857
+ return this.normalizeWithLength(result).v;
858
+ }
762
859
  /**
763
860
  * If this vector has nonzero length, divide by the length to change to a unit vector.
764
861
  * @returns true if normalization completed.
@@ -772,8 +869,31 @@ class Vector3d extends XYZ {
772
869
  this.z *= a;
773
870
  return true;
774
871
  }
775
- /** Return the fractional projection of spaceVector onto this */
872
+ /** Create a normalized vector from the inputs.
873
+ * @param result optional result
874
+ * @returns undefined if and only if normalization fails
875
+ */
876
+ static createNormalized(x = 0, y = 0, z = 0, result) {
877
+ if (undefined === result)
878
+ result = Vector3d.create(x, y, z);
879
+ else
880
+ result.set(x, y, z);
881
+ if (result.normalizeInPlace())
882
+ return result;
883
+ return undefined;
884
+ }
885
+ /**
886
+ * Return fractional projection of target vector onto this
887
+ * * It's returning the signed projection magnitude divided by the target magnitude. In other words,
888
+ * it's returning the length of the projection as a fraction of the target magnitude.
889
+ * @param target the target vector
890
+ * @param defaultFraction the returned value in case magnitude square of target vector is very small
891
+ * */
776
892
  fractionOfProjectionToVector(target, defaultFraction = 0) {
893
+ /*
894
+ * projection length is (this.target)/||target||
895
+ * but here we return (this.target)/||target||^2
896
+ */
777
897
  const numerator = this.dotProduct(target);
778
898
  const denominator = target.magnitudeSquared();
779
899
  if (denominator < Geometry_1.Geometry.smallMetricDistanceSquared)
@@ -793,7 +913,7 @@ class Vector3d extends XYZ {
793
913
  /** Return a vector same length as this but rotate 90 degrees CCW */
794
914
  rotate90CCWXY(result) {
795
915
  result = result ? result : new Vector3d();
796
- // save x,y to allow aliasing ..
916
+ // save x,y to allow aliasing ("this" can be passed to the function as "result")
797
917
  const xx = this.x;
798
918
  const yy = this.y;
799
919
  result.x = -yy;
@@ -801,6 +921,17 @@ class Vector3d extends XYZ {
801
921
  result.z = this.z;
802
922
  return result;
803
923
  }
924
+ /** Return a vector same length as this but rotated 90 degrees clockwise */
925
+ rotate90CWXY(result) {
926
+ result = result ? result : new Vector3d();
927
+ // save x,y to allow aliasing ("this" can be passed to the function as "result")
928
+ const xx = this.x;
929
+ const yy = this.y;
930
+ result.x = yy;
931
+ result.y = -xx;
932
+ result.z = this.z;
933
+ return result;
934
+ }
804
935
  /**
805
936
  * Return a vector which is in the xy plane, perpendicular ot the xy part of this vector, and of unit length.
806
937
  * * If the xy part is 00, the return is the rotated (but not normalized) xy parts of this vector.
@@ -810,6 +941,7 @@ class Vector3d extends XYZ {
810
941
  result = result ? result : new Vector3d();
811
942
  const xx = this.x;
812
943
  const yy = this.y;
944
+ // save x,y to allow aliasing ("this" can be passed to the function as "result")
813
945
  result.x = -yy;
814
946
  result.y = xx;
815
947
  result.z = 0.0;
@@ -839,17 +971,23 @@ class Vector3d extends XYZ {
839
971
  return result;
840
972
  }
841
973
  /**
842
- * Return a (new or optionally preallocated) vector that is rotated 90 degrees in the plane of this vector and the target vector.
974
+ * Return a (new or optionally preallocated) vector that is rotated 90 degrees in
975
+ * the plane of this vector and the target vector.
843
976
  * @param target Second vector which defines the plane of rotation.
844
977
  * @param result optional preallocated vector for result.
845
- * @returns rotated vector, or undefined if the cross product of this and the the target cannot be normalized (i.e. if the target and this are colinear)
978
+ * @returns rotated vector, or undefined if the cross product of this and
979
+ * the the target cannot be normalized (i.e. if the target and this are colinear)
846
980
  */
847
981
  rotate90Towards(target, result) {
848
982
  const normal = this.crossProduct(target).normalize();
849
983
  return normal ? normal.crossProduct(this, result) : undefined;
850
984
  }
851
985
  /** Rotate this vector 90 degrees around an axis vector.
852
- * @returns the (new or optionally reused result) rotated vector, or undefined if the axis vector cannot be normalized.
986
+ * * Note that simple cross is in the plane perpendicular to axis -- it loses the part
987
+ * of "this" that is along the axis. The unit and scale is supposed to fix that.
988
+ * This matches with Rodrigues' rotation formula because cos(theta) = 0 and sin(theta) = 1
989
+ * @returns the (new or optionally reused result) rotated vector, or undefined if the axis
990
+ * vector cannot be normalized.
853
991
  */
854
992
  rotate90Around(axis, result) {
855
993
  const unitNormal = axis.normalize();
@@ -857,12 +995,17 @@ class Vector3d extends XYZ {
857
995
  }
858
996
  /**
859
997
  * Return a vector computed at fractional position between this vector and vectorB
860
- * @param fraction fractional position. 0 is at `this`. 1 is at `vectorB`. True fractions are "between", negatives are "before this", beyond 1 is "beyond vectorB".
998
+ * @param fraction fractional position. 0 is at `this`. 1 is at `vectorB`.
999
+ * True fractions are "between", negatives are "before this", beyond 1 is "beyond vectorB".
861
1000
  * @param vectorB second vector
862
1001
  * @param result optional preallocated result.
863
1002
  */
864
1003
  interpolate(fraction, vectorB, result) {
865
1004
  result = result ? result : new Vector3d();
1005
+ /*
1006
+ * For best last-bit behavior, if fraction is below 0.5, use this as base point.
1007
+ * If above 0.5, use vectorB as base point.
1008
+ */
866
1009
  if (fraction <= 0.5) {
867
1010
  result.x = this.x + fraction * (vectorB.x - this.x);
868
1011
  result.y = this.y + fraction * (vectorB.y - this.y);
@@ -928,7 +1071,8 @@ class Vector3d extends XYZ {
928
1071
  static createAdd2Scaled(vectorA, scaleA, vectorB, scaleB, result) {
929
1072
  return Vector3d.create(vectorA.x * scaleA + vectorB.x * scaleB, vectorA.y * scaleA + vectorB.y * scaleB, vectorA.z * scaleA + vectorB.z * scaleB, result);
930
1073
  }
931
- /** Return the (strongly typed Vector3d) `thisVector3d + vectorA * scalarA + vectorB * scalarB` with all components presented as numbers */
1074
+ /** Return the (strongly typed Vector3d) `thisVector3d + vectorA * scalarA + vectorB * scalarB`
1075
+ * with all components presented as numbers */
932
1076
  static createAdd2ScaledXYZ(ax, ay, az, scaleA, bx, by, bz, scaleB, result) {
933
1077
  return Vector3d.create(ax * scaleA + bx * scaleB, ay * scaleA + by * scaleB, az * scaleA + bz * scaleB, result);
934
1078
  }
@@ -963,7 +1107,8 @@ class Vector3d extends XYZ {
963
1107
  return this.crossProduct(vectorB, result).normalize(result);
964
1108
  }
965
1109
  /**
966
- * Compute the cross product of this vector with `vectorB`. Normalize it, using given xyz as default if length is zero.
1110
+ * Compute the cross product of this vector with `vectorB`. Normalize it, using given xyz as
1111
+ * default if length is zero.
967
1112
  * @param vectorB second vector of cross product
968
1113
  * @param x x value for default result
969
1114
  * @param y y value for default result
@@ -1007,7 +1152,8 @@ class Vector3d extends XYZ {
1007
1152
  return true;
1008
1153
  }
1009
1154
  /**
1010
- * Compute cross product with `vectorB`.
1155
+ * Compute cross product with `vectorB`
1156
+ * * cross product vector will have the given length.
1011
1157
  * @param vectorB second vector for cross product.
1012
1158
  * @param productLength desired length of result vector.
1013
1159
  * @param result optional preallocated vector
@@ -1096,17 +1242,18 @@ class Vector3d extends XYZ {
1096
1242
  return this.x * (pointB.x - pointA.x)
1097
1243
  + this.y * (pointB.y - pointA.y);
1098
1244
  }
1099
- /** Dot product with vector from pointA to pointB, with pointB given as (weighted) x,y,z,w
1100
- * * pointB is a homogeneous point that has to be unweighted
1245
+ /** Dot product with vector from pointA to pointB, with pointB given as (weighted) wx,wy,wz,w
1246
+ * * We need to unweight pointB (which is a homogeneous point) to be able to participate in the
1247
+ * vector dot product
1101
1248
  * * if the weight is near zero metric, the return is zero.
1102
1249
  */
1103
- dotProductStartEndXYZW(pointA, x, y, z, w) {
1250
+ dotProductStartEndXYZW(pointA, wx, wy, wz, w) {
1104
1251
  if (Geometry_1.Geometry.isSmallMetricDistance(w))
1105
1252
  return 0.0;
1106
1253
  const dw = 1.0 / w;
1107
- return this.x * (dw * x - pointA.x)
1108
- + this.y * (dw * y - pointA.y)
1109
- + this.z * (dw * z - pointA.z);
1254
+ return this.x * (dw * wx - pointA.x)
1255
+ + this.y * (dw * wy - pointA.y)
1256
+ + this.z * (dw * wz - pointA.z);
1110
1257
  }
1111
1258
  /** Return the dot product of the instance and vectorB, using only the x and y parts. */
1112
1259
  dotProductXY(vectorB) {
@@ -1148,133 +1295,167 @@ class Vector3d extends XYZ {
1148
1295
  return Vector3d.createCrossProduct(this.x, this.y, this.z, x, y, z, result);
1149
1296
  }
1150
1297
  /**
1151
- * Return the (Strongly typed) angle from this vector to vectorB.
1298
+ * Return the (radians as a simple number, not strongly typed Angle) angle from this vector to vectorB.
1299
+ * * The returned angle is always positive and no larger than 180 degrees (PI radians)
1300
+ * * The returned angle is "in the plane containing the two vectors"
1301
+ * * Use `planarRadiansTo` and `signedRadiansTo` to take have angle measured in specific plane.
1302
+ * @param vectorB target vector.
1303
+ */
1304
+ radiansTo(vectorB) {
1305
+ // ||axb|| = ||a|| ||b|| |sin(t)| and a.b = ||a|| ||b|| cos(t) ==>
1306
+ // ||axb|| / a.b = sin(t)/cos(t) = tan(t) ==> t = arctan(||axb|| / a.b).
1307
+ return Math.atan2(this.crossProductMagnitude(vectorB), this.dotProduct(vectorB));
1308
+ }
1309
+ /**
1310
+ * Return the (strongly typed) angle from this vector to vectorB.
1152
1311
  * * The returned angle is always positive and no larger than 180 degrees (PI radians)
1153
1312
  * * The returned angle is "in the plane containing the two vectors"
1154
- * * Use `planarAngleTo`, `signedAngleTo`, `angleToXY` to take have angle measured in specific plane.
1155
- * @param vectorB target vector of rotation.
1313
+ * * Use `planarAngleTo` and `signedAngleTo` to take have angle measured in specific plane.
1314
+ * @param vectorB target vector.
1156
1315
  */
1157
1316
  angleTo(vectorB) {
1158
- return Angle_1.Angle.createAtan2(this.crossProductMagnitude(vectorB), this.dotProduct(vectorB));
1317
+ return Angle_1.Angle.createRadians(this.radiansTo(vectorB));
1159
1318
  }
1160
1319
  /**
1161
- * Return the (Strongly typed) angle from this vector to the plane perpendicular to planeNormal.
1320
+ * Return the (strongly typed) angle from this vector to the plane perpendicular to planeNormal.
1162
1321
  * * The returned vector is signed
1163
- * * The returned vector is (as degrees) always less than or equal to 90 degrees.
1164
- * @param planeNormal a normal vector to the plane
1322
+ * * The returned vector is (as degrees) always between -90 and 90 degrees.
1323
+ * * The function returns "PI/2 - angleTo(planeNormal)"
1324
+ * @param planeNormal a normal vector to the plane.
1165
1325
  */
1166
- angleFromPerpendicular(vectorB) {
1167
- return Angle_1.Angle.createAtan2(this.dotProduct(vectorB), this.crossProductMagnitude(vectorB));
1326
+ angleFromPerpendicular(planeNormal) {
1327
+ return Angle_1.Angle.createAtan2(this.dotProduct(planeNormal), this.crossProductMagnitude(planeNormal));
1168
1328
  }
1169
1329
  /**
1170
- * Return the (Strongly typed) angle from this vector to vectorB,using only the xy parts.
1171
- * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180 degrees (positive PI radians), not closed on the negative side.
1172
- * * Use `planarAngleTo`, `signedAngleTo`, `angleToXY` to take have angle measured in other planes.
1173
- * @param vectorB target vector of rotation.
1330
+ * Return the (Strongly typed) angle from this vector to vectorB, using only the xy parts.
1331
+ * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180
1332
+ * * degrees (positive PI radians), not closed on the negative side.
1333
+ * * Use `planarAngleTo` and `signedAngleTo` to take have angle measured in other planes.
1334
+ * @param vectorB target vector.
1174
1335
  */
1175
1336
  angleToXY(vectorB) {
1176
1337
  return Angle_1.Angle.createAtan2(this.crossProductXY(vectorB), this.dotProductXY(vectorB));
1177
1338
  }
1178
1339
  /**
1179
- * Return the (radians as a simple number, not strongly typed Angle) radians from this vector to vectorB.
1340
+ * Return the (simple number of radians, not Strongly typed Angle) angle from this vector to vectorB, measured
1341
+ * in the plane containing both, with vectorW indicating which side to view to control sign of the angle.
1342
+ * * The returned angle can range from negative PI to positive PI (not closed on negative side)
1343
+ * * The returned angle is "in the plane containing the two vectors"
1344
+ * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1345
+ * * vectorW does not have to be perpendicular to the plane.
1346
+ * * Use planarRadiansTo to measure the angle between vectors that are projected to another plane.
1347
+ * @param vectorB target vector.
1348
+ * @param vectorW distinguishes between the sides of the plane.
1349
+ */
1350
+ signedRadiansTo(vectorB, vectorW) {
1351
+ const p = this.crossProduct(vectorB);
1352
+ const theta = Math.atan2(p.magnitude(), this.dotProduct(vectorB));
1353
+ if (vectorW.dotProduct(p) < 0.0)
1354
+ return -theta;
1355
+ else
1356
+ return theta;
1357
+ }
1358
+ /**
1359
+ * Return the (strongly typed Angle) angle from this vector to vectorB, measured in the plane containing both,
1360
+ * with vectorW indicating which side to view to control sign of the angle.
1361
+ * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180 degrees
1362
+ * * (positive PI radians), not closed on the negative side.
1363
+ * * The returned angle is "in the plane containing the two vectors"
1364
+ * * `vectorW` distinguishes between the sides of the plane, but does not have to be perpendicular.
1365
+ * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1366
+ * * Use planarRadiansTo to measure the angle between vectors that are projected to another plane.
1367
+ * @param vectorB target vector.
1368
+ * @param vectorW distinguishes between the sides of the plane.
1369
+ */
1370
+ signedAngleTo(vectorB, vectorW) {
1371
+ return Angle_1.Angle.createRadians(this.signedRadiansTo(vectorB, vectorW));
1372
+ }
1373
+ /**
1374
+ * Return the radians (as a simple number, not strongly typed Angle) from this vector to vectorB,
1375
+ * measured between their projections to the plane with the given normal.
1180
1376
  * * The returned angle can be positive or negative, with magnitude no larger than PI radians
1181
- * * Use signedRadiansTo` to take have angle measured in other planes.
1182
- * @param vectorB target vector of rotation.
1377
+ * @param vectorB target vector
1378
+ * @param planeNormal the normal vector to the plane.
1183
1379
  */
1184
- planarRadiansTo(vector, planeNormal) {
1380
+ planarRadiansTo(vectorB, planeNormal) {
1185
1381
  const square = planeNormal.dotProduct(planeNormal);
1186
1382
  if (square === 0.0)
1187
1383
  return 0.0;
1188
1384
  const factor = 1.0 / square;
1189
- const projection0 = this.plusScaled(planeNormal, -this.dotProduct(planeNormal) * factor);
1190
- const projection1 = vector.plusScaled(planeNormal, -vector.dotProduct(planeNormal) * factor);
1191
- return projection0.signedRadiansTo(projection1, planeNormal);
1385
+ /*
1386
+ * projection of vector 'v' on normal 'n' is given by vProj = [dot(v,n)/||n||^2]*n
1387
+ * and projection of 'v' on the plane is given by 'v - vProj'
1388
+ */
1389
+ const thisProj = this.plusScaled(planeNormal, -this.dotProduct(planeNormal) * factor);
1390
+ const vectorBProj = vectorB.plusScaled(planeNormal, -vectorB.dotProduct(planeNormal) * factor);
1391
+ return thisProj.signedRadiansTo(vectorBProj, planeNormal);
1192
1392
  }
1193
1393
  /**
1194
- * Return the (as strongly typed Angle) Angle from this vector to vectorB.
1394
+ * Return the angle (as strongly typed Angle) from this vector to vectorB,
1395
+ * measured between their projections to the plane with the given normal.
1195
1396
  * * The returned angle can range from negative PI to positive PI (not closed on negative side)
1196
- * * Use signedRadiansTo` to take have angle measured in other planes.
1197
- * @param vectorB target vector of rotation.
1397
+ * @param vectorB target vector.
1398
+ * @param planeNormal the normal vector to the plane.
1198
1399
  */
1199
- planarAngleTo(vector, planeNormal) {
1200
- return Angle_1.Angle.createRadians(this.planarRadiansTo(vector, planeNormal));
1400
+ planarAngleTo(vectorB, planeNormal) {
1401
+ return Angle_1.Angle.createRadians(this.planarRadiansTo(vectorB, planeNormal));
1201
1402
  }
1202
- /**
1203
- * Return the (simple number of radians, not Strongly typed Angle) angle from this vector to vectorB, measured in the plane containing both, with vectorW indicating which side to view to control sign of the angle.
1204
- * * The returned angle can range from negative PI to positive PI (not closed on negative side)
1205
- * * The returned angle is "in the plane containing the two vectors"
1206
- * * `vectorW` distinguishes between the sides of the plane, but does not have to be perpendicular.
1207
- * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1208
- * @param vectorB target vector of rotation.
1209
- */
1210
- signedRadiansTo(vector1, vectorW) {
1211
- const p = this.crossProduct(vector1);
1212
- const theta = Math.atan2(p.magnitude(), this.dotProduct(vector1));
1213
- if (vectorW.dotProduct(p) < 0.0)
1214
- return -theta;
1215
- else
1216
- return theta;
1217
- }
1218
- /**
1219
- * Return the (strongly typed Angle) angle from this vector to vectorB, measured in the plane containing both, with vectorW indicating which side to view to control sign of the angle.
1220
- * * The returned angle can range from negative 180 degrees (negative PI radians) to positive 180 degrees (positive PI radians), not closed on the negative side.
1221
- * * The returned angle is "in the plane containing the two vectors"
1222
- * * `vectorW` distinguishes between the sides of the plane, but does not have to be perpendicular.
1223
- * * The returned angle has the same sign as vectorW dot product (thisVector cross vectorB)
1224
- * @param vectorB target vector of rotation.
1225
- */
1226
- signedAngleTo(vector1, vectorW) { return Angle_1.Angle.createRadians(this.signedRadiansTo(vector1, vectorW)); }
1227
- /** Return the smallest (strongly typed) angle from the (bidirectional) line containing `this` to the (bidirectional) line containing `vectorB` */
1228
- smallerUnorientedAngleTo(vectorB) {
1229
- return Angle_1.Angle.createRadians(this.smallerUnorientedRadiansTo(vectorB));
1230
- }
1231
- /** Return the smallest angle (in radians) from the (bidirectional) line containing `this` to the (bidirectional) line containing `vectorB` */
1403
+ /** Return the smallest angle (in radians) from the (bidirectional) line containing `this`
1404
+ * to the (bidirectional) line containing `vectorB` */
1232
1405
  smallerUnorientedRadiansTo(vectorB) {
1233
1406
  const c = this.dotProduct(vectorB);
1234
1407
  const s = this.crossProductMagnitude(vectorB);
1235
1408
  return Math.atan2(Math.abs(s), Math.abs(c));
1236
1409
  }
1237
- /*
1238
- signedAngleTo(vectorB: Vector3d, upVector: Vector3d): Angle { }
1239
- // sectors
1240
- isInSmallerSector(vectorA: Vector3d, vectorB: Vector3d): boolean { }
1241
- isInCCWSector(vectorA: Vector3d, vectorB: Vector3d, upVector: Vector3d): boolean { }
1242
- */
1410
+ /** Return the smallest (strongly typed) angle from the (bidirectional) line containing `this`
1411
+ * to the (bidirectional) line containing `vectorB` */
1412
+ smallerUnorientedAngleTo(vectorB) {
1413
+ return Angle_1.Angle.createRadians(this.smallerUnorientedRadiansTo(vectorB));
1414
+ }
1243
1415
  /**
1244
1416
  * Test if this vector is parallel to other.
1417
+ * * The input tolerances in `options`, if given, are considered to be squared for efficiency's sake,
1418
+ * so if you have a distance or angle tolerance t, you should pass in t * t.
1245
1419
  * @param other second vector in comparison
1246
- * @param oppositeIsParallel if the vectors are on the same line but in opposite directions, return this value.
1420
+ * @param oppositeIsParallel whether to consider diametrically opposed vectors as parallel
1247
1421
  * @param returnValueIfAnInputIsZeroLength if either vector is near zero length, return this value.
1422
+ * @param options optional radian and distance tolerances.
1248
1423
  */
1249
- isParallelTo(other, oppositeIsParallel = false, returnValueIfAnInputIsZeroLength = false) {
1424
+ isParallelTo(other, oppositeIsParallel = false, returnValueIfAnInputIsZeroLength = false, options) {
1425
+ var _a, _b;
1426
+ const radianSquaredTol = (_a = options === null || options === void 0 ? void 0 : options.radianSquaredTol) !== null && _a !== void 0 ? _a : Geometry_1.Geometry.smallAngleRadiansSquared;
1427
+ const distanceSquaredTol = (_b = options === null || options === void 0 ? void 0 : options.distanceSquaredTol) !== null && _b !== void 0 ? _b : Geometry_1.Geometry.smallMetricDistanceSquared;
1250
1428
  const a2 = this.magnitudeSquared();
1251
1429
  const b2 = other.magnitudeSquared();
1252
- // we know both are 0 or positive -- no need for
1253
- if (a2 < Geometry_1.Geometry.smallMetricDistanceSquared || b2 < Geometry_1.Geometry.smallMetricDistanceSquared)
1430
+ if (a2 < distanceSquaredTol || b2 < distanceSquaredTol)
1254
1431
  return returnValueIfAnInputIsZeroLength;
1255
1432
  const dot = this.dotProduct(other);
1256
1433
  if (dot < 0.0 && !oppositeIsParallel)
1257
- return returnValueIfAnInputIsZeroLength;
1434
+ return false;
1258
1435
  const cross2 = this.crossProductMagnitudeSquared(other);
1259
1436
  /* a2,b2,cross2 are squared lengths of respective vectors */
1260
1437
  /* cross2 = sin^2(theta) * a2 * b2 */
1261
1438
  /* For small theta, sin^2(theta)~~theta^2 */
1262
- return cross2 <= Geometry_1.Geometry.smallAngleRadiansSquared * a2 * b2;
1439
+ return cross2 <= radianSquaredTol * a2 * b2;
1263
1440
  }
1264
1441
  /**
1265
1442
  * Test if this vector is perpendicular to other.
1443
+ * * The input tolerances in `options`, if given, are considered to be squared for efficiency's sake,
1444
+ * so if you have a distance or angle tolerance t, you should pass in t * t.
1266
1445
  * @param other second vector in comparison
1267
1446
  * @param returnValueIfAnInputIsZeroLength if either vector is near zero length, return this value.
1447
+ * @param options optional radian and distance tolerances.
1268
1448
  */
1269
- isPerpendicularTo(other, returnValueIfAnInputIsZeroLength = false) {
1449
+ isPerpendicularTo(other, returnValueIfAnInputIsZeroLength = false, options) {
1450
+ var _a, _b;
1451
+ const radianSquaredTol = (_a = options === null || options === void 0 ? void 0 : options.radianSquaredTol) !== null && _a !== void 0 ? _a : Geometry_1.Geometry.smallAngleRadiansSquared;
1452
+ const distanceSquaredTol = (_b = options === null || options === void 0 ? void 0 : options.distanceSquaredTol) !== null && _b !== void 0 ? _b : Geometry_1.Geometry.smallMetricDistanceSquared;
1270
1453
  const aa = this.magnitudeSquared();
1271
- if (aa < Geometry_1.Geometry.smallMetricDistanceSquared)
1272
- return returnValueIfAnInputIsZeroLength;
1273
1454
  const bb = other.magnitudeSquared();
1274
- if (bb < Geometry_1.Geometry.smallMetricDistanceSquared)
1455
+ if (aa < distanceSquaredTol || bb < distanceSquaredTol)
1275
1456
  return returnValueIfAnInputIsZeroLength;
1276
1457
  const ab = this.dotProduct(other);
1277
- return ab * ab <= Geometry_1.Geometry.smallAngleRadiansSquared * aa * bb;
1458
+ return ab * ab <= radianSquaredTol * aa * bb;
1278
1459
  }
1279
1460
  }
1280
1461
  exports.Vector3d = Vector3d;