@itwin/core-geometry 4.10.0-dev.3 → 4.10.0-dev.31

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 (208) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Geometry.d.ts +2 -2
  3. package/lib/cjs/Geometry.js +2 -2
  4. package/lib/cjs/Geometry.js.map +1 -1
  5. package/lib/cjs/clipping/ClipPrimitive.d.ts +7 -7
  6. package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
  7. package/lib/cjs/clipping/ClipPrimitive.js +1 -1
  8. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  9. package/lib/cjs/core-geometry.d.ts +1 -1
  10. package/lib/cjs/core-geometry.d.ts.map +1 -1
  11. package/lib/cjs/core-geometry.js +1 -1
  12. package/lib/cjs/core-geometry.js.map +1 -1
  13. package/lib/cjs/curve/Arc3d.d.ts +21 -10
  14. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  15. package/lib/cjs/curve/Arc3d.js +66 -38
  16. package/lib/cjs/curve/Arc3d.js.map +1 -1
  17. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +27 -8
  18. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  19. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +44 -25
  20. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  21. package/lib/cjs/curve/CurveFactory.d.ts +11 -13
  22. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  23. package/lib/cjs/curve/CurveFactory.js +19 -46
  24. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  25. package/lib/cjs/curve/LineSegment3d.js +2 -2
  26. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  27. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  28. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +5 -4
  29. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  30. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  31. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  32. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +40 -65
  33. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  34. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
  35. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  36. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +131 -70
  37. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  38. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  39. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
  40. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  41. package/lib/cjs/geometry3d/Angle.d.ts +5 -5
  42. package/lib/cjs/geometry3d/Angle.js +5 -5
  43. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  44. package/lib/cjs/geometry3d/AngleSweep.d.ts +101 -13
  45. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  46. package/lib/cjs/geometry3d/AngleSweep.js +156 -57
  47. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  48. package/lib/cjs/geometry3d/BilinearPatch.js +4 -4
  49. package/lib/cjs/geometry3d/BilinearPatch.js.map +1 -1
  50. package/lib/cjs/geometry3d/Matrix3d.d.ts +35 -31
  51. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  52. package/lib/cjs/geometry3d/Matrix3d.js +55 -31
  53. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  54. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +6 -5
  55. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  56. package/lib/cjs/geometry3d/Point3dVector3d.js +6 -5
  57. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  58. package/lib/cjs/geometry3d/PolygonOps.js +2 -2
  59. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  60. package/lib/cjs/geometry3d/Ray3d.js +2 -2
  61. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  62. package/lib/cjs/geometry3d/Transform.d.ts +4 -2
  63. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  64. package/lib/cjs/geometry3d/Transform.js +4 -2
  65. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  66. package/lib/cjs/geometry4d/Map4d.d.ts +5 -5
  67. package/lib/cjs/geometry4d/Map4d.js +5 -5
  68. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  69. package/lib/cjs/geometry4d/Matrix4d.d.ts +4 -7
  70. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  71. package/lib/cjs/geometry4d/Matrix4d.js +4 -7
  72. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  73. package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
  74. package/lib/cjs/geometry4d/Point4d.js +2 -1
  75. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  76. package/lib/cjs/numerics/Newton.d.ts +3 -0
  77. package/lib/cjs/numerics/Newton.d.ts.map +1 -1
  78. package/lib/cjs/numerics/Newton.js +2 -5
  79. package/lib/cjs/numerics/Newton.js.map +1 -1
  80. package/lib/cjs/numerics/Polynomials.d.ts +46 -201
  81. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  82. package/lib/cjs/numerics/Polynomials.js +132 -445
  83. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  84. package/lib/cjs/numerics/SmallSystem.d.ts +164 -0
  85. package/lib/cjs/numerics/SmallSystem.d.ts.map +1 -0
  86. package/lib/cjs/numerics/SmallSystem.js +321 -0
  87. package/lib/cjs/numerics/SmallSystem.js.map +1 -0
  88. package/lib/cjs/polyface/PolyfaceClip.d.ts +3 -3
  89. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  90. package/lib/cjs/polyface/PolyfaceClip.js +1 -1
  91. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  92. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
  93. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
  94. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js +7 -7
  95. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  96. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  97. package/lib/cjs/topology/Graph.js +2 -2
  98. package/lib/cjs/topology/Graph.js.map +1 -1
  99. package/lib/cjs/topology/InsertAndRetriangulateContext.js +2 -2
  100. package/lib/cjs/topology/InsertAndRetriangulateContext.js.map +1 -1
  101. package/lib/cjs/topology/Merging.d.ts +1 -1
  102. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  103. package/lib/cjs/topology/Merging.js +2 -2
  104. package/lib/cjs/topology/Merging.js.map +1 -1
  105. package/lib/esm/Geometry.d.ts +2 -2
  106. package/lib/esm/Geometry.js +2 -2
  107. package/lib/esm/Geometry.js.map +1 -1
  108. package/lib/esm/clipping/ClipPrimitive.d.ts +7 -7
  109. package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
  110. package/lib/esm/clipping/ClipPrimitive.js +1 -1
  111. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  112. package/lib/esm/core-geometry.d.ts +1 -1
  113. package/lib/esm/core-geometry.d.ts.map +1 -1
  114. package/lib/esm/core-geometry.js +1 -1
  115. package/lib/esm/core-geometry.js.map +1 -1
  116. package/lib/esm/curve/Arc3d.d.ts +21 -10
  117. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  118. package/lib/esm/curve/Arc3d.js +66 -38
  119. package/lib/esm/curve/Arc3d.js.map +1 -1
  120. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +27 -8
  121. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  122. package/lib/esm/curve/CurveChainWithDistanceIndex.js +44 -25
  123. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  124. package/lib/esm/curve/CurveFactory.d.ts +11 -13
  125. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  126. package/lib/esm/curve/CurveFactory.js +17 -44
  127. package/lib/esm/curve/CurveFactory.js.map +1 -1
  128. package/lib/esm/curve/LineSegment3d.js +1 -1
  129. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  130. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  131. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +4 -3
  132. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  133. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  134. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  135. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +35 -60
  136. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  137. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
  138. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  139. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +130 -69
  140. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  141. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  142. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
  143. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  144. package/lib/esm/geometry3d/Angle.d.ts +5 -5
  145. package/lib/esm/geometry3d/Angle.js +5 -5
  146. package/lib/esm/geometry3d/Angle.js.map +1 -1
  147. package/lib/esm/geometry3d/AngleSweep.d.ts +101 -13
  148. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  149. package/lib/esm/geometry3d/AngleSweep.js +156 -57
  150. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  151. package/lib/esm/geometry3d/BilinearPatch.js +1 -1
  152. package/lib/esm/geometry3d/BilinearPatch.js.map +1 -1
  153. package/lib/esm/geometry3d/Matrix3d.d.ts +35 -31
  154. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  155. package/lib/esm/geometry3d/Matrix3d.js +55 -31
  156. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  157. package/lib/esm/geometry3d/Point3dVector3d.d.ts +6 -5
  158. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  159. package/lib/esm/geometry3d/Point3dVector3d.js +6 -5
  160. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  161. package/lib/esm/geometry3d/PolygonOps.js +2 -2
  162. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  163. package/lib/esm/geometry3d/Ray3d.js +1 -1
  164. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  165. package/lib/esm/geometry3d/Transform.d.ts +4 -2
  166. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  167. package/lib/esm/geometry3d/Transform.js +4 -2
  168. package/lib/esm/geometry3d/Transform.js.map +1 -1
  169. package/lib/esm/geometry4d/Map4d.d.ts +5 -5
  170. package/lib/esm/geometry4d/Map4d.js +5 -5
  171. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  172. package/lib/esm/geometry4d/Matrix4d.d.ts +4 -7
  173. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  174. package/lib/esm/geometry4d/Matrix4d.js +4 -7
  175. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  176. package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
  177. package/lib/esm/geometry4d/Point4d.js +2 -1
  178. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  179. package/lib/esm/numerics/Newton.d.ts +3 -0
  180. package/lib/esm/numerics/Newton.d.ts.map +1 -1
  181. package/lib/esm/numerics/Newton.js +1 -4
  182. package/lib/esm/numerics/Newton.js.map +1 -1
  183. package/lib/esm/numerics/Polynomials.d.ts +46 -201
  184. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  185. package/lib/esm/numerics/Polynomials.js +132 -444
  186. package/lib/esm/numerics/Polynomials.js.map +1 -1
  187. package/lib/esm/numerics/SmallSystem.d.ts +164 -0
  188. package/lib/esm/numerics/SmallSystem.d.ts.map +1 -0
  189. package/lib/esm/numerics/SmallSystem.js +317 -0
  190. package/lib/esm/numerics/SmallSystem.js.map +1 -0
  191. package/lib/esm/polyface/PolyfaceClip.d.ts +3 -3
  192. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  193. package/lib/esm/polyface/PolyfaceClip.js +1 -1
  194. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  195. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
  196. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
  197. package/lib/esm/polyface/multiclip/OffsetMeshContext.js +4 -4
  198. package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  199. package/lib/esm/topology/Graph.d.ts.map +1 -1
  200. package/lib/esm/topology/Graph.js +1 -1
  201. package/lib/esm/topology/Graph.js.map +1 -1
  202. package/lib/esm/topology/InsertAndRetriangulateContext.js +1 -1
  203. package/lib/esm/topology/InsertAndRetriangulateContext.js.map +1 -1
  204. package/lib/esm/topology/Merging.d.ts +1 -1
  205. package/lib/esm/topology/Merging.d.ts.map +1 -1
  206. package/lib/esm/topology/Merging.js +1 -1
  207. package/lib/esm/topology/Merging.js.map +1 -1
  208. package/package.json +7 -19
@@ -10,7 +10,7 @@ exports.Ray3d = void 0;
10
10
  */
11
11
  const CurveLocationDetail_1 = require("../curve/CurveLocationDetail");
12
12
  const Geometry_1 = require("../Geometry");
13
- const Polynomials_1 = require("../numerics/Polynomials");
13
+ const SmallSystem_1 = require("../numerics/SmallSystem");
14
14
  const Matrix3d_1 = require("./Matrix3d");
15
15
  const Point2dVector2d_1 = require("./Point2dVector2d");
16
16
  const Point3dVector3d_1 = require("./Point3dVector3d");
@@ -467,7 +467,7 @@ class Ray3d {
467
467
  let fractionA, fractionB;
468
468
  let pointA, pointB;
469
469
  let pairType;
470
- if (Polynomials_1.SmallSystem.ray3dXYZUVWClosestApproachUnbounded(rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z, rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z, intersectionFractions)) {
470
+ if (SmallSystem_1.SmallSystem.ray3dXYZUVWClosestApproachUnbounded(rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z, rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z, intersectionFractions)) {
471
471
  fractionA = intersectionFractions.x;
472
472
  fractionB = intersectionFractions.y;
473
473
  pointA = rayA.fractionToPoint(fractionA);
@@ -1 +1 @@
1
- {"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sEAAoH;AACpH,0CAAmE;AACnE,yDAAsD;AACtD,yCAAsC;AAEtC,uDAA6C;AAC7C,uDAAsD;AACtD,mCAA2C;AAC3C,2CAAwC;AAGxC,qBAAqB;AACrB;;;;;;GAMG;AACH,MAAa,KAAK;IAahB,oCAAoC;IACpC,YAAoB,MAAe,EAAE,SAAmB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,CAAC,GA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AAC;CACF;AAphBD,sBAohBC","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\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n// cspell:word Cramer\r\n/**\r\n * A Ray3d contains\r\n * * an `origin` point.\r\n * * a `direction` vector (The vector is not required to be normalized).\r\n * * an optional weight (number).\r\n * @public\r\n */\r\nexport class Ray3d implements BeJSONFunctions {\r\n /** The ray origin */\r\n public origin: Point3d;\r\n /** The ray direction. This is commonly (but not always) a unit vector. */\r\n public direction: Vector3d;\r\n /** Numeric annotation. */\r\n public a?: number; // optional (e.g. weight)\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workVector2?: Vector3d;\r\n private static _workVector3?: Vector3d;\r\n private static _workVector4?: Vector3d;\r\n private static _workMatrix?: Matrix3d;\r\n // constructor (captures references)\r\n private constructor(origin: Point3d, direction: Vector3d) {\r\n this.origin = origin;\r\n this.direction = direction;\r\n this.a = undefined;\r\n }\r\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\r\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\r\n }\r\n /** Create a ray on the x axis. */\r\n public static createXAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 1, 0, 0);\r\n }\r\n /** Create a ray on the y axis. */\r\n public static createYAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 1, 0);\r\n }\r\n /** Create a ray on the z axis. */\r\n public static createZAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 0, 1);\r\n }\r\n /** Create a ray with all zeros. */\r\n public static createZero(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setZero();\r\n result.direction.setZero();\r\n return result;\r\n }\r\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\r\n }\r\n /**\r\n * Test for nearly equal Ray3d objects.\r\n * * This tests for near equality of origin and direction -- i.e. member-by-member comparison.\r\n * * Use [[isAlmostEqualPointSet]] to allow origins to be anywhere along the common ray and to have to allow the\r\n * directions to be scaled or opposing.\r\n */\r\n public isAlmostEqual(other: Ray3d): boolean {\r\n return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);\r\n }\r\n /**\r\n * Return the dot product of the ray's direction vector with a vector from the ray origin\r\n * to the `spacePoint`.\r\n * * If the instance is the unit normal of a plane, then this method returns the (signed) altitude\r\n * of `spacePoint` with respect to the plane.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane\r\n */\r\n public dotProductToPoint(spacePoint: Point3d): number {\r\n return this.direction.dotProductStartEnd(this.origin, spacePoint);\r\n }\r\n /** Return the fractional coordinate (along the direction vector) of the `spacePoint` projected to the ray. */\r\n public pointToFraction(spacePoint: Point3d): number {\r\n return Geometry.safeDivideFraction(\r\n this.dotProductToPoint(spacePoint),\r\n this.direction.magnitudeSquared(),\r\n 0,\r\n );\r\n }\r\n /** Return the `spacePoint` projected onto the ray. */\r\n public projectPointToRay(spacePoint: Point3d): Point3d {\r\n /**\r\n * To project a point to the ray, we can create a vector called \"v\" from ray origin to the spacePoint and project\r\n * that vector to the ray direction vector \"r\". The projection is \"((v.r)/||r||^2) r\" where \"v.r\" is the dot\r\n * product. Note that pointToFraction returns \"(v.r)/||r||^2\".\r\n * Note: If r is the normal of a plane, then projection length \"(v.r)/||r||\" is the signed altitude of the\r\n * spacePoint with respect to the plane.\r\n */\r\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\r\n }\r\n /**\r\n * Test for nearly equal rays, allowing origin float and direction scaling.\r\n * * Use [[isAlmostEqual]] to require member-by-member comparison.\r\n */\r\n public isAlmostEqualPointSet(other: Ray3d): boolean {\r\n /**\r\n * This function tests two rays to determine if they define the same infinite lines.\r\n * So the origins can be different as long as they are on the infinite line (they can\r\n * \"float\") but the directions must be parallel or antiparallel.\r\n */\r\n if (!this.direction.isParallelTo(other.direction, true))\r\n return false;\r\n /**\r\n * In exact math, we consider a ray to have an infinite line as direction (not a finite vector).\r\n * Therefore, in exact math it is not possible for one origin to be on the other ray but not vice\r\n * versa. However, we test both ways because first check may pass due to round-off errors.\r\n */\r\n let workPoint = this.projectPointToRay(other.origin);\r\n if (!other.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n workPoint = other.projectPointToRay(this.origin);\r\n if (!this.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n return true;\r\n }\r\n /** Create a ray from origin and direction. */\r\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(origin, direction);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), direction.clone());\r\n }\r\n /**\r\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian\r\n * coordinates and derivatives.\r\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\r\n * @param weightedDerivative `[x,y,z,w]` derivatives\r\n * @param result\r\n */\r\n public static createWeightedDerivative(\r\n weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d,\r\n ): Ray3d | undefined {\r\n const w = weightedPoint[3];\r\n const dw = weightedDerivative[3];\r\n const x = weightedPoint[0];\r\n const y = weightedPoint[1];\r\n const z = weightedPoint[2];\r\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\r\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\r\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\r\n if (Geometry.isSmallMetricDistance(w))\r\n return undefined;\r\n const divW = 1.0 / w;\r\n const divWW = divW * divW;\r\n return Ray3d.createXYZUVW(\r\n x * divW, y * divW, z * divW,\r\n dx * divWW, dy * divWW, dz * divWW,\r\n result,\r\n );\r\n }\r\n /** Create from coordinates of the origin and direction. */\r\n public static createXYZUVW(\r\n originX: number, originY: number, originZ: number,\r\n directionX: number, directionY: number, directionZ: number,\r\n result?: Ray3d,\r\n ): Ray3d {\r\n if (result) {\r\n result.getOriginRef().set(originX, originY, originZ);\r\n result.getDirectionRef().set(directionX, directionY, directionZ);\r\n return result;\r\n }\r\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\r\n }\r\n /** Capture origin and direction in a new Ray3d. */\r\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\r\n return new Ray3d(origin, direction);\r\n }\r\n /** Create from (clones of) origin, direction, and numeric weight. */\r\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setFrom(direction);\r\n result.a = a;\r\n return result;\r\n }\r\n result = new Ray3d(origin.clone(), direction.clone());\r\n result.a = a;\r\n return result;\r\n }\r\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\r\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setStartEnd(origin, target);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\r\n }\r\n /** Return a reference to the ray's origin. */\r\n public getOriginRef(): Point3d {\r\n return this.origin;\r\n }\r\n /** Return a reference to the ray's direction vector. */\r\n public getDirectionRef(): Vector3d {\r\n return this.direction;\r\n }\r\n /** Copy coordinates from origin and direction. */\r\n public set(origin: Point3d, direction: Vector3d): void {\r\n this.origin.setFrom(origin);\r\n this.direction.setFrom(direction);\r\n }\r\n /** Clone the ray. */\r\n public clone(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(this.origin.clone(), this.direction.clone());\r\n return result;\r\n }\r\n return new Ray3d(this.origin.clone(), this.direction.clone());\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: Ray3d): Ray3d {\r\n return Ray3d.create(\r\n transform.multiplyPoint3d(this.origin, result?.origin),\r\n transform.multiplyVector(this.direction, result?.direction),\r\n result,\r\n );\r\n }\r\n /** Create a clone and return the inverse transform of the clone. */\r\n public cloneInverseTransformed(transform: Transform, result?: Ray3d): Ray3d | undefined {\r\n if (!transform.computeCachedInverse(true))\r\n return undefined;\r\n return Ray3d.create(\r\n transform.multiplyInversePoint3d(this.origin, result?.origin)!,\r\n transform.matrix.multiplyInverseXYZAsVector3d(\r\n this.direction.x, this.direction.y, this.direction.z, result?.direction,\r\n )!,\r\n result,\r\n );\r\n }\r\n /** Apply a transform in place. */\r\n public transformInPlace(transform: Transform) {\r\n transform.multiplyPoint3d(this.origin, this.origin);\r\n transform.multiplyVector(this.direction, this.direction);\r\n }\r\n /** Copy data from another ray. */\r\n public setFrom(source: Ray3d): void {\r\n this.set(source.origin, source.direction);\r\n }\r\n /**\r\n * Return a point at fractional position along the ray.\r\n * * fraction 0 is the ray origin.\r\n * * fraction 1 is at the end of the direction vector when placed at the origin.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.origin.plusScaled(this.direction, fraction, result);\r\n }\r\n /**\r\n * Return a transform for rigid axes at ray origin with z in ray direction.\r\n * * If the direction vector is zero, axes default to identity (from [[Matrix3d.createRigidHeadsUp]])\r\n */\r\n public toRigidZFrame(result?: Transform): Transform {\r\n const axes = Ray3d._workMatrix = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY, Ray3d._workMatrix);\r\n return Transform.createOriginAndMatrix(this.origin, axes, result);\r\n }\r\n /** Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d. */\r\n public setFromJSON(json?: any) {\r\n if (!json) {\r\n this.origin.set(0, 0, 0);\r\n this.direction.set(0, 0, 1);\r\n return;\r\n }\r\n this.origin.setFromJSON(json.origin);\r\n this.direction.setFromJSON(json.direction);\r\n }\r\n /**\r\n * Construct a JSON object from this Ray3d.\r\n * @return {*} [origin,normal]\r\n */\r\n public toJSON(): any {\r\n return { origin: this.origin.toJSON(), direction: this.direction.toJSON() };\r\n }\r\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\r\n public static fromJSON(json?: any) {\r\n const result = Ray3d.createXAxis();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /**\r\n * Try to scale the direction vector to a given `magnitude`.\r\n * * Returns `false` if the ray direction is a zero vector.\r\n */\r\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\r\n if (this.direction.tryNormalizeInPlace()) {\r\n this.direction.scaleInPlace(magnitude);\r\n return true;\r\n }\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * Normalize the ray direction in place.\r\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\r\n * * Save the parameter `a` as the optional `a` member of the ray.\r\n * * Normalize the ray's direction vector.\r\n * * If parameter `a` is nearly zero,\r\n * * Set the `a` member to zero.\r\n * * Set the ray's direction vector to zero.\r\n * @param a value to be saved (e.g,. area).\r\n * @returns `true` if `a` is nonzero and normalization was successful. Otherwise, return `false`.\r\n */\r\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\r\n const tolerance = Geometry.smallMetricDistanceSquared;\r\n this.a = a;\r\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\r\n return true;\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /** Return distance from the ray to point in space. */\r\n public distance(spacePoint: Point3d): number {\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.dotProductToPoint(spacePoint);\r\n const aa = Geometry.inverseMetricDistanceSquared(uu);\r\n if (aa)\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\r\n else\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\r\n }\r\n /**\r\n * Return the intersection parameter of the line defined by the ray with a `plane`.\r\n * * Stores the point of intersection in the `result` point (if passed as a parameter) and returns the parameter\r\n * along the ray where the intersection occurs. If we call the parameter 'f' then the point of intersection would\r\n * be `ray.origin + f * ray.direction`. Therefore:\r\n * * if ray intersects the plane at its origin, the function returns f = 0.\r\n * * if intersects at `ray.origin + ray.direction`, the function returns f = 1.\r\n * * if intersects behind the ray origin, the function returns f < 0.\r\n * * if intersects after `ray.origin + ray.direction`, the function returns f > 1.\r\n * * Returns `undefined` if the ray and plane are parallel or coplanar.\r\n */\r\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\r\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\r\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\r\n const nDotN = this.direction.magnitudeSquared();\r\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\r\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\r\n if (undefined === division)\r\n return undefined;\r\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\r\n if (undefined === division1)\r\n return undefined;\r\n if (result) {\r\n this.origin.plusScaled(this.direction, division, result);\r\n }\r\n return division;\r\n }\r\n /**\r\n * Find the intersection of the line defined by the ray with a Range3d.\r\n * * Return the range of parameters (on the ray) which are \"inside\" the range.\r\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.isNull`.\r\n */\r\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\r\n if (range.isNull)\r\n return Range1d.createNull(result);\r\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\r\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\r\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\r\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z)\r\n )\r\n return interval;\r\n return interval;\r\n }\r\n /**\r\n * Compute the intersection of the ray with a triangle.\r\n * * This method is faster than `BarycentricTriangle.intersectRay3d`.\r\n * @param vertex0 first vertex of the triangle\r\n * @param vertex1 second vertex of the triangle\r\n * @param vertex2 third vertex of the triangle\r\n * @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line\r\n * intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)\r\n * @param parameterTol optional tolerance used to snap barycentric coordinates of the intersection point to\r\n * a triangle edge or vertex (if tolerance is not provided, Geometry.smallFloatingPoint is used)\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.\r\n */\r\n public intersectionWithTriangle(\r\n vertex0: Point3d, vertex1: Point3d, vertex2: Point3d, distanceTol?: number, parameterTol?: number, result?: Point3d,\r\n ): Point3d | undefined {\r\n /**\r\n * Suppose ray is shown by \"rayOrigin + t*rayVector\" and barycentric coordinate of point\r\n * P = w*v0 + u*v1 + v*v2 = (1-u-v)*v0 + u*v1 + v*v2 = v0 + u*(v1-v0) + v*(v2-v0)\r\n *\r\n * Then if ray intersects triangle at a point we have\r\n * v0 + u*(v1-v0) + v*(v2-v0) = rayOrigin + t*rayVector\r\n * or\r\n * -t*rayVector + u*(v1-v0) + v*(v2-v0) = rayOrigin - v0\r\n *\r\n * This equation can be reformulated as the following linear system:\r\n *\r\n * [ | | | ] [t] [ | ]\r\n * [-rayVector v1-v0 v2-v0] [u] = [rayOrigin - v0]\r\n * [ | | | ] [v] [ | ]\r\n *\r\n * Then to find t, u, and v use Cramer's Rule and also the fact that if matrix A = [c1,c2,c3], then\r\n * det(A) = c1.(c2 x c3) which leads to\r\n *\r\n * t = [(rayOrigin - v0).((v1-v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * u = [-rayVector.((rayOrigin - v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * v = [-rayVector.((v1-v0) x (rayOrigin - v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n *\r\n * Now note that swapping any 2 vectors c_i and c_j in formula c1.(c2 x c3) negates it. For example:\r\n * c1.(c2 x c3) = -c3.(c2 x c1) = c2.(c3 x c1)\r\n *\r\n * This leads to the final formulas used in the following code:\r\n * t = [(v2-v0).((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * u = [(rayOrigin - v0).(rayVector x (v2-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * v = [-rayVector.((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n *\r\n * Note that we should verify 0 <= u,v,w <= 1. To do so we only need to check 0 <= u <= 1, 0 <= v, and u+v <= 1.\r\n * That's because w = 1-(u+v) and if we have those 4 checks, it's guaranteed that v <= 1 and 0 <= u+v and so\r\n * 0 <= w <= 1.\r\n *\r\n * More info be found at\r\n * https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm\r\n */\r\n if (distanceTol === undefined || distanceTol < 0) // we explicitly allow zero tolerance\r\n distanceTol = Geometry.smallMetricDistance;\r\n if (parameterTol === undefined || parameterTol < 0) // we explicitly allow zero tolerance\r\n parameterTol = Geometry.smallFloatingPoint;\r\n const edge1 = Ray3d._workVector0 = Vector3d.createStartEnd(vertex0, vertex1, Ray3d._workVector0);\r\n const edge2 = Ray3d._workVector1 = Vector3d.createStartEnd(vertex0, vertex2, Ray3d._workVector1);\r\n const h = Ray3d._workVector2 = this.direction.crossProduct(edge2, Ray3d._workVector2);\r\n const a = edge1.dotProduct(h);\r\n if (a >= -distanceTol && a <= distanceTol)\r\n return undefined; // ray is parallel to the triangle (includes coplanar case)\r\n const f = 1.0 / a;\r\n const s = Ray3d._workVector3 = Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);\r\n let u = f * s.dotProduct(h);\r\n if (u < 0.0) {\r\n if (u > -parameterTol)\r\n u = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u > 1.0) {\r\n if (u < 1.0 + parameterTol)\r\n u = 1.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);\r\n let v = f * this.direction.dotProduct(q);\r\n if (v < 0.0) {\r\n if (v > -parameterTol)\r\n v = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u + v > 1.0) {\r\n if (u + v < 1.0 + parameterTol)\r\n v = 1.0 - u;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n // at this stage, we know the line (parameterized as the ray) intersects the triangle\r\n const t = f * edge2.dotProduct(q);\r\n if (t <= distanceTol) // line intersection but not ray intersection\r\n return undefined;\r\n return this.origin.plusScaled(this.direction, t, result); // ray intersection\r\n }\r\n /**\r\n * Return the shortest vector `v` to `targetPoint` from the line defined by this ray.\r\n * * If the projection of `targetPoint` onto the line defined by this ray is q, then `v  = targetPoint - q`.\r\n */\r\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\r\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\r\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\r\n return vectorV.plusScaled(this.direction, -fraction, result);\r\n }\r\n /**\r\n * Determine if two rays intersect, or are fully overlapped, or parallel but not coincident, or skew.\r\n * * Return a CurveLocationDetailPair which contains fraction and point on each ray and has\r\n * annotation (in member `approachType`) indicating one of these relationships:\r\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated\r\n * in detailA and detailB\r\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach.\r\n * The rays are skew in space.\r\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The\r\n * fractions and points are a representative single common point.\r\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are\r\n * at the minimum distance\r\n */\r\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\r\n const intersectionFractions = Vector2d.create();\r\n let fractionA, fractionB;\r\n let pointA, pointB;\r\n let pairType;\r\n if (\r\n SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\r\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\r\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z,\r\n intersectionFractions,\r\n )\r\n ) {\r\n fractionA = intersectionFractions.x;\r\n fractionB = intersectionFractions.y;\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\r\n } else {\r\n fractionB = 0.0;\r\n fractionA = rayA.pointToFraction(rayB.origin);\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\r\n }\r\n const pair = CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\r\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\r\n pair.approachType = pairType;\r\n return pair;\r\n }\r\n /**\r\n * Return a ray with `ray.origin` interpolated between `pt1` and `pt2` at the given `fraction`\r\n * and `ray.direction` set to the vector from `pt1` to `pt2` multiplied by the given `tangentScale`.\r\n * @param pt1 start point of the interpolation.\r\n * @param fraction fractional position between points.\r\n * @param pt2 end point of the interpolation.\r\n * @param tangentScale scale factor to apply to the startToEnd vector.\r\n * @param result optional receiver.\r\n */\r\n public static interpolatePointAndTangent(\r\n pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d,\r\n ): Ray3d {\r\n result = result ?? Ray3d.createZero();\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n const dz = pt2.z - pt1.z;\r\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\r\n if (fraction <= 0.5)\r\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\r\n else {\r\n const t: number = fraction - 1.0;\r\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sEAAoH;AACpH,0CAAmE;AACnE,yDAAsD;AACtD,yCAAsC;AAEtC,uDAA6C;AAC7C,uDAAsD;AACtD,mCAA2C;AAC3C,2CAAwC;AAGxC,qBAAqB;AACrB;;;;;;GAMG;AACH,MAAa,KAAK;IAahB,oCAAoC;IACpC,YAAoB,MAAe,EAAE,SAAmB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACrB,CAAC;IACO,MAAM,CAAC,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QACrF,OAAO,I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AAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD;;;;;;;;OAQG;IACI,MAAM,CAAC,0BAA0B,CACtC,GAAW,EAAE,QAAgB,EAAE,GAAW,EAAE,YAAoB,EAAE,MAAc;QAEhF,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACtC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,CAAC,CAAC;QAC9E,IAAI,QAAQ,IAAI,GAAG;YACjB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAC,CAAC;aACpF,CAAC;YACJ,MAAM,CAAC,GAAW,QAAQ,GAAG,GAAG,CAAC;YACjC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAphBD,sBAohBC","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\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/SmallSystem\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n// cspell:word Cramer\r\n/**\r\n * A Ray3d contains\r\n * * an `origin` point.\r\n * * a `direction` vector (The vector is not required to be normalized).\r\n * * an optional weight (number).\r\n * @public\r\n */\r\nexport class Ray3d implements BeJSONFunctions {\r\n /** The ray origin */\r\n public origin: Point3d;\r\n /** The ray direction. This is commonly (but not always) a unit vector. */\r\n public direction: Vector3d;\r\n /** Numeric annotation. */\r\n public a?: number; // optional (e.g. weight)\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workVector2?: Vector3d;\r\n private static _workVector3?: Vector3d;\r\n private static _workVector4?: Vector3d;\r\n private static _workMatrix?: Matrix3d;\r\n // constructor (captures references)\r\n private constructor(origin: Point3d, direction: Vector3d) {\r\n this.origin = origin;\r\n this.direction = direction;\r\n this.a = undefined;\r\n }\r\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\r\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\r\n }\r\n /** Create a ray on the x axis. */\r\n public static createXAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 1, 0, 0);\r\n }\r\n /** Create a ray on the y axis. */\r\n public static createYAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 1, 0);\r\n }\r\n /** Create a ray on the z axis. */\r\n public static createZAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 0, 1);\r\n }\r\n /** Create a ray with all zeros. */\r\n public static createZero(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setZero();\r\n result.direction.setZero();\r\n return result;\r\n }\r\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\r\n }\r\n /**\r\n * Test for nearly equal Ray3d objects.\r\n * * This tests for near equality of origin and direction -- i.e. member-by-member comparison.\r\n * * Use [[isAlmostEqualPointSet]] to allow origins to be anywhere along the common ray and to have to allow the\r\n * directions to be scaled or opposing.\r\n */\r\n public isAlmostEqual(other: Ray3d): boolean {\r\n return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);\r\n }\r\n /**\r\n * Return the dot product of the ray's direction vector with a vector from the ray origin\r\n * to the `spacePoint`.\r\n * * If the instance is the unit normal of a plane, then this method returns the (signed) altitude\r\n * of `spacePoint` with respect to the plane.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane\r\n */\r\n public dotProductToPoint(spacePoint: Point3d): number {\r\n return this.direction.dotProductStartEnd(this.origin, spacePoint);\r\n }\r\n /** Return the fractional coordinate (along the direction vector) of the `spacePoint` projected to the ray. */\r\n public pointToFraction(spacePoint: Point3d): number {\r\n return Geometry.safeDivideFraction(\r\n this.dotProductToPoint(spacePoint),\r\n this.direction.magnitudeSquared(),\r\n 0,\r\n );\r\n }\r\n /** Return the `spacePoint` projected onto the ray. */\r\n public projectPointToRay(spacePoint: Point3d): Point3d {\r\n /**\r\n * To project a point to the ray, we can create a vector called \"v\" from ray origin to the spacePoint and project\r\n * that vector to the ray direction vector \"r\". The projection is \"((v.r)/||r||^2) r\" where \"v.r\" is the dot\r\n * product. Note that pointToFraction returns \"(v.r)/||r||^2\".\r\n * Note: If r is the normal of a plane, then projection length \"(v.r)/||r||\" is the signed altitude of the\r\n * spacePoint with respect to the plane.\r\n */\r\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\r\n }\r\n /**\r\n * Test for nearly equal rays, allowing origin float and direction scaling.\r\n * * Use [[isAlmostEqual]] to require member-by-member comparison.\r\n */\r\n public isAlmostEqualPointSet(other: Ray3d): boolean {\r\n /**\r\n * This function tests two rays to determine if they define the same infinite lines.\r\n * So the origins can be different as long as they are on the infinite line (they can\r\n * \"float\") but the directions must be parallel or antiparallel.\r\n */\r\n if (!this.direction.isParallelTo(other.direction, true))\r\n return false;\r\n /**\r\n * In exact math, we consider a ray to have an infinite line as direction (not a finite vector).\r\n * Therefore, in exact math it is not possible for one origin to be on the other ray but not vice\r\n * versa. However, we test both ways because first check may pass due to round-off errors.\r\n */\r\n let workPoint = this.projectPointToRay(other.origin);\r\n if (!other.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n workPoint = other.projectPointToRay(this.origin);\r\n if (!this.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n return true;\r\n }\r\n /** Create a ray from origin and direction. */\r\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(origin, direction);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), direction.clone());\r\n }\r\n /**\r\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian\r\n * coordinates and derivatives.\r\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\r\n * @param weightedDerivative `[x,y,z,w]` derivatives\r\n * @param result\r\n */\r\n public static createWeightedDerivative(\r\n weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d,\r\n ): Ray3d | undefined {\r\n const w = weightedPoint[3];\r\n const dw = weightedDerivative[3];\r\n const x = weightedPoint[0];\r\n const y = weightedPoint[1];\r\n const z = weightedPoint[2];\r\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\r\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\r\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\r\n if (Geometry.isSmallMetricDistance(w))\r\n return undefined;\r\n const divW = 1.0 / w;\r\n const divWW = divW * divW;\r\n return Ray3d.createXYZUVW(\r\n x * divW, y * divW, z * divW,\r\n dx * divWW, dy * divWW, dz * divWW,\r\n result,\r\n );\r\n }\r\n /** Create from coordinates of the origin and direction. */\r\n public static createXYZUVW(\r\n originX: number, originY: number, originZ: number,\r\n directionX: number, directionY: number, directionZ: number,\r\n result?: Ray3d,\r\n ): Ray3d {\r\n if (result) {\r\n result.getOriginRef().set(originX, originY, originZ);\r\n result.getDirectionRef().set(directionX, directionY, directionZ);\r\n return result;\r\n }\r\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\r\n }\r\n /** Capture origin and direction in a new Ray3d. */\r\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\r\n return new Ray3d(origin, direction);\r\n }\r\n /** Create from (clones of) origin, direction, and numeric weight. */\r\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setFrom(direction);\r\n result.a = a;\r\n return result;\r\n }\r\n result = new Ray3d(origin.clone(), direction.clone());\r\n result.a = a;\r\n return result;\r\n }\r\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\r\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setStartEnd(origin, target);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\r\n }\r\n /** Return a reference to the ray's origin. */\r\n public getOriginRef(): Point3d {\r\n return this.origin;\r\n }\r\n /** Return a reference to the ray's direction vector. */\r\n public getDirectionRef(): Vector3d {\r\n return this.direction;\r\n }\r\n /** Copy coordinates from origin and direction. */\r\n public set(origin: Point3d, direction: Vector3d): void {\r\n this.origin.setFrom(origin);\r\n this.direction.setFrom(direction);\r\n }\r\n /** Clone the ray. */\r\n public clone(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(this.origin.clone(), this.direction.clone());\r\n return result;\r\n }\r\n return new Ray3d(this.origin.clone(), this.direction.clone());\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: Ray3d): Ray3d {\r\n return Ray3d.create(\r\n transform.multiplyPoint3d(this.origin, result?.origin),\r\n transform.multiplyVector(this.direction, result?.direction),\r\n result,\r\n );\r\n }\r\n /** Create a clone and return the inverse transform of the clone. */\r\n public cloneInverseTransformed(transform: Transform, result?: Ray3d): Ray3d | undefined {\r\n if (!transform.computeCachedInverse(true))\r\n return undefined;\r\n return Ray3d.create(\r\n transform.multiplyInversePoint3d(this.origin, result?.origin)!,\r\n transform.matrix.multiplyInverseXYZAsVector3d(\r\n this.direction.x, this.direction.y, this.direction.z, result?.direction,\r\n )!,\r\n result,\r\n );\r\n }\r\n /** Apply a transform in place. */\r\n public transformInPlace(transform: Transform) {\r\n transform.multiplyPoint3d(this.origin, this.origin);\r\n transform.multiplyVector(this.direction, this.direction);\r\n }\r\n /** Copy data from another ray. */\r\n public setFrom(source: Ray3d): void {\r\n this.set(source.origin, source.direction);\r\n }\r\n /**\r\n * Return a point at fractional position along the ray.\r\n * * fraction 0 is the ray origin.\r\n * * fraction 1 is at the end of the direction vector when placed at the origin.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.origin.plusScaled(this.direction, fraction, result);\r\n }\r\n /**\r\n * Return a transform for rigid axes at ray origin with z in ray direction.\r\n * * If the direction vector is zero, axes default to identity (from [[Matrix3d.createRigidHeadsUp]])\r\n */\r\n public toRigidZFrame(result?: Transform): Transform {\r\n const axes = Ray3d._workMatrix = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY, Ray3d._workMatrix);\r\n return Transform.createOriginAndMatrix(this.origin, axes, result);\r\n }\r\n /** Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d. */\r\n public setFromJSON(json?: any) {\r\n if (!json) {\r\n this.origin.set(0, 0, 0);\r\n this.direction.set(0, 0, 1);\r\n return;\r\n }\r\n this.origin.setFromJSON(json.origin);\r\n this.direction.setFromJSON(json.direction);\r\n }\r\n /**\r\n * Construct a JSON object from this Ray3d.\r\n * @return {*} [origin,normal]\r\n */\r\n public toJSON(): any {\r\n return { origin: this.origin.toJSON(), direction: this.direction.toJSON() };\r\n }\r\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\r\n public static fromJSON(json?: any) {\r\n const result = Ray3d.createXAxis();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /**\r\n * Try to scale the direction vector to a given `magnitude`.\r\n * * Returns `false` if the ray direction is a zero vector.\r\n */\r\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\r\n if (this.direction.tryNormalizeInPlace()) {\r\n this.direction.scaleInPlace(magnitude);\r\n return true;\r\n }\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * Normalize the ray direction in place.\r\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\r\n * * Save the parameter `a` as the optional `a` member of the ray.\r\n * * Normalize the ray's direction vector.\r\n * * If parameter `a` is nearly zero,\r\n * * Set the `a` member to zero.\r\n * * Set the ray's direction vector to zero.\r\n * @param a value to be saved (e.g,. area).\r\n * @returns `true` if `a` is nonzero and normalization was successful. Otherwise, return `false`.\r\n */\r\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\r\n const tolerance = Geometry.smallMetricDistanceSquared;\r\n this.a = a;\r\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\r\n return true;\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /** Return distance from the ray to point in space. */\r\n public distance(spacePoint: Point3d): number {\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.dotProductToPoint(spacePoint);\r\n const aa = Geometry.inverseMetricDistanceSquared(uu);\r\n if (aa)\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\r\n else\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\r\n }\r\n /**\r\n * Return the intersection parameter of the line defined by the ray with a `plane`.\r\n * * Stores the point of intersection in the `result` point (if passed as a parameter) and returns the parameter\r\n * along the ray where the intersection occurs. If we call the parameter 'f' then the point of intersection would\r\n * be `ray.origin + f * ray.direction`. Therefore:\r\n * * if ray intersects the plane at its origin, the function returns f = 0.\r\n * * if intersects at `ray.origin + ray.direction`, the function returns f = 1.\r\n * * if intersects behind the ray origin, the function returns f < 0.\r\n * * if intersects after `ray.origin + ray.direction`, the function returns f > 1.\r\n * * Returns `undefined` if the ray and plane are parallel or coplanar.\r\n */\r\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\r\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\r\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\r\n const nDotN = this.direction.magnitudeSquared();\r\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\r\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\r\n if (undefined === division)\r\n return undefined;\r\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\r\n if (undefined === division1)\r\n return undefined;\r\n if (result) {\r\n this.origin.plusScaled(this.direction, division, result);\r\n }\r\n return division;\r\n }\r\n /**\r\n * Find the intersection of the line defined by the ray with a Range3d.\r\n * * Return the range of parameters (on the ray) which are \"inside\" the range.\r\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.isNull`.\r\n */\r\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\r\n if (range.isNull)\r\n return Range1d.createNull(result);\r\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\r\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\r\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\r\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z)\r\n )\r\n return interval;\r\n return interval;\r\n }\r\n /**\r\n * Compute the intersection of the ray with a triangle.\r\n * * This method is faster than `BarycentricTriangle.intersectRay3d`.\r\n * @param vertex0 first vertex of the triangle\r\n * @param vertex1 second vertex of the triangle\r\n * @param vertex2 third vertex of the triangle\r\n * @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line\r\n * intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)\r\n * @param parameterTol optional tolerance used to snap barycentric coordinates of the intersection point to\r\n * a triangle edge or vertex (if tolerance is not provided, Geometry.smallFloatingPoint is used)\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.\r\n */\r\n public intersectionWithTriangle(\r\n vertex0: Point3d, vertex1: Point3d, vertex2: Point3d, distanceTol?: number, parameterTol?: number, result?: Point3d,\r\n ): Point3d | undefined {\r\n /**\r\n * Suppose ray is shown by \"rayOrigin + t*rayVector\" and barycentric coordinate of point\r\n * P = w*v0 + u*v1 + v*v2 = (1-u-v)*v0 + u*v1 + v*v2 = v0 + u*(v1-v0) + v*(v2-v0)\r\n *\r\n * Then if ray intersects triangle at a point we have\r\n * v0 + u*(v1-v0) + v*(v2-v0) = rayOrigin + t*rayVector\r\n * or\r\n * -t*rayVector + u*(v1-v0) + v*(v2-v0) = rayOrigin - v0\r\n *\r\n * This equation can be reformulated as the following linear system:\r\n *\r\n * [ | | | ] [t] [ | ]\r\n * [-rayVector v1-v0 v2-v0] [u] = [rayOrigin - v0]\r\n * [ | | | ] [v] [ | ]\r\n *\r\n * Then to find t, u, and v use Cramer's Rule and also the fact that if matrix A = [c1,c2,c3], then\r\n * det(A) = c1.(c2 x c3) which leads to\r\n *\r\n * t = [(rayOrigin - v0).((v1-v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * u = [-rayVector.((rayOrigin - v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * v = [-rayVector.((v1-v0) x (rayOrigin - v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n *\r\n * Now note that swapping any 2 vectors c_i and c_j in formula c1.(c2 x c3) negates it. For example:\r\n * c1.(c2 x c3) = -c3.(c2 x c1) = c2.(c3 x c1)\r\n *\r\n * This leads to the final formulas used in the following code:\r\n * t = [(v2-v0).((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * u = [(rayOrigin - v0).(rayVector x (v2-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * v = [-rayVector.((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n *\r\n * Note that we should verify 0 <= u,v,w <= 1. To do so we only need to check 0 <= u <= 1, 0 <= v, and u+v <= 1.\r\n * That's because w = 1-(u+v) and if we have those 4 checks, it's guaranteed that v <= 1 and 0 <= u+v and so\r\n * 0 <= w <= 1.\r\n *\r\n * More info be found at\r\n * https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm\r\n */\r\n if (distanceTol === undefined || distanceTol < 0) // we explicitly allow zero tolerance\r\n distanceTol = Geometry.smallMetricDistance;\r\n if (parameterTol === undefined || parameterTol < 0) // we explicitly allow zero tolerance\r\n parameterTol = Geometry.smallFloatingPoint;\r\n const edge1 = Ray3d._workVector0 = Vector3d.createStartEnd(vertex0, vertex1, Ray3d._workVector0);\r\n const edge2 = Ray3d._workVector1 = Vector3d.createStartEnd(vertex0, vertex2, Ray3d._workVector1);\r\n const h = Ray3d._workVector2 = this.direction.crossProduct(edge2, Ray3d._workVector2);\r\n const a = edge1.dotProduct(h);\r\n if (a >= -distanceTol && a <= distanceTol)\r\n return undefined; // ray is parallel to the triangle (includes coplanar case)\r\n const f = 1.0 / a;\r\n const s = Ray3d._workVector3 = Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);\r\n let u = f * s.dotProduct(h);\r\n if (u < 0.0) {\r\n if (u > -parameterTol)\r\n u = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u > 1.0) {\r\n if (u < 1.0 + parameterTol)\r\n u = 1.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);\r\n let v = f * this.direction.dotProduct(q);\r\n if (v < 0.0) {\r\n if (v > -parameterTol)\r\n v = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u + v > 1.0) {\r\n if (u + v < 1.0 + parameterTol)\r\n v = 1.0 - u;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n // at this stage, we know the line (parameterized as the ray) intersects the triangle\r\n const t = f * edge2.dotProduct(q);\r\n if (t <= distanceTol) // line intersection but not ray intersection\r\n return undefined;\r\n return this.origin.plusScaled(this.direction, t, result); // ray intersection\r\n }\r\n /**\r\n * Return the shortest vector `v` to `targetPoint` from the line defined by this ray.\r\n * * If the projection of `targetPoint` onto the line defined by this ray is q, then `v  = targetPoint - q`.\r\n */\r\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\r\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\r\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\r\n return vectorV.plusScaled(this.direction, -fraction, result);\r\n }\r\n /**\r\n * Determine if two rays intersect, or are fully overlapped, or parallel but not coincident, or skew.\r\n * * Return a CurveLocationDetailPair which contains fraction and point on each ray and has\r\n * annotation (in member `approachType`) indicating one of these relationships:\r\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated\r\n * in detailA and detailB\r\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach.\r\n * The rays are skew in space.\r\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The\r\n * fractions and points are a representative single common point.\r\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are\r\n * at the minimum distance\r\n */\r\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\r\n const intersectionFractions = Vector2d.create();\r\n let fractionA, fractionB;\r\n let pointA, pointB;\r\n let pairType;\r\n if (\r\n SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\r\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\r\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z,\r\n intersectionFractions,\r\n )\r\n ) {\r\n fractionA = intersectionFractions.x;\r\n fractionB = intersectionFractions.y;\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\r\n } else {\r\n fractionB = 0.0;\r\n fractionA = rayA.pointToFraction(rayB.origin);\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\r\n }\r\n const pair = CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\r\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\r\n pair.approachType = pairType;\r\n return pair;\r\n }\r\n /**\r\n * Return a ray with `ray.origin` interpolated between `pt1` and `pt2` at the given `fraction`\r\n * and `ray.direction` set to the vector from `pt1` to `pt2` multiplied by the given `tangentScale`.\r\n * @param pt1 start point of the interpolation.\r\n * @param fraction fractional position between points.\r\n * @param pt2 end point of the interpolation.\r\n * @param tangentScale scale factor to apply to the startToEnd vector.\r\n * @param result optional receiver.\r\n */\r\n public static interpolatePointAndTangent(\r\n pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d,\r\n ): Ray3d {\r\n result = result ?? Ray3d.createZero();\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n const dz = pt2.z - pt1.z;\r\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\r\n if (fraction <= 0.5)\r\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\r\n else {\r\n const t: number = fraction - 1.0;\r\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
@@ -158,8 +158,10 @@ export declare class Transform implements BeJSONFunctions {
158
158
  */
159
159
  static createScaleAboutPoint(fixedPoint: Point3d, scale: number, result?: Transform): Transform;
160
160
  /**
161
- * Return a transformation which flattens space onto a plane, sweeping along a direction which may be different from the plane normal.
162
- * @param sweepVector vector for the sweep direction
161
+ * Return a transformation which flattens space onto a plane, sweeping along a direction which may be different
162
+ * from the plane normal.
163
+ * * See [Matrix3d.createFlattenAlongVectorToPlane] for math details.
164
+ * @param sweepVector sweep direction. If same as `planeNormal`, the resulting transformation flattens to the plane.
163
165
  * @param planePoint any point on the plane
164
166
  * @param planeNormal vector normal to the plane.
165
167
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Transform.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAA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EAAE,QAAQ,GAAG,QAAQ;IAGtF;;;;;;;OAOG;IACI,6BAA6B,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,GAAG,IAAI;IASxF;;;;;;;;;;;;;OAaG;IACI,0BAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS;IAStE;;;;;;;;;;;;;OAaG;IACI,yBAAyB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS;IAUhF;;;;;;;;OAQG;IACI,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAoB/D;;;;OAIG;IACI,OAAO,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS;IAczD;;;;;;;;;;OAUG;WACW,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,SAAS,GAAG,IAAI;CAmChH"}
@@ -326,8 +326,10 @@ class Transform {
326
326
  return Transform.createRefs(origin, matrix, result);
327
327
  }
328
328
  /**
329
- * Return a transformation which flattens space onto a plane, sweeping along a direction which may be different from the plane normal.
330
- * @param sweepVector vector for the sweep direction
329
+ * Return a transformation which flattens space onto a plane, sweeping along a direction which may be different
330
+ * from the plane normal.
331
+ * * See [Matrix3d.createFlattenAlongVectorToPlane] for math details.
332
+ * @param sweepVector sweep direction. If same as `planeNormal`, the resulting transformation flattens to the plane.
331
333
  * @param planePoint any point on the plane
332
334
  * @param planeNormal vector normal to the plane.
333
335
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../../src/geometry3d/Transform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAmE;AACnE,mDAAgD;AAChD,yCAAsC;AACtC,uDAA4C;AAC5C,uDAA2D;AAC3D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AC;YAChB,mBAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACtD,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAC7D,CAAC;QACD;;;;;;;WAOG;QACH,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,IAAI,yBAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAC9E,mBAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACxE,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF;AA3xBD,8BA2xBC","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\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d, XYZ } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\nimport { TransformProps, XAndY, XYAndZ } from \"./XYZProps\";\r\n\r\n/**\r\n * A Transform consists of an origin and a Matrix3d. This describes a coordinate frame with this origin, with\r\n * the columns of the Matrix3d being the local x,y,z axis directions.\r\n * * The math for a Transform `T` consisting of a Matrix3d `M` and a Point3d `o` on a Vector3d `p` is: `Tp = M*p + o`.\r\n * In other words, `T` is a combination of two operations on `p`: the action of matrix multiplication, followed by a\r\n * translation. `Origin` is a traditional term for `o`, because `T` can be interpreted as a change of basis from the\r\n * global axes centered at the global origin, to a new set of axes specified by matrix M columns centered at `o`.\r\n * * Beware that for common transformations (e.g. scale about point, rotate around an axis) the `fixed point` that\r\n * is used when describing the transform is NOT the `origin` stored in the transform. Setup methods (e.g\r\n * createFixedPointAndMatrix, createScaleAboutPoint) take care of determining the appropriate origin coordinates.\r\n * * If `T` is a translation, no point is fixed by `T`.\r\n * * If `T` is the identity, all points are fixed by `T`.\r\n * * If `T` is a scale about a point, one point is fixed by `T`.\r\n * * If `T` is a rotation about an axis, a line is fixed by `T`.\r\n * * If `T` is a projection to the plane, a plane is fixed by `T`.\r\n * @public\r\n */\r\nexport class Transform implements BeJSONFunctions {\r\n private _origin: XYZ;\r\n private _matrix: Matrix3d;\r\n // Constructor accepts and uses pointer to content (no copy is done here).\r\n private constructor(origin: XYZ, matrix: Matrix3d) {\r\n this._origin = origin;\r\n this._matrix = matrix;\r\n }\r\n private static _identity?: Transform;\r\n /** The identity Transform. Value is frozen and cannot be modified. */\r\n public static get identity(): Transform {\r\n if (undefined === this._identity) {\r\n this._identity = Transform.createIdentity();\r\n this._identity.freeze();\r\n }\r\n return this._identity;\r\n }\r\n /** Freeze this instance (and its members) so it is read-only */\r\n public freeze(): Readonly<this> {\r\n this._origin.freeze();\r\n this._matrix.freeze();\r\n return Object.freeze(this);\r\n }\r\n /**\r\n * Copy contents from other Transform into this Transform\r\n * @param other source transform\r\n */\r\n public setFrom(other: Transform) {\r\n this._origin.setFrom(other._origin);\r\n this._matrix.setFrom(other._matrix);\r\n }\r\n /** Set this Transform to be an identity. */\r\n public setIdentity() {\r\n this._origin.setZero();\r\n this._matrix.setIdentity();\r\n }\r\n /**\r\n * Set this Transform instance from flexible inputs:\r\n * * Any object (such as another Transform or TransformProps) that has `origin` and `matrix` members\r\n * accepted by `Point3d.setFromJSON` and `Matrix3d.setFromJSON`\r\n * * An array of 3 number arrays, each with 4 entries which are rows in a 3x4 matrix.\r\n * * An array of 12 numbers, each block of 4 entries as a row 3x4 matrix.\r\n * * If no input is provided, the identity Transform is returned.\r\n */\r\n public setFromJSON(json?: TransformProps | Transform): void {\r\n if (json) {\r\n if (json instanceof Object && (json as any).origin && (json as any).matrix) {\r\n this._origin.setFromJSON((json as any).origin);\r\n this._matrix.setFromJSON((json as any).matrix);\r\n return;\r\n }\r\n if (Geometry.isArrayOfNumberArray(json, 3, 4)) {\r\n this._matrix.setRowValues(\r\n json[0][0], json[0][1], json[0][2],\r\n json[1][0], json[1][1], json[1][2],\r\n json[2][0], json[2][1], json[2][2],\r\n );\r\n this._origin.set(json[0][3], json[1][3], json[2][3]);\r\n return;\r\n }\r\n if (Geometry.isNumberArray(json, 12)) {\r\n this._matrix.setRowValues(\r\n json[0], json[1], json[2],\r\n json[4], json[5], json[6],\r\n json[8], json[9], json[10],\r\n );\r\n this._origin.set(json[3], json[7], json[11]);\r\n return;\r\n }\r\n }\r\n this.setIdentity();\r\n }\r\n /**\r\n * Test for near equality with `other` Transform. Comparison uses the `isAlmostEqual` methods on the `origin` and\r\n * `matrix` parts.\r\n * @param other Transform to compare to.\r\n */\r\n public isAlmostEqual(other: Readonly<Transform>): boolean {\r\n return this === other || this.origin.isAlmostEqual(other.origin) && this.matrix.isAlmostEqual(other.matrix);\r\n }\r\n /**\r\n * Test for near equality with `other` Transform. Comparison uses the `isAlmostEqual` methods on the `origin` part\r\n * and the `isAlmostEqualAllowZRotation` method on the `matrix` part.\r\n * @param other Transform to compare to.\r\n */\r\n public isAlmostEqualAllowZRotation(other: Transform): boolean {\r\n return this._origin.isAlmostEqual(other._origin) && this._matrix.isAlmostEqualAllowZRotation(other._matrix);\r\n }\r\n /**\r\n * Return a 3 by 4 matrix containing the rows of this Transform.\r\n * * The transform's origin coordinates are the last entries of the 3 json arrays\r\n */\r\n public toRows(): number[][] {\r\n return [\r\n [this._matrix.coffs[0], this._matrix.coffs[1], this._matrix.coffs[2], this._origin.x],\r\n [this._matrix.coffs[3], this._matrix.coffs[4], this._matrix.coffs[5], this._origin.y],\r\n [this._matrix.coffs[6], this._matrix.coffs[7], this._matrix.coffs[8], this._origin.z],\r\n ];\r\n }\r\n /**\r\n * Return a 3 by 4 matrix containing the rows of this Transform.\r\n * * The transform's origin coordinates are the last entries of the 3 json arrays\r\n */\r\n public toJSON(): TransformProps {\r\n return this.toRows();\r\n }\r\n /** Return a new Transform initialized by `Transform.setFromJSON` */\r\n public static fromJSON(json?: TransformProps): Transform {\r\n const result = Transform.createIdentity();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /** Copy the contents of `this` transform into a new Transform (or to the result, if specified). */\r\n public clone(result?: Transform): Transform {\r\n if (result) {\r\n result._matrix.setFrom(this._matrix);\r\n result._origin.setFrom(this._origin);\r\n return result;\r\n }\r\n return new Transform(\r\n Point3d.createFrom(this._origin),\r\n this._matrix.clone(),\r\n );\r\n }\r\n /**\r\n * Return a modified copy of `this` Transform so that its `matrix` part is rigid (`origin` part is untouched).\r\n * * @see [[Matrix3d.axisOrderCrossProductsInPlace]] documentation for details of how the matrix is modified to rigid.\r\n */\r\n public cloneRigid(axisOrder: AxisOrder = AxisOrder.XYZ): Transform | undefined {\r\n const modifiedMatrix = Matrix3d.createRigidFromMatrix3d(this.matrix, axisOrder);\r\n if (!modifiedMatrix)\r\n return undefined;\r\n return new Transform(this.origin.cloneAsPoint3d(), modifiedMatrix);\r\n }\r\n /** Create a Transform with the given `origin` and `matrix`. Inputs are captured, not cloned. */\r\n public static createRefs(origin: XYZ | undefined, matrix: Matrix3d, result?: Transform): Transform {\r\n if (!origin)\r\n origin = Point3d.createZero();\r\n if (result) {\r\n result._origin = origin;\r\n result._matrix = matrix;\r\n return result;\r\n }\r\n return new Transform(origin, matrix);\r\n }\r\n /** Create a Transform with complete contents given. `q` inputs make the matrix and `a` inputs make the origin */\r\n public static createRowValues(\r\n qxx: number, qxy: number, qxz: number, ax: number,\r\n qyx: number, qyy: number, qyz: number, ay: number,\r\n qzx: number, qzy: number, qzz: number, az: number,\r\n result?: Transform,\r\n ): Transform {\r\n if (result) {\r\n result._origin.set(ax, ay, az);\r\n result._matrix.setRowValues(qxx, qxy, qxz, qyx, qyy, qyz, qzx, qzy, qzz);\r\n return result;\r\n }\r\n return new Transform(\r\n Point3d.create(ax, ay, az),\r\n Matrix3d.createRowValues(qxx, qxy, qxz, qyx, qyy, qyz, qzx, qzy, qzz),\r\n );\r\n }\r\n /** Create a Transform with all zeros */\r\n public static createZero(result?: Transform): Transform {\r\n return Transform.createRowValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, result);\r\n }\r\n /**\r\n * Create a Transform with translation provided by x,y,z parts.\r\n * * Translation Transform maps any vector `v` to `v + p` where `p = (x,y,z)`\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/CubeTransform\r\n * @param x x part of translation\r\n * @param y y part of translation\r\n * @param z z part of translation\r\n * @param result optional pre-allocated Transform\r\n * @returns new or updated transform\r\n */\r\n public static createTranslationXYZ(x: number = 0, y: number = 0, z: number = 0, result?: Transform): Transform {\r\n return Transform.createRefs(Vector3d.create(x, y, z), Matrix3d.createIdentity(), result);\r\n }\r\n /**\r\n * Create a Transform with specified `translation` part.\r\n * * Translation Transform maps any vector `v` to `v + translation`\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/CubeTransform\r\n * @param translation x,y,z parts of the translation\r\n * @param result optional pre-allocated Transform\r\n * @returns new or updated transform\r\n */\r\n public static createTranslation(translation: XYZ, result?: Transform): Transform {\r\n return Transform.createRefs(translation, Matrix3d.createIdentity(), result);\r\n }\r\n /** Return a reference (and NOT a copy) to the `matrix` part of the Transform. */\r\n public get matrix(): Matrix3d {\r\n return this._matrix;\r\n }\r\n /** Return a reference (and NOT a copy) to the `origin` part of the Transform. */\r\n public get origin(): XYZ {\r\n return this._origin;\r\n }\r\n /** return a (clone of) the `origin` part of the Transform, as a `Point3d` */\r\n public getOrigin(): Point3d {\r\n return Point3d.createFrom(this._origin);\r\n }\r\n /** return a (clone of) the `origin` part of the Transform, as a `Vector3d` */\r\n public getTranslation(): Vector3d {\r\n return Vector3d.createFrom(this._origin);\r\n }\r\n /** return a (clone of) the `matrix` part of the Transform, as a `Matrix3d` */\r\n public getMatrix(): Matrix3d {\r\n return this._matrix.clone();\r\n }\r\n /** test if the transform has `origin` = (0,0,0) and identity `matrix` */\r\n public get isIdentity(): boolean {\r\n return this._matrix.isIdentity && this._origin.isAlmostZero;\r\n }\r\n /** Create an identity transform */\r\n public static createIdentity(result?: Transform): Transform {\r\n if (result) {\r\n result._origin.setZero();\r\n result._matrix.setIdentity();\r\n return result;\r\n }\r\n return Transform.createRefs(Point3d.createZero(), Matrix3d.createIdentity());\r\n }\r\n /**\r\n * Create a Transform using the given `origin` and `matrix`.\r\n * * This is the appropriate construction when the columns of the matrix are coordinate axes of a\r\n * local-to-world mapping, and the given point is the axes' origin in world coordinates.\r\n * * This function is closely related to `createFixedPointAndMatrix` whose point input is the fixed point\r\n * of the world-to-world transformation.\r\n * * If origin is `undefined`, (0,0,0) is used. If matrix is `undefined` the identity matrix is used.\r\n */\r\n public static createOriginAndMatrix(\r\n origin: XYZ | undefined, matrix: Matrix3d | undefined, result?: Transform,\r\n ): Transform {\r\n if (result) {\r\n result._origin.setFromPoint3d(origin);\r\n result._matrix.setFrom(matrix);\r\n return result;\r\n }\r\n return Transform.createRefs(\r\n origin ? origin.cloneAsPoint3d() : Point3d.createZero(),\r\n matrix === undefined ? Matrix3d.createIdentity() : matrix.clone(),\r\n result,\r\n );\r\n }\r\n /** Create a Transform using the given `origin` and columns of the `matrix`. If `undefined` zero is used. */\r\n public setOriginAndMatrixColumns(\r\n origin: XYZ | undefined, vectorX: Vector3d | undefined, vectorY: Vector3d | undefined, vectorZ: Vector3d | undefined,\r\n ): void {\r\n if (origin !== undefined)\r\n this._origin.setFrom(origin);\r\n this._matrix.setColumns(vectorX, vectorY, vectorZ);\r\n }\r\n /** Create a Transform using the given `origin` and columns of the `matrix` */\r\n public static createOriginAndMatrixColumns(\r\n origin: XYZ, vectorX: Vector3d, vectorY: Vector3d, vectorZ: Vector3d, result?: Transform,\r\n ): Transform {\r\n if (result)\r\n result.setOriginAndMatrixColumns(origin, vectorX, vectorY, vectorZ);\r\n else\r\n result = Transform.createRefs(Vector3d.createFrom(origin), Matrix3d.createColumns(vectorX, vectorY, vectorZ));\r\n return result;\r\n }\r\n /**\r\n * Create a Transform such that its `matrix` part is rigid.\r\n * @see [[Matrix3d.createRigidFromColumns]] for details of how the matrix is created to be rigid.\r\n */\r\n public static createRigidFromOriginAndColumns(\r\n origin: XYZ | undefined, vectorX: Vector3d, vectorY: Vector3d, axisOrder: AxisOrder, result?: Transform,\r\n ): Transform | undefined {\r\n const matrix = Matrix3d.createRigidFromColumns(vectorX, vectorY, axisOrder, result ? result._matrix : undefined);\r\n if (!matrix)\r\n return undefined;\r\n if (result) {\r\n // result._matrix was already modified to become rigid via createRigidFromColumns\r\n result._origin.setFrom(origin);\r\n return result;\r\n }\r\n /**\r\n * We don't want to pass \"origin\" to createRefs because createRefs does not clone \"origin\". That means if \"origin\"\r\n * is changed via Transform at any point, the initial \"origin\" passed by the user is also changed. To avoid that,\r\n * we pass \"undefined\" to createRefs so that it allocates a new point which then we set it to the \"origin\" which\r\n * is passed by user in the next line.\r\n */\r\n result = Transform.createRefs(undefined, matrix);\r\n result._origin.setFromPoint3d(origin);\r\n return result;\r\n }\r\n /**\r\n * Create a Transform with the specified `matrix`. Compute an `origin` (different from the given `fixedPoint`)\r\n * so that the `fixedPoint` maps back to itself. The returned Transform, transforms a point `p` to `M*p + (f - M*f)`\r\n * where `f` is the fixedPoint (i.e., `Tp = M*(p-f) + f`).\r\n */\r\n public static createFixedPointAndMatrix(\r\n fixedPoint: XYAndZ | undefined, matrix: Matrix3d, result?: Transform,\r\n ): Transform {\r\n if (fixedPoint) {\r\n /**\r\n * if f is a fixed point, then Tf = M*f + o = f where M is the matrix and o is the origin.\r\n * we define the origin o = f - M*f. Therefore, Tf = Mf + o = M*f + (f - M*f) = f.\r\n */\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(fixedPoint, matrix, fixedPoint);\r\n return Transform.createRefs(origin, matrix.clone(), result);\r\n }\r\n return Transform.createRefs(undefined, matrix.clone());\r\n }\r\n /**\r\n * Create a transform with the specified `matrix` and points `a` and `b`. The returned Transform maps\r\n * point `p` to `M*(p-a) + b` (i.e., `Tp = M*(p-a) + b`), so maps `a` to `b`.\r\n */\r\n public static createMatrixPickupPutdown(\r\n matrix: Matrix3d, a: Point3d, b: Point3d, result?: Transform,\r\n ): Transform {\r\n // we define the origin o = b - M*a so Tp = M*p + o = M*p + (b - M*a) = M*(p-a) + b\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(b, matrix, a);\r\n return Transform.createRefs(origin, matrix.clone(), result);\r\n }\r\n /**\r\n * Create a Transform which leaves the fixedPoint unchanged and scales everything else around it by\r\n * a single scale factor. The returned Transform maps a point `p` to `M*p + (f - M*f)`\r\n * where `f` is the fixedPoint and M is the scale matrix (i.e., `Tp = M*(p-f) + f`).\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/CubeTransform\r\n */\r\n public static createScaleAboutPoint(fixedPoint: Point3d, scale: number, result?: Transform): Transform {\r\n const matrix = Matrix3d.createScale(scale, scale, scale);\r\n /**\r\n * if f is a fixed point, then Tf = M*f + o = f where M is the matrix and o is the origin.\r\n * we define the origin o = f - M*f. Therefore, Tf = M*f + o = M*f + (f - M*f) = f.\r\n */\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(fixedPoint, matrix, fixedPoint);\r\n return Transform.createRefs(origin, matrix, result);\r\n }\r\n /**\r\n * Return a transformation which flattens space onto a plane, sweeping along a direction which may be different from the plane normal.\r\n * @param sweepVector vector for the sweep direction\r\n * @param planePoint any point on the plane\r\n * @param planeNormal vector normal to the plane.\r\n */\r\n public static createFlattenAlongVectorToPlane(sweepVector: Vector3d, planePoint: XYAndZ, planeNormal: Vector3d): Transform | undefined {\r\n const matrix = Matrix3d.createFlattenAlongVectorToPlane(sweepVector, planeNormal);\r\n if (matrix === undefined)\r\n return undefined;\r\n return Transform.createFixedPointAndMatrix(planePoint, matrix);\r\n }\r\n /**\r\n * Transform the input 2d point (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyPoint2d(point: XAndY, result?: Point2d): Point2d {\r\n return Matrix3d.xyPlusMatrixTimesXY(this._origin, this._matrix, point, result);\r\n }\r\n /**\r\n * Transform the input 3d point (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyPoint3d(point: XYAndZ, result?: Point3d): Point3d {\r\n // Tx = Mx + o so we return Mx + o\r\n return Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, point, result);\r\n }\r\n /**\r\n * Transform the input 3d point in place (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyXYAndZInPlace(point: XYAndZ): void {\r\n return Matrix3d.xyzPlusMatrixTimesXYZInPlace(this._origin, this._matrix, point);\r\n }\r\n /**\r\n * Transform the input 3d point (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyXYZ(x: number, y: number, z: number = 0, result?: Point3d): Point3d {\r\n // Tx = Mx + o so we return Mx + o\r\n return Matrix3d.xyzPlusMatrixTimesCoordinates(this._origin, this._matrix, x, y, z, result);\r\n }\r\n /**\r\n * Multiply a specific row (component) of the 3x4 instance times (x,y,z,1). Return the result.\r\n */\r\n public multiplyComponentXYZ(componentIndex: number, x: number, y: number, z: number = 0): number {\r\n const coffs = this._matrix.coffs;\r\n const idx = 3 * componentIndex;\r\n return this.origin.at(componentIndex) + (coffs[idx] * x) + (coffs[idx + 1] * y) + (coffs[idx + 2] * z);\r\n }\r\n /**\r\n * Multiply a specific row (component) of the 3x4 instance times (x,y,z,w). Return the result.\r\n */\r\n public multiplyComponentXYZW(componentIndex: number, x: number, y: number, z: number, w: number): number {\r\n const coffs = this._matrix.coffs;\r\n const idx = 3 * componentIndex;\r\n return (this.origin.at(componentIndex) * w) + (coffs[idx] * x) + (coffs[idx + 1] * y) + (coffs[idx + 2] * z);\r\n }\r\n /**\r\n * Transform the homogeneous point. Return as a new `Point4d`, or in the pre-allocated result (if result is given).\r\n * * If `p = (x,y,z)` then this method computes `Tp = M*p + o*w` and returns the `Point4d` formed by `Tp` in the\r\n * first three coordinates, and `w` in the fourth.\r\n * * Logically, this is multiplication by the 4x4 matrix formed from the 3x4 instance augmented with fourth row 0001.\r\n */\r\n public multiplyXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d {\r\n return Matrix3d.xyzPlusMatrixTimesWeightedCoordinates(this._origin, this._matrix, x, y, z, w, result);\r\n }\r\n /**\r\n * Transform the homogeneous point. Return as new `Float64Array` with size 4, or in the pre-allocated `result` of sufficient size.\r\n * * If `p = (x,y,z)` then this method computes `Tp = M*p + o*w` and returns the `Float64Array` formed by `Tp`\r\n * in the first 3 numbers of the array and `w` as the fourth.\r\n * * Logically, this is multiplication by the 4x4 matrix formed from the 3x4 instance augmented with fourth row 0001.\r\n */\r\n public multiplyXYZWToFloat64Array(x: number, y: number, z: number, w: number, result?: Float64Array): Float64Array {\r\n return Matrix3d.xyzPlusMatrixTimesWeightedCoordinatesToFloat64Array(this._origin, this._matrix, x, y, z, w, result);\r\n }\r\n /**\r\n * * Transform the point. Return as new `Float64Array` with size 3, or in the pre-allocated `result` of sufficient size.\r\n * * If `p = (x,y,z)` then this method computes `Tp = M*p + o` and returns it as the first 3 elements of the array.\r\n */\r\n public multiplyXYZToFloat64Array(x: number, y: number, z: number, result?: Float64Array): Float64Array {\r\n return Matrix3d.xyzPlusMatrixTimesCoordinatesToFloat64Array(this._origin, this._matrix, x, y, z, result);\r\n }\r\n /**\r\n * Multiply the homogeneous point by the transpose of `this` Transform. Return as a new `Point4d` or in the\r\n * pre-allocated result (if result is given).\r\n * * If `p = (x,y,z)` then this method computes `M^t*p` and returns it in the first three coordinates of the `Point4d`,\r\n * and `o*p + w` in the fourth.\r\n * * Logically, this is multiplication by the transpose of the 4x4 matrix formed from the 3x4 instance augmented with\r\n * fourth row 0001.\r\n */\r\n public multiplyTransposeXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d {\r\n const coffs = this._matrix.coffs;\r\n const origin = this._origin;\r\n return Point4d.create(\r\n (x * coffs[0]) + (y * coffs[3]) + (z * coffs[6]),\r\n (x * coffs[1]) + (y * coffs[4]) + (z * coffs[7]),\r\n (x * coffs[2]) + (y * coffs[5]) + (z * coffs[8]),\r\n (x * origin.x) + (y * origin.y) + (z * origin.z) + w,\r\n result,\r\n );\r\n }\r\n /** For each point in the array, replace point by the transformed point (using `Tp = M*p + o`) */\r\n public multiplyPoint3dArrayInPlace(points: Point3d[]) {\r\n let point;\r\n for (point of points)\r\n Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, point, point);\r\n }\r\n /** For each point in the 2d array, replace point by the transformed point (using `Tp = M*p + o`) */\r\n public multiplyPoint3dArrayArrayInPlace(chains: Point3d[][]) {\r\n for (const chain of chains)\r\n this.multiplyPoint3dArrayInPlace(chain);\r\n }\r\n /**\r\n * Multiply the point by the inverse Transform.\r\n * * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse`\r\n * Transform has matrix part `MInverse` and origin part `-MInverse*o`.\r\n * * Return as a new point or in the optional `result`.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInversePoint3d(point: XYAndZ, result?: Point3d): Point3d | undefined {\r\n return this._matrix.multiplyInverseXYZAsPoint3d(\r\n point.x - this._origin.x,\r\n point.y - this._origin.y,\r\n point.z - this._origin.z,\r\n result,\r\n );\r\n }\r\n /**\r\n * Multiply the homogenous point by the inverse Transform.\r\n * * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse` Transform\r\n * has matrix part `MInverse` and origin part `-MInverse*o`.\r\n * * This method computes `TInverse p = MInverse*p - w*MInverse*o` and returns the `Point4d` formed by `TInverse*p`\r\n * in the first three coordinates, and `w` in the fourth.\r\n * * Logically, this is multiplication by the inverse of the 4x4 matrix formed from the 3x4 instance augmented with\r\n * fourth row 0001. This is equivalent to the 4x4 matrix formed in similar fashion from the inverse of this instance.\r\n * * Return as a new point or in the optional `result`.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInversePoint4d(weightedPoint: Point4d, result?: Point4d): Point4d | undefined {\r\n const w = weightedPoint.w;\r\n return this._matrix.multiplyInverseXYZW(\r\n weightedPoint.x - w * this.origin.x,\r\n weightedPoint.y - w * this.origin.y,\r\n weightedPoint.z - w * this.origin.z,\r\n w,\r\n result,\r\n );\r\n }\r\n /**\r\n * Multiply the point by the inverse Transform.\r\n * * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse` Transform\r\n * has matrix part `MInverse` and origin part `-MInverse*o`.\r\n * * Return as a new point or in the optional `result`.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInverseXYZ(x: number, y: number, z: number, result?: Point3d): Point3d | undefined {\r\n return this._matrix.multiplyInverseXYZAsPoint3d(\r\n x - this._origin.x,\r\n y - this._origin.y,\r\n z - this._origin.z,\r\n result,\r\n );\r\n }\r\n /**\r\n * * Compute (if needed) the inverse of the `matrix` part of the Transform, thereby ensuring inverse\r\n * operations can complete.\r\n * @param useCached If true, accept prior cached inverse if available.\r\n * @returns `true` if matrix inverse completes, `false` otherwise.\r\n */\r\n public computeCachedInverse(useCached: boolean = true): boolean {\r\n return this._matrix.computeCachedInverse(useCached);\r\n }\r\n /**\r\n * Match the length of destination array with the length of source array\r\n * * If destination has more elements than source, remove the extra elements.\r\n * * If destination has fewer elements than source, use `constructionFunction` to create new elements.\r\n * *\r\n * @param source the source array\r\n * @param dest the destination array\r\n * @param constructionFunction function to call to create new elements.\r\n */\r\n public static matchArrayLengths(source: any[], dest: any[], constructionFunction: () => any): number {\r\n const numSource = source.length;\r\n const numDest = dest.length;\r\n if (numSource > numDest) {\r\n for (let i = numDest; i < numSource; i++) {\r\n dest.push(constructionFunction());\r\n }\r\n } else if (numDest > numSource) {\r\n dest.length = numSource;\r\n }\r\n return numSource;\r\n }\r\n /**\r\n * Multiply each point in the array by the inverse of `this` Transform.\r\n * * For a transform `T = [M o]` the inverse transform `T' = [M' -M'o]` exists if and only if `M` has an inverse\r\n * `M'`. Indeed, for any point `p`, we have `T'Tp = T'(Mp + o) = M'(Mp + o) - M'o = M'Mp + M'o - M'o = p.`\r\n * * If `result` is given, resize it to match the input `points` array and update it with original points `p[]`.\r\n * * If `result` is not given, return a new array.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInversePoint3dArray(points: Point3d[], result?: Point3d[]): Point3d[] | undefined {\r\n if (!this._matrix.computeCachedInverse(true))\r\n return undefined;\r\n const originX = this.origin.x;\r\n const originY = this.origin.y;\r\n const originZ = this.origin.z;\r\n if (result) {\r\n const n = Transform.matchArrayLengths(points, result, () => Point3d.createZero());\r\n for (let i = 0; i < n; i++)\r\n this._matrix.multiplyInverseXYZAsPoint3d(\r\n points[i].x - originX,\r\n points[i].y - originY,\r\n points[i].z - originZ,\r\n result[i],\r\n );\r\n return result;\r\n }\r\n result = [];\r\n for (const point of points)\r\n result.push(\r\n this._matrix.multiplyInverseXYZAsPoint3d(\r\n point.x - originX,\r\n point.y - originY,\r\n point.z - originZ,\r\n )!,\r\n );\r\n return result;\r\n }\r\n /**\r\n * Multiply each point in the array by the inverse of `this` Transform in place.\r\n * * For a transform `T = [M o]` the inverse transform `T' = [M' -M'o]` exists if and only if `M` has an inverse\r\n * `M'`. Indeed, for any point `p`, we have `T'Tp = T'(Mp + o) = M'(Mp + o) - M'o = M'Mp + M'o - M'o = p.`\r\n * * Returns `true` if the `matrix` part if this Transform is invertible and `false` if singular.\r\n */\r\n public multiplyInversePoint3dArrayInPlace(points: Point3d[]): boolean {\r\n if (!this._matrix.computeCachedInverse(true))\r\n return false;\r\n for (const point of points)\r\n this._matrix.multiplyInverseXYZAsPoint3d(\r\n point.x - this.origin.x,\r\n point.y - this.origin.y,\r\n point.z - this.origin.z,\r\n point,\r\n );\r\n return true;\r\n }\r\n /**\r\n * Transform the input 2d point array (using `Tp = M*p + o`).\r\n * * If `result` is given, resize it to match the input `points` array and update it with transformed points.\r\n * * If `result` is not given, return a new array.\r\n */\r\n public multiplyPoint2dArray(points: Point2d[], result?: Point2d[]): Point2d[] {\r\n if (result) {\r\n const n = Transform.matchArrayLengths(points, result, () => Point2d.createZero());\r\n for (let i = 0; i < n; i++)\r\n Matrix3d.xyPlusMatrixTimesXY(this._origin, this._matrix, points[i], result[i]);\r\n return result;\r\n }\r\n result = [];\r\n for (const p of points)\r\n result.push(Matrix3d.xyPlusMatrixTimesXY(this._origin, this._matrix, p));\r\n return result;\r\n }\r\n /**\r\n * Transform the input 3d point array (using `Tp = M*p + o`).\r\n * * If `result` is given, resize it to match the input `points` array and update it with transformed points.\r\n * * If `result` is not given, return a new array.\r\n */\r\n public multiplyPoint3dArray(points: Point3d[], result?: Point3d[]): Point3d[] {\r\n if (result) {\r\n const n = Transform.matchArrayLengths(points, result, () => Point3d.createZero());\r\n for (let i = 0; i < n; i++)\r\n Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, points[i], result[i]);\r\n return result;\r\n }\r\n result = [];\r\n for (const p of points)\r\n result.push(Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, p));\r\n return result;\r\n }\r\n /**\r\n * Multiply the vector by the `matrix` part of the Transform.\r\n * * The `origin` part of Transform is not used.\r\n * * If `result` is given, update it with the multiplication. Otherwise, create a new Vector3d.\r\n */\r\n public multiplyVector(vector: Vector3d, result?: Vector3d): Vector3d {\r\n return this._matrix.multiplyVector(vector, result);\r\n }\r\n /**\r\n * Multiply the vector by the `matrix` part of the Transform in place.\r\n * * The `origin` part of Transform is not used.\r\n */\r\n public multiplyVectorInPlace(vector: Vector3d): void {\r\n this._matrix.multiplyVectorInPlace(vector);\r\n }\r\n /**\r\n * Multiply the vector (x,y,z) by the `matrix` part of the Transform.\r\n * * The `origin` part of Transform is not used.\r\n * * If `result` is given, update it with the multiplication. Otherwise, create a new Vector3d.\r\n */\r\n public multiplyVectorXYZ(x: number, y: number, z: number, result?: Vector3d): Vector3d {\r\n return this._matrix.multiplyXYZ(x, y, z, result);\r\n }\r\n /**\r\n * Calculate `transformA * transformB` and store it into the calling instance (`this`).\r\n * * **Note:** If `transformA = [A a]` and `transformB = [B b]` then `transformA * transformB` is defined as\r\n * `[A*B Ab+a]`.\r\n * * @see [[multiplyTransformTransform]] documentation for math details.\r\n * @param transformA first operand\r\n * @param transformB second operand\r\n */\r\n public setMultiplyTransformTransform(transformA: Transform, transformB: Transform): void {\r\n Matrix3d.xyzPlusMatrixTimesXYZ(\r\n transformA._origin,\r\n transformA._matrix,\r\n transformB._origin,\r\n this._origin as Point3d,\r\n );\r\n transformA._matrix.multiplyMatrixMatrix(transformB._matrix, this._matrix);\r\n }\r\n /**\r\n * Multiply `this` Transform times `other` Transform.\r\n * * **Note:** If `this = [A a]` and `other = [B b]` then `this * other` is defined as `[A*B Ab+a]` because:\r\n * ```\r\n * equation\r\n * \\begin{matrix}\r\n * \\text{this Transform with matrix part }\\bold{A}\\text{ and origin part }\\bold{a} & \\blockTransform{A}{a}\\\\\r\n * \\text{other Transform with matrix part }\\bold{B}\\text{ and origin part }\\bold{b} & \\blockTransform{B}{b} \\\\\r\n * \\text{product}& \\blockTransform{A}{a}\\blockTransform{B}{b}=\\blockTransform{AB}{Ab + a}\r\n * \\end{matrix}\r\n * ```\r\n * @param other the `other` Transform to be multiplied to `this` Transform.\r\n * @param result optional preallocated `result` to reuse.\r\n */\r\n public multiplyTransformTransform(other: Transform, result?: Transform) {\r\n if (!result)\r\n return Transform.createRefs(\r\n Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, other._origin),\r\n this._matrix.multiplyMatrixMatrix(other._matrix),\r\n );\r\n result.setMultiplyTransformTransform(this, other);\r\n return result;\r\n }\r\n /**\r\n * Multiply `this` Transform times `other` Matrix3d (considered to be a Transform with 0 `origin`).\r\n * * **Note:** If `this = [A a]` and `other = [B 0]`, then `this * other` is defined as [A*B a] because:\r\n * ```\r\n * equation\r\n * \\begin{matrix}\r\n * \\text{this Transform with matrix part }\\bold{A}\\text{ and origin part }\\bold{a} & \\blockTransform{A}{a}\\\\\r\n * \\text{other matrix }\\bold{B}\\text{ promoted to block Transform} & \\blockTransform{B}{0} \\\\\r\n * \\text{product}& \\blockTransform{A}{a}\\blockTransform{B}{0}=\\blockTransform{AB}{a}\r\n * \\end{matrix}\r\n * ```\r\n * @param other the `other` Matrix3d to be multiplied to `this` Transform.\r\n * @param result optional preallocated `result` to reuse.\r\n */\r\n public multiplyTransformMatrix3d(other: Matrix3d, result?: Transform): Transform {\r\n if (!result)\r\n return Transform.createRefs(\r\n this._origin.cloneAsPoint3d(),\r\n this._matrix.multiplyMatrixMatrix(other),\r\n );\r\n this._matrix.multiplyMatrixMatrix(other, result._matrix);\r\n result._origin.setFrom(this._origin);\r\n return result;\r\n }\r\n /**\r\n * Return the range of the transformed corners.\r\n * * The 8 corners are transformed individually.\r\n * * **Note:** Suppose you have a geometry, a range box around that geometry, and your Transform is a rotation.\r\n * If you rotate the range box and recompute a new range box around the rotated range box, then the new range\r\n * box will have a larger volume than the original range box. However, if you rotate the geometry itself and\r\n * then recompute the range box, it will be a tighter range box around the rotated geometry. `multiplyRange`\r\n * function creates the larger range box because it only has access to the range box and not the geometry itself.\r\n */\r\n public multiplyRange(range: Range3d, result?: Range3d): Range3d {\r\n if (range.isNull)\r\n return range.clone(result);\r\n const lowX = range.low.x;\r\n const lowY = range.low.y;\r\n const lowZ = range.low.z;\r\n const highX = range.high.x;\r\n const highY = range.high.y;\r\n const highZ = range.high.z;\r\n result = Range3d.createNull(result);\r\n result.extendTransformedXYZ(this, lowX, lowY, lowZ);\r\n result.extendTransformedXYZ(this, highX, lowY, lowZ);\r\n result.extendTransformedXYZ(this, lowX, highY, lowZ);\r\n result.extendTransformedXYZ(this, highX, highY, lowZ);\r\n result.extendTransformedXYZ(this, lowX, lowY, highZ);\r\n result.extendTransformedXYZ(this, highX, lowY, highZ);\r\n result.extendTransformedXYZ(this, lowX, highY, highZ);\r\n result.extendTransformedXYZ(this, highX, highY, highZ);\r\n return result;\r\n }\r\n /**\r\n * Return a Transform which is the inverse of `this` Transform.\r\n * * If `transform = [M o]` then `transformInverse = [MInverse -MInverse*o]`\r\n * * Return `undefined` if this Transform's matrix is singular.\r\n */\r\n public inverse(result?: Transform): Transform | undefined {\r\n const matrixInverse = this._matrix.inverse(result ? result._matrix : undefined);\r\n if (!matrixInverse)\r\n return undefined;\r\n if (result) {\r\n // result._matrix is already defined\r\n matrixInverse.multiplyXYZ(-this._origin.x, -this._origin.y, -this._origin.z, result._origin as Vector3d);\r\n return result;\r\n }\r\n return Transform.createRefs(\r\n matrixInverse.multiplyXYZ(-this._origin.x, -this._origin.y, -this._origin.z),\r\n matrixInverse,\r\n );\r\n }\r\n /**\r\n * Initialize 2 Transforms that map between the unit box (specified by 000 and 111) and the range box specified\r\n * by the input points.\r\n * @param min the min corner of the range box\r\n * @param max the max corner of the range box\r\n * @param npcToGlobal maps NPC coordinates into range box coordinates. Specifically, maps 000 to `min` and maps\r\n * 111 to `max`. This Transform is the inverse of `globalToNpc`. Object created by caller, re-initialized here.\r\n * @param globalToNpc maps range box coordinates into NPC coordinates. Specifically, maps `min` to 000 and maps\r\n * `max` to 111. This Transform is the inverse of `npcToGlobal`. Object created by caller, re-initialized here.\r\n * * NPC stands for `Normalized Projection Coordinate`\r\n */\r\n public static initFromRange(min: Point3d, max: Point3d, npcToGlobal?: Transform, globalToNpc?: Transform): void {\r\n const diag = max.minus(min);\r\n if (diag.x === 0.0)\r\n diag.x = 1.0;\r\n if (diag.y === 0.0)\r\n diag.y = 1.0;\r\n if (diag.z === 0.0)\r\n diag.z = 1.0;\r\n const rMatrix = new Matrix3d();\r\n /**\r\n * [diag.x 0 0 min.x]\r\n * npcToGlobal = [ 0 diag.y 0 min.y]\r\n * [ 0 0 diag.y min.z]\r\n *\r\n * npcToGlobal * 0 = min\r\n * npcToGlobal * 1 = diag + min = max\r\n */\r\n if (npcToGlobal) {\r\n Matrix3d.createScale(diag.x, diag.y, diag.z, rMatrix);\r\n Transform.createOriginAndMatrix(min, rMatrix, npcToGlobal);\r\n }\r\n /**\r\n * [1/diag.x 0 0 -min.x/diag.x]\r\n * globalToNpc = [ 0 1/diag.y 0 -min.y/diag.y]\r\n * [ 0 0 1/diag.y -min.z/diag.z]\r\n *\r\n * globalToNpc * min = min/diag - min/diag = 0\r\n * globalToNpc * max = max/diag - min/diag = diag/diag = 1\r\n */\r\n if (globalToNpc) {\r\n const origin = new Point3d(-min.x / diag.x, -min.y / diag.y, -min.z / diag.z);\r\n Matrix3d.createScale(1.0 / diag.x, 1.0 / diag.y, 1.0 / diag.z, rMatrix);\r\n Transform.createOriginAndMatrix(origin, rMatrix, globalToNpc);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../../src/geometry3d/Transform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAmE;AACnE,mDAAgD;AAChD,yCAAsC;AACtC,uDAA4C;AAC5C,uDAA2D;AAC3D,mCAAkC;AAGlC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,S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C,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACtD,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAC7D,CAAC;QACD;;;;;;;WAOG;QACH,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,IAAI,yBAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAC9E,mBAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACxE,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF;AA7xBD,8BA6xBC","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\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d, XYZ } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\nimport { TransformProps, XAndY, XYAndZ } from \"./XYZProps\";\r\n\r\n/**\r\n * A Transform consists of an origin and a Matrix3d. This describes a coordinate frame with this origin, with\r\n * the columns of the Matrix3d being the local x,y,z axis directions.\r\n * * The math for a Transform `T` consisting of a Matrix3d `M` and a Point3d `o` on a Vector3d `p` is: `Tp = M*p + o`.\r\n * In other words, `T` is a combination of two operations on `p`: the action of matrix multiplication, followed by a\r\n * translation. `Origin` is a traditional term for `o`, because `T` can be interpreted as a change of basis from the\r\n * global axes centered at the global origin, to a new set of axes specified by matrix M columns centered at `o`.\r\n * * Beware that for common transformations (e.g. scale about point, rotate around an axis) the `fixed point` that\r\n * is used when describing the transform is NOT the `origin` stored in the transform. Setup methods (e.g\r\n * createFixedPointAndMatrix, createScaleAboutPoint) take care of determining the appropriate origin coordinates.\r\n * * If `T` is a translation, no point is fixed by `T`.\r\n * * If `T` is the identity, all points are fixed by `T`.\r\n * * If `T` is a scale about a point, one point is fixed by `T`.\r\n * * If `T` is a rotation about an axis, a line is fixed by `T`.\r\n * * If `T` is a projection to the plane, a plane is fixed by `T`.\r\n * @public\r\n */\r\nexport class Transform implements BeJSONFunctions {\r\n private _origin: XYZ;\r\n private _matrix: Matrix3d;\r\n // Constructor accepts and uses pointer to content (no copy is done here).\r\n private constructor(origin: XYZ, matrix: Matrix3d) {\r\n this._origin = origin;\r\n this._matrix = matrix;\r\n }\r\n private static _identity?: Transform;\r\n /** The identity Transform. Value is frozen and cannot be modified. */\r\n public static get identity(): Transform {\r\n if (undefined === this._identity) {\r\n this._identity = Transform.createIdentity();\r\n this._identity.freeze();\r\n }\r\n return this._identity;\r\n }\r\n /** Freeze this instance (and its members) so it is read-only */\r\n public freeze(): Readonly<this> {\r\n this._origin.freeze();\r\n this._matrix.freeze();\r\n return Object.freeze(this);\r\n }\r\n /**\r\n * Copy contents from other Transform into this Transform\r\n * @param other source transform\r\n */\r\n public setFrom(other: Transform) {\r\n this._origin.setFrom(other._origin);\r\n this._matrix.setFrom(other._matrix);\r\n }\r\n /** Set this Transform to be an identity. */\r\n public setIdentity() {\r\n this._origin.setZero();\r\n this._matrix.setIdentity();\r\n }\r\n /**\r\n * Set this Transform instance from flexible inputs:\r\n * * Any object (such as another Transform or TransformProps) that has `origin` and `matrix` members\r\n * accepted by `Point3d.setFromJSON` and `Matrix3d.setFromJSON`\r\n * * An array of 3 number arrays, each with 4 entries which are rows in a 3x4 matrix.\r\n * * An array of 12 numbers, each block of 4 entries as a row 3x4 matrix.\r\n * * If no input is provided, the identity Transform is returned.\r\n */\r\n public setFromJSON(json?: TransformProps | Transform): void {\r\n if (json) {\r\n if (json instanceof Object && (json as any).origin && (json as any).matrix) {\r\n this._origin.setFromJSON((json as any).origin);\r\n this._matrix.setFromJSON((json as any).matrix);\r\n return;\r\n }\r\n if (Geometry.isArrayOfNumberArray(json, 3, 4)) {\r\n this._matrix.setRowValues(\r\n json[0][0], json[0][1], json[0][2],\r\n json[1][0], json[1][1], json[1][2],\r\n json[2][0], json[2][1], json[2][2],\r\n );\r\n this._origin.set(json[0][3], json[1][3], json[2][3]);\r\n return;\r\n }\r\n if (Geometry.isNumberArray(json, 12)) {\r\n this._matrix.setRowValues(\r\n json[0], json[1], json[2],\r\n json[4], json[5], json[6],\r\n json[8], json[9], json[10],\r\n );\r\n this._origin.set(json[3], json[7], json[11]);\r\n return;\r\n }\r\n }\r\n this.setIdentity();\r\n }\r\n /**\r\n * Test for near equality with `other` Transform. Comparison uses the `isAlmostEqual` methods on the `origin` and\r\n * `matrix` parts.\r\n * @param other Transform to compare to.\r\n */\r\n public isAlmostEqual(other: Readonly<Transform>): boolean {\r\n return this === other || this.origin.isAlmostEqual(other.origin) && this.matrix.isAlmostEqual(other.matrix);\r\n }\r\n /**\r\n * Test for near equality with `other` Transform. Comparison uses the `isAlmostEqual` methods on the `origin` part\r\n * and the `isAlmostEqualAllowZRotation` method on the `matrix` part.\r\n * @param other Transform to compare to.\r\n */\r\n public isAlmostEqualAllowZRotation(other: Transform): boolean {\r\n return this._origin.isAlmostEqual(other._origin) && this._matrix.isAlmostEqualAllowZRotation(other._matrix);\r\n }\r\n /**\r\n * Return a 3 by 4 matrix containing the rows of this Transform.\r\n * * The transform's origin coordinates are the last entries of the 3 json arrays\r\n */\r\n public toRows(): number[][] {\r\n return [\r\n [this._matrix.coffs[0], this._matrix.coffs[1], this._matrix.coffs[2], this._origin.x],\r\n [this._matrix.coffs[3], this._matrix.coffs[4], this._matrix.coffs[5], this._origin.y],\r\n [this._matrix.coffs[6], this._matrix.coffs[7], this._matrix.coffs[8], this._origin.z],\r\n ];\r\n }\r\n /**\r\n * Return a 3 by 4 matrix containing the rows of this Transform.\r\n * * The transform's origin coordinates are the last entries of the 3 json arrays\r\n */\r\n public toJSON(): TransformProps {\r\n return this.toRows();\r\n }\r\n /** Return a new Transform initialized by `Transform.setFromJSON` */\r\n public static fromJSON(json?: TransformProps): Transform {\r\n const result = Transform.createIdentity();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /** Copy the contents of `this` transform into a new Transform (or to the result, if specified). */\r\n public clone(result?: Transform): Transform {\r\n if (result) {\r\n result._matrix.setFrom(this._matrix);\r\n result._origin.setFrom(this._origin);\r\n return result;\r\n }\r\n return new Transform(\r\n Point3d.createFrom(this._origin),\r\n this._matrix.clone(),\r\n );\r\n }\r\n /**\r\n * Return a modified copy of `this` Transform so that its `matrix` part is rigid (`origin` part is untouched).\r\n * * @see [[Matrix3d.axisOrderCrossProductsInPlace]] documentation for details of how the matrix is modified to rigid.\r\n */\r\n public cloneRigid(axisOrder: AxisOrder = AxisOrder.XYZ): Transform | undefined {\r\n const modifiedMatrix = Matrix3d.createRigidFromMatrix3d(this.matrix, axisOrder);\r\n if (!modifiedMatrix)\r\n return undefined;\r\n return new Transform(this.origin.cloneAsPoint3d(), modifiedMatrix);\r\n }\r\n /** Create a Transform with the given `origin` and `matrix`. Inputs are captured, not cloned. */\r\n public static createRefs(origin: XYZ | undefined, matrix: Matrix3d, result?: Transform): Transform {\r\n if (!origin)\r\n origin = Point3d.createZero();\r\n if (result) {\r\n result._origin = origin;\r\n result._matrix = matrix;\r\n return result;\r\n }\r\n return new Transform(origin, matrix);\r\n }\r\n /** Create a Transform with complete contents given. `q` inputs make the matrix and `a` inputs make the origin */\r\n public static createRowValues(\r\n qxx: number, qxy: number, qxz: number, ax: number,\r\n qyx: number, qyy: number, qyz: number, ay: number,\r\n qzx: number, qzy: number, qzz: number, az: number,\r\n result?: Transform,\r\n ): Transform {\r\n if (result) {\r\n result._origin.set(ax, ay, az);\r\n result._matrix.setRowValues(qxx, qxy, qxz, qyx, qyy, qyz, qzx, qzy, qzz);\r\n return result;\r\n }\r\n return new Transform(\r\n Point3d.create(ax, ay, az),\r\n Matrix3d.createRowValues(qxx, qxy, qxz, qyx, qyy, qyz, qzx, qzy, qzz),\r\n );\r\n }\r\n /** Create a Transform with all zeros */\r\n public static createZero(result?: Transform): Transform {\r\n return Transform.createRowValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, result);\r\n }\r\n /**\r\n * Create a Transform with translation provided by x,y,z parts.\r\n * * Translation Transform maps any vector `v` to `v + p` where `p = (x,y,z)`\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/CubeTransform\r\n * @param x x part of translation\r\n * @param y y part of translation\r\n * @param z z part of translation\r\n * @param result optional pre-allocated Transform\r\n * @returns new or updated transform\r\n */\r\n public static createTranslationXYZ(x: number = 0, y: number = 0, z: number = 0, result?: Transform): Transform {\r\n return Transform.createRefs(Vector3d.create(x, y, z), Matrix3d.createIdentity(), result);\r\n }\r\n /**\r\n * Create a Transform with specified `translation` part.\r\n * * Translation Transform maps any vector `v` to `v + translation`\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/CubeTransform\r\n * @param translation x,y,z parts of the translation\r\n * @param result optional pre-allocated Transform\r\n * @returns new or updated transform\r\n */\r\n public static createTranslation(translation: XYZ, result?: Transform): Transform {\r\n return Transform.createRefs(translation, Matrix3d.createIdentity(), result);\r\n }\r\n /** Return a reference (and NOT a copy) to the `matrix` part of the Transform. */\r\n public get matrix(): Matrix3d {\r\n return this._matrix;\r\n }\r\n /** Return a reference (and NOT a copy) to the `origin` part of the Transform. */\r\n public get origin(): XYZ {\r\n return this._origin;\r\n }\r\n /** return a (clone of) the `origin` part of the Transform, as a `Point3d` */\r\n public getOrigin(): Point3d {\r\n return Point3d.createFrom(this._origin);\r\n }\r\n /** return a (clone of) the `origin` part of the Transform, as a `Vector3d` */\r\n public getTranslation(): Vector3d {\r\n return Vector3d.createFrom(this._origin);\r\n }\r\n /** return a (clone of) the `matrix` part of the Transform, as a `Matrix3d` */\r\n public getMatrix(): Matrix3d {\r\n return this._matrix.clone();\r\n }\r\n /** test if the transform has `origin` = (0,0,0) and identity `matrix` */\r\n public get isIdentity(): boolean {\r\n return this._matrix.isIdentity && this._origin.isAlmostZero;\r\n }\r\n /** Create an identity transform */\r\n public static createIdentity(result?: Transform): Transform {\r\n if (result) {\r\n result._origin.setZero();\r\n result._matrix.setIdentity();\r\n return result;\r\n }\r\n return Transform.createRefs(Point3d.createZero(), Matrix3d.createIdentity());\r\n }\r\n /**\r\n * Create a Transform using the given `origin` and `matrix`.\r\n * * This is the appropriate construction when the columns of the matrix are coordinate axes of a\r\n * local-to-world mapping, and the given point is the axes' origin in world coordinates.\r\n * * This function is closely related to `createFixedPointAndMatrix` whose point input is the fixed point\r\n * of the world-to-world transformation.\r\n * * If origin is `undefined`, (0,0,0) is used. If matrix is `undefined` the identity matrix is used.\r\n */\r\n public static createOriginAndMatrix(\r\n origin: XYZ | undefined, matrix: Matrix3d | undefined, result?: Transform,\r\n ): Transform {\r\n if (result) {\r\n result._origin.setFromPoint3d(origin);\r\n result._matrix.setFrom(matrix);\r\n return result;\r\n }\r\n return Transform.createRefs(\r\n origin ? origin.cloneAsPoint3d() : Point3d.createZero(),\r\n matrix === undefined ? Matrix3d.createIdentity() : matrix.clone(),\r\n result,\r\n );\r\n }\r\n /** Create a Transform using the given `origin` and columns of the `matrix`. If `undefined` zero is used. */\r\n public setOriginAndMatrixColumns(\r\n origin: XYZ | undefined, vectorX: Vector3d | undefined, vectorY: Vector3d | undefined, vectorZ: Vector3d | undefined,\r\n ): void {\r\n if (origin !== undefined)\r\n this._origin.setFrom(origin);\r\n this._matrix.setColumns(vectorX, vectorY, vectorZ);\r\n }\r\n /** Create a Transform using the given `origin` and columns of the `matrix` */\r\n public static createOriginAndMatrixColumns(\r\n origin: XYZ, vectorX: Vector3d, vectorY: Vector3d, vectorZ: Vector3d, result?: Transform,\r\n ): Transform {\r\n if (result)\r\n result.setOriginAndMatrixColumns(origin, vectorX, vectorY, vectorZ);\r\n else\r\n result = Transform.createRefs(Vector3d.createFrom(origin), Matrix3d.createColumns(vectorX, vectorY, vectorZ));\r\n return result;\r\n }\r\n /**\r\n * Create a Transform such that its `matrix` part is rigid.\r\n * @see [[Matrix3d.createRigidFromColumns]] for details of how the matrix is created to be rigid.\r\n */\r\n public static createRigidFromOriginAndColumns(\r\n origin: XYZ | undefined, vectorX: Vector3d, vectorY: Vector3d, axisOrder: AxisOrder, result?: Transform,\r\n ): Transform | undefined {\r\n const matrix = Matrix3d.createRigidFromColumns(vectorX, vectorY, axisOrder, result ? result._matrix : undefined);\r\n if (!matrix)\r\n return undefined;\r\n if (result) {\r\n // result._matrix was already modified to become rigid via createRigidFromColumns\r\n result._origin.setFrom(origin);\r\n return result;\r\n }\r\n /**\r\n * We don't want to pass \"origin\" to createRefs because createRefs does not clone \"origin\". That means if \"origin\"\r\n * is changed via Transform at any point, the initial \"origin\" passed by the user is also changed. To avoid that,\r\n * we pass \"undefined\" to createRefs so that it allocates a new point which then we set it to the \"origin\" which\r\n * is passed by user in the next line.\r\n */\r\n result = Transform.createRefs(undefined, matrix);\r\n result._origin.setFromPoint3d(origin);\r\n return result;\r\n }\r\n /**\r\n * Create a Transform with the specified `matrix`. Compute an `origin` (different from the given `fixedPoint`)\r\n * so that the `fixedPoint` maps back to itself. The returned Transform, transforms a point `p` to `M*p + (f - M*f)`\r\n * where `f` is the fixedPoint (i.e., `Tp = M*(p-f) + f`).\r\n */\r\n public static createFixedPointAndMatrix(\r\n fixedPoint: XYAndZ | undefined, matrix: Matrix3d, result?: Transform,\r\n ): Transform {\r\n if (fixedPoint) {\r\n /**\r\n * if f is a fixed point, then Tf = M*f + o = f where M is the matrix and o is the origin.\r\n * we define the origin o = f - M*f. Therefore, Tf = Mf + o = M*f + (f - M*f) = f.\r\n */\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(fixedPoint, matrix, fixedPoint);\r\n return Transform.createRefs(origin, matrix.clone(), result);\r\n }\r\n return Transform.createRefs(undefined, matrix.clone());\r\n }\r\n /**\r\n * Create a transform with the specified `matrix` and points `a` and `b`. The returned Transform maps\r\n * point `p` to `M*(p-a) + b` (i.e., `Tp = M*(p-a) + b`), so maps `a` to `b`.\r\n */\r\n public static createMatrixPickupPutdown(\r\n matrix: Matrix3d, a: Point3d, b: Point3d, result?: Transform,\r\n ): Transform {\r\n // we define the origin o = b - M*a so Tp = M*p + o = M*p + (b - M*a) = M*(p-a) + b\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(b, matrix, a);\r\n return Transform.createRefs(origin, matrix.clone(), result);\r\n }\r\n /**\r\n * Create a Transform which leaves the fixedPoint unchanged and scales everything else around it by\r\n * a single scale factor. The returned Transform maps a point `p` to `M*p + (f - M*f)`\r\n * where `f` is the fixedPoint and M is the scale matrix (i.e., `Tp = M*(p-f) + f`).\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/CubeTransform\r\n */\r\n public static createScaleAboutPoint(fixedPoint: Point3d, scale: number, result?: Transform): Transform {\r\n const matrix = Matrix3d.createScale(scale, scale, scale);\r\n /**\r\n * if f is a fixed point, then Tf = M*f + o = f where M is the matrix and o is the origin.\r\n * we define the origin o = f - M*f. Therefore, Tf = M*f + o = M*f + (f - M*f) = f.\r\n */\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(fixedPoint, matrix, fixedPoint);\r\n return Transform.createRefs(origin, matrix, result);\r\n }\r\n /**\r\n * Return a transformation which flattens space onto a plane, sweeping along a direction which may be different\r\n * from the plane normal.\r\n * * See [Matrix3d.createFlattenAlongVectorToPlane] for math details.\r\n * @param sweepVector sweep direction. If same as `planeNormal`, the resulting transformation flattens to the plane.\r\n * @param planePoint any point on the plane\r\n * @param planeNormal vector normal to the plane.\r\n */\r\n public static createFlattenAlongVectorToPlane(sweepVector: Vector3d, planePoint: XYAndZ, planeNormal: Vector3d): Transform | undefined {\r\n const matrix = Matrix3d.createFlattenAlongVectorToPlane(sweepVector, planeNormal);\r\n if (matrix === undefined)\r\n return undefined;\r\n return Transform.createFixedPointAndMatrix(planePoint, matrix);\r\n }\r\n /**\r\n * Transform the input 2d point (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyPoint2d(point: XAndY, result?: Point2d): Point2d {\r\n return Matrix3d.xyPlusMatrixTimesXY(this._origin, this._matrix, point, result);\r\n }\r\n /**\r\n * Transform the input 3d point (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyPoint3d(point: XYAndZ, result?: Point3d): Point3d {\r\n // Tx = Mx + o so we return Mx + o\r\n return Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, point, result);\r\n }\r\n /**\r\n * Transform the input 3d point in place (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyXYAndZInPlace(point: XYAndZ): void {\r\n return Matrix3d.xyzPlusMatrixTimesXYZInPlace(this._origin, this._matrix, point);\r\n }\r\n /**\r\n * Transform the input 3d point (using `Tp = M*p + o`).\r\n * Return as a new point or in the pre-allocated result (if result is given).\r\n */\r\n public multiplyXYZ(x: number, y: number, z: number = 0, result?: Point3d): Point3d {\r\n // Tx = Mx + o so we return Mx + o\r\n return Matrix3d.xyzPlusMatrixTimesCoordinates(this._origin, this._matrix, x, y, z, result);\r\n }\r\n /**\r\n * Multiply a specific row (component) of the 3x4 instance times (x,y,z,1). Return the result.\r\n */\r\n public multiplyComponentXYZ(componentIndex: number, x: number, y: number, z: number = 0): number {\r\n const coffs = this._matrix.coffs;\r\n const idx = 3 * componentIndex;\r\n return this.origin.at(componentIndex) + (coffs[idx] * x) + (coffs[idx + 1] * y) + (coffs[idx + 2] * z);\r\n }\r\n /**\r\n * Multiply a specific row (component) of the 3x4 instance times (x,y,z,w). Return the result.\r\n */\r\n public multiplyComponentXYZW(componentIndex: number, x: number, y: number, z: number, w: number): number {\r\n const coffs = this._matrix.coffs;\r\n const idx = 3 * componentIndex;\r\n return (this.origin.at(componentIndex) * w) + (coffs[idx] * x) + (coffs[idx + 1] * y) + (coffs[idx + 2] * z);\r\n }\r\n /**\r\n * Transform the homogeneous point. Return as a new `Point4d`, or in the pre-allocated result (if result is given).\r\n * * If `p = (x,y,z)` then this method computes `Tp = M*p + o*w` and returns the `Point4d` formed by `Tp` in the\r\n * first three coordinates, and `w` in the fourth.\r\n * * Logically, this is multiplication by the 4x4 matrix formed from the 3x4 instance augmented with fourth row 0001.\r\n */\r\n public multiplyXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d {\r\n return Matrix3d.xyzPlusMatrixTimesWeightedCoordinates(this._origin, this._matrix, x, y, z, w, result);\r\n }\r\n /**\r\n * Transform the homogeneous point. Return as new `Float64Array` with size 4, or in the pre-allocated `result` of sufficient size.\r\n * * If `p = (x,y,z)` then this method computes `Tp = M*p + o*w` and returns the `Float64Array` formed by `Tp`\r\n * in the first 3 numbers of the array and `w` as the fourth.\r\n * * Logically, this is multiplication by the 4x4 matrix formed from the 3x4 instance augmented with fourth row 0001.\r\n */\r\n public multiplyXYZWToFloat64Array(x: number, y: number, z: number, w: number, result?: Float64Array): Float64Array {\r\n return Matrix3d.xyzPlusMatrixTimesWeightedCoordinatesToFloat64Array(this._origin, this._matrix, x, y, z, w, result);\r\n }\r\n /**\r\n * * Transform the point. Return as new `Float64Array` with size 3, or in the pre-allocated `result` of sufficient size.\r\n * * If `p = (x,y,z)` then this method computes `Tp = M*p + o` and returns it as the first 3 elements of the array.\r\n */\r\n public multiplyXYZToFloat64Array(x: number, y: number, z: number, result?: Float64Array): Float64Array {\r\n return Matrix3d.xyzPlusMatrixTimesCoordinatesToFloat64Array(this._origin, this._matrix, x, y, z, result);\r\n }\r\n /**\r\n * Multiply the homogeneous point by the transpose of `this` Transform. Return as a new `Point4d` or in the\r\n * pre-allocated result (if result is given).\r\n * * If `p = (x,y,z)` then this method computes `M^t*p` and returns it in the first three coordinates of the `Point4d`,\r\n * and `o*p + w` in the fourth.\r\n * * Logically, this is multiplication by the transpose of the 4x4 matrix formed from the 3x4 instance augmented with\r\n * fourth row 0001.\r\n */\r\n public multiplyTransposeXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d {\r\n const coffs = this._matrix.coffs;\r\n const origin = this._origin;\r\n return Point4d.create(\r\n (x * coffs[0]) + (y * coffs[3]) + (z * coffs[6]),\r\n (x * coffs[1]) + (y * coffs[4]) + (z * coffs[7]),\r\n (x * coffs[2]) + (y * coffs[5]) + (z * coffs[8]),\r\n (x * origin.x) + (y * origin.y) + (z * origin.z) + w,\r\n result,\r\n );\r\n }\r\n /** For each point in the array, replace point by the transformed point (using `Tp = M*p + o`) */\r\n public multiplyPoint3dArrayInPlace(points: Point3d[]) {\r\n let point;\r\n for (point of points)\r\n Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, point, point);\r\n }\r\n /** For each point in the 2d array, replace point by the transformed point (using `Tp = M*p + o`) */\r\n public multiplyPoint3dArrayArrayInPlace(chains: Point3d[][]) {\r\n for (const chain of chains)\r\n this.multiplyPoint3dArrayInPlace(chain);\r\n }\r\n /**\r\n * Multiply the point by the inverse Transform.\r\n * * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse`\r\n * Transform has matrix part `MInverse` and origin part `-MInverse*o`.\r\n * * Return as a new point or in the optional `result`.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInversePoint3d(point: XYAndZ, result?: Point3d): Point3d | undefined {\r\n return this._matrix.multiplyInverseXYZAsPoint3d(\r\n point.x - this._origin.x,\r\n point.y - this._origin.y,\r\n point.z - this._origin.z,\r\n result,\r\n );\r\n }\r\n /**\r\n * Multiply the homogenous point by the inverse Transform.\r\n * * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse` Transform\r\n * has matrix part `MInverse` and origin part `-MInverse*o`.\r\n * * This method computes `TInverse p = MInverse*p - w*MInverse*o` and returns the `Point4d` formed by `TInverse*p`\r\n * in the first three coordinates, and `w` in the fourth.\r\n * * Logically, this is multiplication by the inverse of the 4x4 matrix formed from the 3x4 instance augmented with\r\n * fourth row 0001. This is equivalent to the 4x4 matrix formed in similar fashion from the inverse of this instance.\r\n * * Return as a new point or in the optional `result`.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInversePoint4d(weightedPoint: Point4d, result?: Point4d): Point4d | undefined {\r\n const w = weightedPoint.w;\r\n return this._matrix.multiplyInverseXYZW(\r\n weightedPoint.x - w * this.origin.x,\r\n weightedPoint.y - w * this.origin.y,\r\n weightedPoint.z - w * this.origin.z,\r\n w,\r\n result,\r\n );\r\n }\r\n /**\r\n * Multiply the point by the inverse Transform.\r\n * * If for a point `p` we have `Tp = M*p + o = q`, then `p = MInverse*(q - o) = TInverse q` so `TInverse` Transform\r\n * has matrix part `MInverse` and origin part `-MInverse*o`.\r\n * * Return as a new point or in the optional `result`.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInverseXYZ(x: number, y: number, z: number, result?: Point3d): Point3d | undefined {\r\n return this._matrix.multiplyInverseXYZAsPoint3d(\r\n x - this._origin.x,\r\n y - this._origin.y,\r\n z - this._origin.z,\r\n result,\r\n );\r\n }\r\n /**\r\n * * Compute (if needed) the inverse of the `matrix` part of the Transform, thereby ensuring inverse\r\n * operations can complete.\r\n * @param useCached If true, accept prior cached inverse if available.\r\n * @returns `true` if matrix inverse completes, `false` otherwise.\r\n */\r\n public computeCachedInverse(useCached: boolean = true): boolean {\r\n return this._matrix.computeCachedInverse(useCached);\r\n }\r\n /**\r\n * Match the length of destination array with the length of source array\r\n * * If destination has more elements than source, remove the extra elements.\r\n * * If destination has fewer elements than source, use `constructionFunction` to create new elements.\r\n * *\r\n * @param source the source array\r\n * @param dest the destination array\r\n * @param constructionFunction function to call to create new elements.\r\n */\r\n public static matchArrayLengths(source: any[], dest: any[], constructionFunction: () => any): number {\r\n const numSource = source.length;\r\n const numDest = dest.length;\r\n if (numSource > numDest) {\r\n for (let i = numDest; i < numSource; i++) {\r\n dest.push(constructionFunction());\r\n }\r\n } else if (numDest > numSource) {\r\n dest.length = numSource;\r\n }\r\n return numSource;\r\n }\r\n /**\r\n * Multiply each point in the array by the inverse of `this` Transform.\r\n * * For a transform `T = [M o]` the inverse transform `T' = [M' -M'o]` exists if and only if `M` has an inverse\r\n * `M'`. Indeed, for any point `p`, we have `T'Tp = T'(Mp + o) = M'(Mp + o) - M'o = M'Mp + M'o - M'o = p.`\r\n * * If `result` is given, resize it to match the input `points` array and update it with original points `p[]`.\r\n * * If `result` is not given, return a new array.\r\n * * Returns `undefined` if the `matrix` part if this Transform is singular.\r\n */\r\n public multiplyInversePoint3dArray(points: Point3d[], result?: Point3d[]): Point3d[] | undefined {\r\n if (!this._matrix.computeCachedInverse(true))\r\n return undefined;\r\n const originX = this.origin.x;\r\n const originY = this.origin.y;\r\n const originZ = this.origin.z;\r\n if (result) {\r\n const n = Transform.matchArrayLengths(points, result, () => Point3d.createZero());\r\n for (let i = 0; i < n; i++)\r\n this._matrix.multiplyInverseXYZAsPoint3d(\r\n points[i].x - originX,\r\n points[i].y - originY,\r\n points[i].z - originZ,\r\n result[i],\r\n );\r\n return result;\r\n }\r\n result = [];\r\n for (const point of points)\r\n result.push(\r\n this._matrix.multiplyInverseXYZAsPoint3d(\r\n point.x - originX,\r\n point.y - originY,\r\n point.z - originZ,\r\n )!,\r\n );\r\n return result;\r\n }\r\n /**\r\n * Multiply each point in the array by the inverse of `this` Transform in place.\r\n * * For a transform `T = [M o]` the inverse transform `T' = [M' -M'o]` exists if and only if `M` has an inverse\r\n * `M'`. Indeed, for any point `p`, we have `T'Tp = T'(Mp + o) = M'(Mp + o) - M'o = M'Mp + M'o - M'o = p.`\r\n * * Returns `true` if the `matrix` part if this Transform is invertible and `false` if singular.\r\n */\r\n public multiplyInversePoint3dArrayInPlace(points: Point3d[]): boolean {\r\n if (!this._matrix.computeCachedInverse(true))\r\n return false;\r\n for (const point of points)\r\n this._matrix.multiplyInverseXYZAsPoint3d(\r\n point.x - this.origin.x,\r\n point.y - this.origin.y,\r\n point.z - this.origin.z,\r\n point,\r\n );\r\n return true;\r\n }\r\n /**\r\n * Transform the input 2d point array (using `Tp = M*p + o`).\r\n * * If `result` is given, resize it to match the input `points` array and update it with transformed points.\r\n * * If `result` is not given, return a new array.\r\n */\r\n public multiplyPoint2dArray(points: Point2d[], result?: Point2d[]): Point2d[] {\r\n if (result) {\r\n const n = Transform.matchArrayLengths(points, result, () => Point2d.createZero());\r\n for (let i = 0; i < n; i++)\r\n Matrix3d.xyPlusMatrixTimesXY(this._origin, this._matrix, points[i], result[i]);\r\n return result;\r\n }\r\n result = [];\r\n for (const p of points)\r\n result.push(Matrix3d.xyPlusMatrixTimesXY(this._origin, this._matrix, p));\r\n return result;\r\n }\r\n /**\r\n * Transform the input 3d point array (using `Tp = M*p + o`).\r\n * * If `result` is given, resize it to match the input `points` array and update it with transformed points.\r\n * * If `result` is not given, return a new array.\r\n */\r\n public multiplyPoint3dArray(points: Point3d[], result?: Point3d[]): Point3d[] {\r\n if (result) {\r\n const n = Transform.matchArrayLengths(points, result, () => Point3d.createZero());\r\n for (let i = 0; i < n; i++)\r\n Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, points[i], result[i]);\r\n return result;\r\n }\r\n result = [];\r\n for (const p of points)\r\n result.push(Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, p));\r\n return result;\r\n }\r\n /**\r\n * Multiply the vector by the `matrix` part of the Transform.\r\n * * The `origin` part of Transform is not used.\r\n * * If `result` is given, update it with the multiplication. Otherwise, create a new Vector3d.\r\n */\r\n public multiplyVector(vector: Vector3d, result?: Vector3d): Vector3d {\r\n return this._matrix.multiplyVector(vector, result);\r\n }\r\n /**\r\n * Multiply the vector by the `matrix` part of the Transform in place.\r\n * * The `origin` part of Transform is not used.\r\n */\r\n public multiplyVectorInPlace(vector: Vector3d): void {\r\n this._matrix.multiplyVectorInPlace(vector);\r\n }\r\n /**\r\n * Multiply the vector (x,y,z) by the `matrix` part of the Transform.\r\n * * The `origin` part of Transform is not used.\r\n * * If `result` is given, update it with the multiplication. Otherwise, create a new Vector3d.\r\n */\r\n public multiplyVectorXYZ(x: number, y: number, z: number, result?: Vector3d): Vector3d {\r\n return this._matrix.multiplyXYZ(x, y, z, result);\r\n }\r\n /**\r\n * Calculate `transformA * transformB` and store it into the calling instance (`this`).\r\n * * **Note:** If `transformA = [A a]` and `transformB = [B b]` then `transformA * transformB` is defined as\r\n * `[A*B Ab+a]`.\r\n * * @see [[multiplyTransformTransform]] documentation for math details.\r\n * @param transformA first operand\r\n * @param transformB second operand\r\n */\r\n public setMultiplyTransformTransform(transformA: Transform, transformB: Transform): void {\r\n Matrix3d.xyzPlusMatrixTimesXYZ(\r\n transformA._origin,\r\n transformA._matrix,\r\n transformB._origin,\r\n this._origin as Point3d,\r\n );\r\n transformA._matrix.multiplyMatrixMatrix(transformB._matrix, this._matrix);\r\n }\r\n /**\r\n * Multiply `this` Transform times `other` Transform.\r\n * * **Note:** If `this = [A a]` and `other = [B b]` then `this * other` is defined as `[A*B Ab+a]` because:\r\n * ```\r\n * equation\r\n * \\begin{matrix}\r\n * \\text{this Transform with matrix part }\\bold{A}\\text{ and origin part }\\bold{a} & \\blockTransform{A}{a}\\\\\r\n * \\text{other Transform with matrix part }\\bold{B}\\text{ and origin part }\\bold{b} & \\blockTransform{B}{b} \\\\\r\n * \\text{product}& \\blockTransform{A}{a}\\blockTransform{B}{b}=\\blockTransform{AB}{Ab + a}\r\n * \\end{matrix}\r\n * ```\r\n * @param other the `other` Transform to be multiplied to `this` Transform.\r\n * @param result optional preallocated `result` to reuse.\r\n */\r\n public multiplyTransformTransform(other: Transform, result?: Transform) {\r\n if (!result)\r\n return Transform.createRefs(\r\n Matrix3d.xyzPlusMatrixTimesXYZ(this._origin, this._matrix, other._origin),\r\n this._matrix.multiplyMatrixMatrix(other._matrix),\r\n );\r\n result.setMultiplyTransformTransform(this, other);\r\n return result;\r\n }\r\n /**\r\n * Multiply `this` Transform times `other` Matrix3d (considered to be a Transform with 0 `origin`).\r\n * * **Note:** If `this = [A a]` and `other = [B 0]`, then `this * other` is defined as [A*B a] because:\r\n * ```\r\n * equation\r\n * \\begin{matrix}\r\n * \\text{this Transform with matrix part }\\bold{A}\\text{ and origin part }\\bold{a} & \\blockTransform{A}{a}\\\\\r\n * \\text{other matrix }\\bold{B}\\text{ promoted to block Transform} & \\blockTransform{B}{0} \\\\\r\n * \\text{product}& \\blockTransform{A}{a}\\blockTransform{B}{0}=\\blockTransform{AB}{a}\r\n * \\end{matrix}\r\n * ```\r\n * @param other the `other` Matrix3d to be multiplied to `this` Transform.\r\n * @param result optional preallocated `result` to reuse.\r\n */\r\n public multiplyTransformMatrix3d(other: Matrix3d, result?: Transform): Transform {\r\n if (!result)\r\n return Transform.createRefs(\r\n this._origin.cloneAsPoint3d(),\r\n this._matrix.multiplyMatrixMatrix(other),\r\n );\r\n this._matrix.multiplyMatrixMatrix(other, result._matrix);\r\n result._origin.setFrom(this._origin);\r\n return result;\r\n }\r\n /**\r\n * Return the range of the transformed corners.\r\n * * The 8 corners are transformed individually.\r\n * * **Note:** Suppose you have a geometry, a range box around that geometry, and your Transform is a rotation.\r\n * If you rotate the range box and recompute a new range box around the rotated range box, then the new range\r\n * box will have a larger volume than the original range box. However, if you rotate the geometry itself and\r\n * then recompute the range box, it will be a tighter range box around the rotated geometry. `multiplyRange`\r\n * function creates the larger range box because it only has access to the range box and not the geometry itself.\r\n */\r\n public multiplyRange(range: Range3d, result?: Range3d): Range3d {\r\n if (range.isNull)\r\n return range.clone(result);\r\n const lowX = range.low.x;\r\n const lowY = range.low.y;\r\n const lowZ = range.low.z;\r\n const highX = range.high.x;\r\n const highY = range.high.y;\r\n const highZ = range.high.z;\r\n result = Range3d.createNull(result);\r\n result.extendTransformedXYZ(this, lowX, lowY, lowZ);\r\n result.extendTransformedXYZ(this, highX, lowY, lowZ);\r\n result.extendTransformedXYZ(this, lowX, highY, lowZ);\r\n result.extendTransformedXYZ(this, highX, highY, lowZ);\r\n result.extendTransformedXYZ(this, lowX, lowY, highZ);\r\n result.extendTransformedXYZ(this, highX, lowY, highZ);\r\n result.extendTransformedXYZ(this, lowX, highY, highZ);\r\n result.extendTransformedXYZ(this, highX, highY, highZ);\r\n return result;\r\n }\r\n /**\r\n * Return a Transform which is the inverse of `this` Transform.\r\n * * If `transform = [M o]` then `transformInverse = [MInverse -MInverse*o]`\r\n * * Return `undefined` if this Transform's matrix is singular.\r\n */\r\n public inverse(result?: Transform): Transform | undefined {\r\n const matrixInverse = this._matrix.inverse(result ? result._matrix : undefined);\r\n if (!matrixInverse)\r\n return undefined;\r\n if (result) {\r\n // result._matrix is already defined\r\n matrixInverse.multiplyXYZ(-this._origin.x, -this._origin.y, -this._origin.z, result._origin as Vector3d);\r\n return result;\r\n }\r\n return Transform.createRefs(\r\n matrixInverse.multiplyXYZ(-this._origin.x, -this._origin.y, -this._origin.z),\r\n matrixInverse,\r\n );\r\n }\r\n /**\r\n * Initialize 2 Transforms that map between the unit box (specified by 000 and 111) and the range box specified\r\n * by the input points.\r\n * @param min the min corner of the range box\r\n * @param max the max corner of the range box\r\n * @param npcToGlobal maps NPC coordinates into range box coordinates. Specifically, maps 000 to `min` and maps\r\n * 111 to `max`. This Transform is the inverse of `globalToNpc`. Object created by caller, re-initialized here.\r\n * @param globalToNpc maps range box coordinates into NPC coordinates. Specifically, maps `min` to 000 and maps\r\n * `max` to 111. This Transform is the inverse of `npcToGlobal`. Object created by caller, re-initialized here.\r\n * * NPC stands for `Normalized Projection Coordinate`\r\n */\r\n public static initFromRange(min: Point3d, max: Point3d, npcToGlobal?: Transform, globalToNpc?: Transform): void {\r\n const diag = max.minus(min);\r\n if (diag.x === 0.0)\r\n diag.x = 1.0;\r\n if (diag.y === 0.0)\r\n diag.y = 1.0;\r\n if (diag.z === 0.0)\r\n diag.z = 1.0;\r\n const rMatrix = new Matrix3d();\r\n /**\r\n * [diag.x 0 0 min.x]\r\n * npcToGlobal = [ 0 diag.y 0 min.y]\r\n * [ 0 0 diag.y min.z]\r\n *\r\n * npcToGlobal * 0 = min\r\n * npcToGlobal * 1 = diag + min = max\r\n */\r\n if (npcToGlobal) {\r\n Matrix3d.createScale(diag.x, diag.y, diag.z, rMatrix);\r\n Transform.createOriginAndMatrix(min, rMatrix, npcToGlobal);\r\n }\r\n /**\r\n * [1/diag.x 0 0 -min.x/diag.x]\r\n * globalToNpc = [ 0 1/diag.y 0 -min.y/diag.y]\r\n * [ 0 0 1/diag.y -min.z/diag.z]\r\n *\r\n * globalToNpc * min = min/diag - min/diag = 0\r\n * globalToNpc * max = max/diag - min/diag = diag/diag = 1\r\n */\r\n if (globalToNpc) {\r\n const origin = new Point3d(-min.x / diag.x, -min.y / diag.y, -min.z / diag.z);\r\n Matrix3d.createScale(1.0 / diag.x, 1.0 / diag.y, 1.0 / diag.z, rMatrix);\r\n Transform.createOriginAndMatrix(origin, rMatrix, globalToNpc);\r\n }\r\n }\r\n}\r\n"]}
@@ -49,11 +49,11 @@ export declare class Map4d implements BeJSONFunctions {
49
49
  /** Test if both matrices are almost equal to those */
50
50
  isAlmostEqual(other: Map4d): boolean;
51
51
  /**
52
- * Create a map between a frustum and world coordinates.
53
- * @param origin lower left of frustum
54
- * @param uVector Vector from lower left rear to lower right rear.
55
- * @param vVector Vector from lower left rear to upper left rear.
56
- * @param wVector Vector from lower left rear to lower left front, i.e. lower left rear towards eye.
52
+ * Create a world to NPC map that maps between world coordinates and the given frustum.
53
+ * @param origin lower left rear of frustum
54
+ * @param uVector Vector from origin to lower right rear.
55
+ * @param vVector Vector from origin to upper left rear.
56
+ * @param wVector Vector from origin to lower left front, i.e. origin towards eye.
57
57
  * @param fraction front size divided by rear size.
58
58
  */
59
59
  static createVectorFrustum(origin: Point3d, uVector: Vector3d, vVector: Vector3d, wVector: Vector3d, fraction: number): Map4d | undefined;