@itwin/core-geometry 4.10.0-dev.26 → 4.10.0-dev.28

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 (117) hide show
  1. package/lib/cjs/core-geometry.d.ts +1 -1
  2. package/lib/cjs/core-geometry.d.ts.map +1 -1
  3. package/lib/cjs/core-geometry.js +1 -1
  4. package/lib/cjs/core-geometry.js.map +1 -1
  5. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  6. package/lib/cjs/curve/Arc3d.js +2 -1
  7. package/lib/cjs/curve/Arc3d.js.map +1 -1
  8. package/lib/cjs/curve/CurveFactory.d.ts +1 -1
  9. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  10. package/lib/cjs/curve/CurveFactory.js +3 -3
  11. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  12. package/lib/cjs/curve/LineSegment3d.js +2 -2
  13. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  14. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  15. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +3 -2
  16. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  17. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  18. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +7 -6
  19. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  20. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  21. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +3 -2
  22. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  23. package/lib/cjs/geometry3d/BilinearPatch.js +4 -4
  24. package/lib/cjs/geometry3d/BilinearPatch.js.map +1 -1
  25. package/lib/cjs/geometry3d/Matrix3d.d.ts +26 -16
  26. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  27. package/lib/cjs/geometry3d/Matrix3d.js +34 -16
  28. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  29. package/lib/cjs/geometry3d/Ray3d.js +2 -2
  30. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  31. package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
  32. package/lib/cjs/geometry4d/Point4d.js +2 -1
  33. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  34. package/lib/cjs/numerics/Newton.d.ts +3 -0
  35. package/lib/cjs/numerics/Newton.d.ts.map +1 -1
  36. package/lib/cjs/numerics/Newton.js +2 -5
  37. package/lib/cjs/numerics/Newton.js.map +1 -1
  38. package/lib/cjs/numerics/Polynomials.d.ts +22 -178
  39. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  40. package/lib/cjs/numerics/Polynomials.js +62 -360
  41. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  42. package/lib/cjs/numerics/SmallSystem.d.ts +164 -0
  43. package/lib/cjs/numerics/SmallSystem.d.ts.map +1 -0
  44. package/lib/cjs/numerics/SmallSystem.js +321 -0
  45. package/lib/cjs/numerics/SmallSystem.js.map +1 -0
  46. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
  47. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
  48. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js +7 -7
  49. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  50. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  51. package/lib/cjs/topology/Graph.js +2 -2
  52. package/lib/cjs/topology/Graph.js.map +1 -1
  53. package/lib/cjs/topology/InsertAndRetriangulateContext.js +2 -2
  54. package/lib/cjs/topology/InsertAndRetriangulateContext.js.map +1 -1
  55. package/lib/cjs/topology/Merging.d.ts +1 -1
  56. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  57. package/lib/cjs/topology/Merging.js +2 -2
  58. package/lib/cjs/topology/Merging.js.map +1 -1
  59. package/lib/esm/core-geometry.d.ts +1 -1
  60. package/lib/esm/core-geometry.d.ts.map +1 -1
  61. package/lib/esm/core-geometry.js +1 -1
  62. package/lib/esm/core-geometry.js.map +1 -1
  63. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  64. package/lib/esm/curve/Arc3d.js +2 -1
  65. package/lib/esm/curve/Arc3d.js.map +1 -1
  66. package/lib/esm/curve/CurveFactory.d.ts +1 -1
  67. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  68. package/lib/esm/curve/CurveFactory.js +1 -1
  69. package/lib/esm/curve/CurveFactory.js.map +1 -1
  70. package/lib/esm/curve/LineSegment3d.js +1 -1
  71. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  72. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  73. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +2 -1
  74. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  75. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  76. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +2 -1
  77. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  78. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  79. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +2 -1
  80. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  81. package/lib/esm/geometry3d/BilinearPatch.js +1 -1
  82. package/lib/esm/geometry3d/BilinearPatch.js.map +1 -1
  83. package/lib/esm/geometry3d/Matrix3d.d.ts +26 -16
  84. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  85. package/lib/esm/geometry3d/Matrix3d.js +34 -16
  86. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  87. package/lib/esm/geometry3d/Ray3d.js +1 -1
  88. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  89. package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
  90. package/lib/esm/geometry4d/Point4d.js +2 -1
  91. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  92. package/lib/esm/numerics/Newton.d.ts +3 -0
  93. package/lib/esm/numerics/Newton.d.ts.map +1 -1
  94. package/lib/esm/numerics/Newton.js +1 -4
  95. package/lib/esm/numerics/Newton.js.map +1 -1
  96. package/lib/esm/numerics/Polynomials.d.ts +22 -178
  97. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  98. package/lib/esm/numerics/Polynomials.js +62 -359
  99. package/lib/esm/numerics/Polynomials.js.map +1 -1
  100. package/lib/esm/numerics/SmallSystem.d.ts +164 -0
  101. package/lib/esm/numerics/SmallSystem.d.ts.map +1 -0
  102. package/lib/esm/numerics/SmallSystem.js +317 -0
  103. package/lib/esm/numerics/SmallSystem.js.map +1 -0
  104. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
  105. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
  106. package/lib/esm/polyface/multiclip/OffsetMeshContext.js +4 -4
  107. package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  108. package/lib/esm/topology/Graph.d.ts.map +1 -1
  109. package/lib/esm/topology/Graph.js +1 -1
  110. package/lib/esm/topology/Graph.js.map +1 -1
  111. package/lib/esm/topology/InsertAndRetriangulateContext.js +1 -1
  112. package/lib/esm/topology/InsertAndRetriangulateContext.js.map +1 -1
  113. package/lib/esm/topology/Merging.d.ts +1 -1
  114. package/lib/esm/topology/Merging.d.ts.map +1 -1
  115. package/lib/esm/topology/Merging.js +1 -1
  116. package/lib/esm/topology/Merging.js.map +1 -1
  117. package/package.json +3 -3
@@ -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,GAAG,SAAS,CAAC;IACrB,CAAC;IACO,MAAM,CAA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------------------------------------------------------------------------\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,IAAI,KAAK,CAAC,yBAAO,CAAC,MAAM,CAAC,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,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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Point4d.d.ts","sourceRoot":"","sources":["../../../src/geometry4d/Point4d.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAY,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC;AAgBpC;;;;;;;GAOG;AACH,qBAAa,OAAQ,SAAQ,OAAQ,YAAW,eAAe;IAC7D,6CAA6C;IACtC,IAAI,EAAE,YAAY,CAAC;IAC1B,kCAAkC;IAC3B,GAAG,CAAC,CAAC,GAAE,MAAU,EAAE,CAAC,GAAE,M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AY1B,6EAA6E;WAC/D,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAqDtI;;OAEG;IACI,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;CAShE"}
@@ -366,7 +366,8 @@ class Point4d extends Plane3d_1.Plane3d {
366
366
  projectPointToPlane(spacePoint, result) {
367
367
  const h = this.altitude(spacePoint);
368
368
  const nn = this.magnitudeSquaredXYZ();
369
- const alpha = Geometry_1.Geometry.conditionalDivideCoordinate(-h, nn);
369
+ // this unusual tol is needed so that toPlane3dByOriginAndUnitNormal agrees with its original implementation
370
+ const alpha = Geometry_1.Geometry.conditionalDivideCoordinate(-h, nn, Geometry_1.Geometry.largeFractionResult * Geometry_1.Geometry.largeFractionResult);
370
371
  if (alpha === undefined)
371
372
  return spacePoint.clone(result);
372
373
  return spacePoint.plusXYZ(alpha * this.x, alpha * this.y, alpha * this.z, result);
@@ -1 +1 @@
1
- {"version":3,"file":"Point4d.js","sourceRoot":"","sources":["../../../src/geometry4d/Point4d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,0CAAgF;AAChF,mDAAgD;AAChD,6FAA0F;AAC1F,uFAAoF;AACpF,mEAAwD;AACxD,mEAAkE;AAClE,+CAA4C;AAQ5C;;;;;;;;;GASG;AACH,SAAS,mBAAmB,CAAC,GAAW,EAAE,EAAU,EAAE,GAAW,EAC/D,CAAS,EAAE,EAAU,EAAE,IAAY;IACnC,OAAO,IAAI,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;GAOG;AACH,MAAa,OAAQ,SAAQ,iBAAO;IAGlC,kCAAkC;IAC3B,GAAG,CAAC,IAAY,CAAC,EAAE,IAAY,CA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G;YAChB,GAAG,GAAG,GAAG,CAAC;QAEZ,oCAAoC;QACpC,MAAM,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAE,0DAA0D;QACxF,EAAE,CAAC,mBAAmB,EAAE,CAAC;QAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,oBAAoB,GAAG,KAAK,GAAG,iBAAiB,CAAC;QACvD,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC1G,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;OAEG;IACI,oBAAoB,CAAC,KAAc;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,+BAA+B;QACpE,MAAM,GAAG,GAAG,mBAAQ,CAAC,yBAAyB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS;YACnB,OAAO,SAAS,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACF;AAxkBD,0BAwkBC","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 Numerics\r\n */\r\nimport { BeJSONFunctions, Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Plane3d } from \"../geometry3d/Plane3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { XAndY, XYAndZ } from \"../geometry3d/XYZProps\";\r\n\r\n/**\r\n * 4d point packed in an array of 4 numbers.\r\n * @public\r\n */\r\nexport type Point4dProps = number[];\r\n/**\r\n *\r\n * @param ddg numerator second derivative\r\n * @param dh denominator derivative\r\n * @param ddh denominator second derivative\r\n * @param f primary function (g/h)\r\n * @param df derivative of (g/h)\r\n * @param divH = (1/h)\r\n * @internal\r\n */\r\nfunction quotientDerivative2(ddg: number, dh: number, ddh: number,\r\n f: number, df: number, divH: number): number {\r\n return divH * (ddg - 2.0 * df * dh - f * ddh);\r\n}\r\n\r\n/** 4 Dimensional point (x,y,z,w) used in perspective calculations.\r\n * * the coordinates are stored in a Float64Array of length 4.\r\n * * properties `x`, `y`, `z`, `w` access array members.\r\n * *\r\n * * The coordinates are physically stored as a single Float64Array with 4 entries. (w last)\r\n * *\r\n * @public\r\n */\r\nexport class Point4d extends Plane3d implements BeJSONFunctions {\r\n /** x,y,z,w are packed into a Float64Array */\r\n public xyzw: Float64Array;\r\n /** Set x,y,z,w of this point. */\r\n public set(x: number = 0, y: number = 0, z: number = 0, w: number = 0): Point4d {\r\n this.xyzw[0] = x;\r\n this.xyzw[1] = y;\r\n this.xyzw[2] = z;\r\n this.xyzw[3] = w;\r\n return this;\r\n }\r\n /** Set a component by index.\r\n * * No change if index is out of range.\r\n */\r\n public setComponent(index: number, value: number) {\r\n if (index >= 0 && index < 4) {\r\n this.xyzw[index] = value;\r\n }\r\n }\r\n /** The x component. */\r\n public get x() { return this.xyzw[0]; }\r\n public set x(val: number) { this.xyzw[0] = val; }\r\n /** The y component. */\r\n public get y() { return this.xyzw[1]; }\r\n public set y(val: number) { this.xyzw[1] = val; }\r\n /** The z component. */\r\n public get z() { return this.xyzw[2]; }\r\n public set z(val: number) { this.xyzw[2] = val; }\r\n /** The w component of this point. */\r\n public get w() { return this.xyzw[3]; }\r\n public set w(val: number) { this.xyzw[3] = val; }\r\n /** Construct from coordinates. */\r\n protected constructor(x: number = 0, y: number = 0, z: number = 0, w: number = 0) {\r\n super();\r\n this.xyzw = new Float64Array(4);\r\n this.xyzw[0] = x;\r\n this.xyzw[1] = y;\r\n this.xyzw[2] = z;\r\n this.xyzw[3] = w;\r\n }\r\n /** Return a Point4d with specified x,y,z,w */\r\n public static create(x: number = 0, y: number = 0, z: number = 0, w: number = 0, result?: Point4d): Point4d {\r\n return result ? result.set(x, y, z, w) : new Point4d(x, y, z, w);\r\n }\r\n /**\r\n * Create a \"Point4d as a plane\" from \"any\" other [[PlaneAltitudeEvaluator]] type.\r\n * @param source\r\n * @returns\r\n */\r\n public static createPlaneFrom(source: PlaneAltitudeEvaluator): Point4d | undefined {\r\n return new Point4d(source.normalX(), source.normalY(), source.normalZ(), source.altitudeXYZ(0, 0, 0));\r\n }\r\n /** Copy coordinates from `other`. */\r\n public setFrom(other: Point4d): Point4d {\r\n this.xyzw[0] = other.xyzw[0];\r\n this.xyzw[1] = other.xyzw[1];\r\n this.xyzw[2] = other.xyzw[2];\r\n this.xyzw[3] = other.xyzw[3];\r\n return this;\r\n }\r\n /** Clone this point */\r\n public clone(result?: Point4d): Point4d {\r\n return result ? result.setFrom(this) : new Point4d(this.xyzw[0], this.xyzw[1], this.xyzw[2], this.xyzw[3]);\r\n }\r\n /** Set this point's xyzw from a json array `[x,y,z,w]` */\r\n public setFromJSON(json?: Point4dProps) {\r\n if (Geometry.isNumberArray(json, 4))\r\n this.set(json[0], json[1], json[2], json[3]);\r\n else\r\n this.set(0, 0, 0, 0);\r\n }\r\n\r\n /** Create a new point with coordinates from a json array `[x,y,z,w]` */\r\n public static fromJSON(json?: Point4dProps): Point4d {\r\n const result = new Point4d();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /** Near-equality test, using `Geometry.isSameCoordinate` on all 4 x,y,z,w */\r\n public isAlmostEqual(other: Point4d): boolean {\r\n return Geometry.isSameCoordinate(this.x, other.x)\r\n && Geometry.isSameCoordinate(this.y, other.y)\r\n && Geometry.isSameCoordinate(this.z, other.z)\r\n && Geometry.isSameCoordinate(this.w, other.w);\r\n }\r\n /**\r\n * Test for same coordinate by direct x,y,z,w args\r\n * @param x x to test\r\n * @param y y to test\r\n * @param z z to test\r\n * @param w w to test\r\n */\r\n public isAlmostEqualXYZW(x: number, y: number, z: number, w: number): boolean {\r\n return Geometry.isSameCoordinate(this.x, x)\r\n && Geometry.isSameCoordinate(this.y, y)\r\n && Geometry.isSameCoordinate(this.z, z)\r\n && Geometry.isSameCoordinate(this.w, w);\r\n }\r\n\r\n /**\r\n * Convert an Angle to a JSON object.\r\n * @return {*} [x,y,z,w]\r\n */\r\n public toJSON(): Point4dProps {\r\n return [this.xyzw[0], this.xyzw[1], this.xyzw[2], this.xyzw[3]];\r\n }\r\n /** Return the 4d distance from this point to other, with all 4 components squared into the hypotenuse.\r\n * * x,y,z,w all participate without normalization.\r\n */\r\n public distanceXYZW(other: Point4d): number {\r\n return Geometry.hypotenuseXYZW(other.xyzw[0] - this.xyzw[0], other.xyzw[1] - this.xyzw[1], other.xyzw[2] - this.xyzw[2], other.xyzw[3] - this.xyzw[3]);\r\n }\r\n /** Return the squared 4d distance from this point to other, with all 4 components squared into the hypotenuse.\r\n * * x,y,z,w all participate without normalization.\r\n */\r\n public distanceSquaredXYZW(other: Point4d): number {\r\n return Geometry.hypotenuseSquaredXYZW(other.xyzw[0] - this.xyzw[0], other.xyzw[1] - this.xyzw[1], other.xyzw[2] - this.xyzw[2], other.xyzw[3] - this.xyzw[3]);\r\n }\r\n /** Return the distance between the instance and other after normalizing by weights\r\n */\r\n public realDistanceXY(other: Point4d): number | undefined {\r\n const wA = this.w;\r\n const wB = other.w;\r\n if (Geometry.isSmallMetricDistance(wA) || Geometry.isSmallMetricDistance(wB))\r\n return undefined;\r\n return Geometry.hypotenuseXY(other.xyzw[0] / wB - this.xyzw[0] / wA, other.xyzw[1] / wB - this.xyzw[1] / wA);\r\n }\r\n /** Return the largest absolute distance between corresponding components\r\n * * x,y,z,w all participate without normalization.\r\n */\r\n public maxDiff(other: Point4d): number {\r\n return Math.max(Math.abs(other.xyzw[0] - this.xyzw[0]), Math.abs(other.xyzw[1] - this.xyzw[1]), Math.abs(other.xyzw[2] - this.xyzw[2]), Math.abs(other.xyzw[3] - this.xyzw[3]));\r\n }\r\n /** Return the largest absolute entry of all 4 components x,y,z,w */\r\n public maxAbs(): number {\r\n return Math.max(Math.abs(this.xyzw[0]), Math.abs(this.xyzw[1]), Math.abs(this.xyzw[2]), Math.abs(this.xyzw[3]));\r\n }\r\n /** Returns the magnitude including all 4 components x,y,z,w */\r\n public magnitudeXYZW(): number {\r\n return Geometry.hypotenuseXYZW(this.xyzw[0], this.xyzw[1], this.xyzw[2], this.xyzw[3]);\r\n }\r\n /** Returns the magnitude of the leading xyz components. w is ignored. (i.e. the leading xyz are NOT divided by w.) */\r\n public magnitudeSquaredXYZ(): number {\r\n return Geometry.hypotenuseSquaredXYZ(this.xyzw[0], this.xyzw[1], this.xyzw[2]);\r\n }\r\n\r\n /** Return the difference (this-other) using all 4 components x,y,z,w */\r\n public minus(other: Point4d, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] - other.xyzw[0], this.xyzw[1] - other.xyzw[1], this.xyzw[2] - other.xyzw[2], this.xyzw[3] - other.xyzw[3], result);\r\n }\r\n /** Return `((other.w * this) - (this.w * other))` */\r\n public crossWeightedMinus(other: Point4d, result?: Vector3d): Vector3d {\r\n const wa = this.xyzw[3];\r\n const wb = other.xyzw[3];\r\n return Vector3d.create(wb * this.xyzw[0] - wa * other.xyzw[0], wb * this.xyzw[1] - wa * other.xyzw[1], wb * this.xyzw[2] - wa * other.xyzw[2], result);\r\n }\r\n /** Return `((other.w * this) - (this.w * other))`, with other.w known to be 1 */\r\n public crossWeightedMinusPoint3d(other: Point3d, result?: Vector3d): Vector3d {\r\n const wa = this.xyzw[3];\r\n return Vector3d.create(this.xyzw[0] - wa * other.x, this.xyzw[1] - wa * other.y, this.xyzw[2] - wa * other.z, result);\r\n }\r\n /** Return the sum of this and other, using all 4 components x,y,z,w */\r\n public plus(other: Point4d, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + other.xyzw[0], this.xyzw[1] + other.xyzw[1], this.xyzw[2] + other.xyzw[2], this.xyzw[3] + other.xyzw[3], result);\r\n }\r\n /** Test if all components are nearly zero. */\r\n public get isAlmostZero(): boolean {\r\n return Geometry.isSmallMetricDistance(this.maxAbs());\r\n }\r\n /** Create a point with zero in all coordinates. */\r\n public static createZero(): Point4d { return new Point4d(0, 0, 0, 0); }\r\n /**\r\n * Create plane coefficients for the plane containing pointA, pointB, and 0010.\r\n * @param pointA first point\r\n * @param pointB second point\r\n */\r\n public static createPlanePointPointZ(pointA: Point4d, pointB: Point4d, result?: Point4d) {\r\n return Point4d.create(pointA.y * pointB.w - pointA.w * pointB.y, pointA.w * pointB.x - pointA.x * pointB.w, 0.0, pointA.x * pointB.y - pointA.y * pointB.x, result);\r\n }\r\n /**\r\n * extract 3 consecutive numbers from a Float64Array into the xyz values of a Point4d with w = 1.\r\n * @param data buffer of numbers\r\n * @param xIndex first index for x,y,z sequence\r\n */\r\n public static createFromPackedXYZ(data: Float64Array, xIndex: number = 0, result?: Point4d): Point4d | undefined {\r\n if (xIndex >= 0 && xIndex + 2 < data.length)\r\n return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], 1.0, result);\r\n return undefined;\r\n }\r\n /**\r\n * extract 4 consecutive numbers from a Float64Array into a Point4d.\r\n * @param data buffer of numbers\r\n * @param xIndex first index for x,y,z,w sequence\r\n */\r\n public static createFromPacked(data: Float64Array, xIndex: number = 0, result?: Point4d): Point4d | undefined {\r\n if (xIndex >= 0 && xIndex + 3 < data.length)\r\n return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], data[xIndex + 3], result);\r\n return undefined;\r\n }\r\n /**\r\n * extract 4 consecutive numbers from a Float64Array into a Point4d.\r\n * @param data buffer of numbers\r\n * @param xIndex first index for x,y,z,w sequence. Assumed to be a valid index!\r\n * @deprecated in 4.x. Use createFromPacked instead.\r\n */\r\n public static createFromPackedXYZW(data: Float64Array, xIndex: number = 0, result?: Point4d): Point4d {\r\n return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], data[xIndex + 3], result);\r\n }\r\n /** Create a `Point4d` with x,y,z from an `XYAndZ` input, and w from a separate number. */\r\n public static createFromPointAndWeight(xyz: XYAndZ, w: number): Point4d {\r\n return new Point4d(xyz.x, xyz.y, xyz.z, w);\r\n }\r\n /** Create a `Point4d` from\r\n * * Point2d, Point3d, or Point4d\r\n * * other structure with members x,y and optional z,w\r\n * * array of numbers\r\n * * default z is 0.0\r\n * * default w is 1.0 (array[3] can replace)\r\n */\r\n public static createFromPoint(point: XAndY | XYAndZ | Point4d | number[]): Point4d {\r\n if (point instanceof Point2d)\r\n return new Point4d(point.x, point.y, 0, 1);\r\n if (point instanceof Point3d)\r\n return new Point4d(point.x, point.y, point.z, 1);\r\n if (point instanceof Point4d)\r\n return point.clone();\r\n // hm ... some flavor of x,y,z subset ...\r\n if (Array.isArray(point)) {\r\n const x1 = point.length > 0 ? point[0] : 0.0;\r\n const y1 = point.length > 1 ? point[1] : 0.0;\r\n const z1 = point.length > 2 ? point[2] : 0.0;\r\n const w1 = point.length > 3 ? point[3] : 1.0;\r\n return new Point4d(x1, y1, z1, w1);\r\n }\r\n const x = point.x;\r\n const y = point.y;\r\n const z = point.hasOwnProperty(\"z\") ? (point as any).z : 0.0;\r\n const w = point.hasOwnProperty(\"w\") ? (point as any).w : 1.0;\r\n return new Point4d(x, y, z, w);\r\n\r\n }\r\n /** Return `point + vector * scalar` */\r\n public plusScaled(vector: Point4d, scaleFactor: number, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + vector.xyzw[0] * scaleFactor, this.xyzw[1] + vector.xyzw[1] * scaleFactor, this.xyzw[2] + vector.xyzw[2] * scaleFactor, this.xyzw[3] + vector.xyzw[3] * scaleFactor, result);\r\n }\r\n /** Return interpolation between instance and pointB at fraction\r\n */\r\n public interpolate(fraction: number, pointB: Point4d, result?: Point4d): Point4d {\r\n const v = 1.0 - fraction;\r\n return Point4d.create(this.xyzw[0] * v + pointB.xyzw[0] * fraction, this.xyzw[1] * v + pointB.xyzw[1] * fraction, this.xyzw[2] * v + pointB.xyzw[2] * fraction, this.xyzw[3] * v + pointB.xyzw[3] * fraction, result);\r\n }\r\n /** Return `point + vectorA * scalarA + vectorB * scalarB` */\r\n public plus2Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB, this.xyzw[1] + vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB, this.xyzw[2] + vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB, this.xyzw[3] + vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB, result);\r\n }\r\n /** Return `point + vectorA * scalarA + vectorB * scalarB + vectorC * scalarC` */\r\n public plus3Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, vectorC: Point4d, scalarC: number, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB + vectorC.xyzw[0] * scalarC, this.xyzw[1] + vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB + vectorC.xyzw[1] * scalarC, this.xyzw[2] + vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB + vectorC.xyzw[2] * scalarC, this.xyzw[3] + vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB + vectorC.xyzw[3] * scalarC, result);\r\n }\r\n /** Return `point + vectorA * scalarA + vectorB * scalarB` */\r\n public static createAdd2Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, result?: Point4d): Point4d {\r\n return Point4d.create(vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB, vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB, vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB, vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB, result);\r\n }\r\n /** Return `point + vectorA \\ scalarA + vectorB * scalarB + vectorC * scalarC` */\r\n public static createAdd3Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, vectorC: Point4d, scalarC: number, result?: Point4d): Point4d {\r\n return Point4d.create(vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB + vectorC.xyzw[0] * scalarC, vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB + vectorC.xyzw[1] * scalarC, vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB + vectorC.xyzw[2] * scalarC, vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB + vectorC.xyzw[3] * scalarC, result);\r\n }\r\n /** Return dot product of (4d) vectors from the instance to targetA and targetB */\r\n public dotVectorsToTargets(targetA: Point4d, targetB: Point4d): number {\r\n return (targetA.xyzw[0] - this.xyzw[0]) * (targetB.xyzw[0] - this.xyzw[0]) +\r\n (targetA.xyzw[1] - this.xyzw[1]) * (targetB.xyzw[1] - this.xyzw[1]) +\r\n (targetA.xyzw[2] - this.xyzw[2]) * (targetB.xyzw[2] - this.xyzw[2]) +\r\n (targetA.xyzw[3] - this.xyzw[3]) * (targetB.xyzw[3] - this.xyzw[3]);\r\n }\r\n /** return (4d) dot product of the instance and other point. */\r\n public dotProduct(other: Point4d): number {\r\n return this.xyzw[0] * other.xyzw[0] + this.xyzw[1] * other.xyzw[1] + this.xyzw[2] * other.xyzw[2] + this.xyzw[3] * other.xyzw[3];\r\n }\r\n /** return (4d) dot product of the instance with xyzw */\r\n public dotProductXYZW(x: number, y: number, z: number, w: number): number {\r\n return this.xyzw[0] * x + this.xyzw[1] * y + this.xyzw[2] * z + this.xyzw[3] * w;\r\n }\r\n /** dotProduct with (point.x, point.y, point.z, 1) Used in PlaneAltitudeEvaluator interface */\r\n public altitude(point: Point3d): number {\r\n return this.xyzw[0] * point.x + this.xyzw[1] * point.y + this.xyzw[2] * point.z + this.xyzw[3];\r\n }\r\n /** dotProduct with (x, y, z, 1) Used in PlaneAltitudeEvaluator interface */\r\n public altitudeXYZ(x: number, y: number, z: number): number {\r\n return this.xyzw[0] * x + this.xyzw[1] * y + this.xyzw[2] * z + this.xyzw[3];\r\n }\r\n /** dotProduct with (point.x, point.y, point.z, point.w) Used in PlaneAltitudeEvaluator interface */\r\n public weightedAltitude(point: Point4d): number {\r\n return this.xyzw[0] * point.x + this.xyzw[1] * point.y + this.xyzw[2] * point.z + this.xyzw[3] * point.w;\r\n }\r\n /** dotProduct with (vector.x, vector.y, vector.z, 0). Used in PlaneAltitudeEvaluator interface */\r\n public velocity(vector: Vector3d): number {\r\n return this.xyzw[0] * vector.x + this.xyzw[1] * vector.y + this.xyzw[2] * vector.z;\r\n }\r\n /** dotProduct with (x,y,z, 0). Used in PlaneAltitudeEvaluator interface */\r\n public velocityXYZ(x: number, y: number, z: number): number {\r\n return this.xyzw[0] * x + this.xyzw[1] * y + this.xyzw[2] * z;\r\n }\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n */\r\n public normalX(): number { return this.x; }\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n */\r\n public normalY(): number { return this.y; }\r\n /**\r\n * Return the z component of the normal used to evaluate altitude.\r\n */\r\n public normalZ(): number { return this.z; }\r\n\r\n /** unit X vector */\r\n public static unitX(): Point4d { return new Point4d(1, 0, 0, 0); }\r\n /** unit Y vector */\r\n public static unitY(): Point4d { return new Point4d(0, 1, 0, 0); }\r\n /** unit Z vector */\r\n public static unitZ(): Point4d { return new Point4d(0, 0, 1, 0); }\r\n /** unit W vector */\r\n public static unitW(): Point4d { return new Point4d(0, 0, 0, 1); }\r\n /** Divide by denominator, but return undefined if denominator is zero. */\r\n public safeDivideOrNull(denominator: number, result?: Point4d): Point4d | undefined {\r\n if (denominator !== 0.0) {\r\n return this.scale(1.0 / denominator, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * * Return xyz projection of spacePoint to the plane (this Point4d is understood as plane coefficients, not point coordinates)\r\n * * If the xyz part of `this` are all zero, (a clone of) `spacePoint` is returned.\r\n */\r\n public projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d {\r\n const h = this.altitude(spacePoint);\r\n const nn = this.magnitudeSquaredXYZ();\r\n const alpha = Geometry.conditionalDivideCoordinate(-h, nn);\r\n if (alpha === undefined)\r\n return spacePoint.clone(result);\r\n return spacePoint.plusXYZ(alpha * this.x, alpha * this.y, alpha * this.z, result);\r\n }\r\n /** scale all components (including w!!) */\r\n public scale(scale: number, result?: Point4d): Point4d {\r\n result = result ? result : new Point4d();\r\n result.xyzw[0] = this.xyzw[0] * scale;\r\n result.xyzw[1] = this.xyzw[1] * scale;\r\n result.xyzw[2] = this.xyzw[2] * scale;\r\n result.xyzw[3] = this.xyzw[3] * scale;\r\n return result;\r\n }\r\n /** Negate components (including w!!) */\r\n public negate(result?: Point4d): Point4d {\r\n result = result ? result : new Point4d();\r\n result.xyzw[0] = -this.xyzw[0];\r\n result.xyzw[1] = -this.xyzw[1];\r\n result.xyzw[2] = -this.xyzw[2];\r\n result.xyzw[3] = -this.xyzw[3];\r\n return result;\r\n }\r\n /**\r\n * If `this.w` is nonzero, return a 4d point `(x/w,y/w,z/w, 1)`\r\n * If `this.w` is zero, return undefined.\r\n * @param result optional result\r\n */\r\n public normalizeWeight(result?: Point4d): Point4d | undefined {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n result = result ? result : new Point4d();\r\n return this.safeDivideOrNull(mag, result);\r\n }\r\n /**\r\n * If `this.w` is nonzero, return a 3d point `(x/w,y/w,z/w)`\r\n * If `this.w` is zero, return undefined.\r\n * @param result optional result\r\n */\r\n public realPoint(result?: Point3d): Point3d | undefined {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n if (mag === 0.0)\r\n return undefined;\r\n const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.\r\n return Point3d.create(this.xyzw[0] * a, this.xyzw[1] * a, this.xyzw[2] * a, result);\r\n }\r\n\r\n /** Convert the homogeneous point to a (strongly typed) point or vector.\r\n * * If `this.w` is nonzero, return a Point3d `(x/w,y/w,z/w)`\r\n * * If `this.w` is zero, return a Vector3d `(x,y,z)`\r\n */\r\n public realPointOrVector(): Point3d | Vector3d {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n if (mag === 0.0)\r\n return Vector3d.create(this.x, this.y, this.z);\r\n const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.\r\n return Point3d.create(this.x * a, this.y * a, this.z * a);\r\n }\r\n /**\r\n * * If w is nonzero, return Point3d with x/w,y/w,z/w.\r\n * * If w is zero, return 000\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n * @param w w coordinate\r\n * @param result optional result\r\n */\r\n public static createRealPoint3dDefault000(x: number, y: number, z: number, w: number, result?: Point3d): Point3d {\r\n const mag = Geometry.correctSmallFraction(w);\r\n const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.\r\n return Point3d.create(x * a, y * a, z * a, result);\r\n }\r\n /**\r\n * * If w is nonzero, return Vector3d which is the derivative of the projected xyz with given w and 4d derivatives.\r\n * * If w is zero, return 000\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n * @param w w coordinate\r\n * @param dx x coordinate of derivative\r\n * @param dy y coordinate of derivative\r\n * @param dz z coordinate of derivative\r\n * @param dw w coordinate of derivative\r\n * @param result optional result\r\n */\r\n public static createRealDerivativeRay3dDefault000(x: number, y: number, z: number, w: number, dx: number, dy: number, dz: number, dw: number, result?: Ray3d): Ray3d {\r\n const mag = Geometry.correctSmallFraction(w);\r\n // real point is X/w.\r\n // real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.\r\n const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.\r\n const aa = a * a;\r\n return Ray3d.createXYZUVW(x * a, y * a, z * a, (dx * w - dw * x) * aa, (dy * w - dw * y) * aa, (dz * w - dw * z) * aa, result);\r\n }\r\n /**\r\n * * If w is nonzero, return Vector3d which is the derivative of the projected xyz with given w and 4d derivatives.\r\n * * If w is zero, return 000\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n * @param w w coordinate\r\n * @param dx x coordinate of derivative\r\n * @param dy y coordinate of derivative\r\n * @param dz z coordinate of derivative\r\n * @param dw w coordinate of derivative\r\n * @param result optional result\r\n */\r\n public static createRealDerivativePlane3dByOriginAndVectorsDefault000(x: number, y: number, z: number, w: number, dx: number, dy: number, dz: number, dw: number, ddx: number, ddy: number, ddz: number, ddw: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const mag = Geometry.correctSmallFraction(w);\r\n // real point is X/w.\r\n // real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.\r\n const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.\r\n const aa = a * a;\r\n const fx = x * a;\r\n const fy = y * a;\r\n const fz = z * a;\r\n const dfx = (dx * w - dw * x) * aa;\r\n const dfy = (dy * w - dw * y) * aa;\r\n const dfz = (dz * w - dw * z) * aa;\r\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(fx, fy, fz, dfx, dfy, dfz, quotientDerivative2(ddx, dw, ddw, fx, dfx, a), quotientDerivative2(ddy, dw, ddw, fy, dfy, a), quotientDerivative2(ddz, dw, ddw, fz, dfz, a), result);\r\n }\r\n /**\r\n * * If this.w is nonzero, return Point3d with x/w,y/w,z/w.\r\n * * If this.w is zero, return 000\r\n */\r\n public realPointDefault000(result?: Point3d): Point3d {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n if (mag === 0.0)\r\n return Point3d.create(0, 0, 0, result);\r\n result = result ? result : new Point3d();\r\n const a = 1.0 / mag;\r\n return Point3d.create(this.xyzw[0] * a, this.xyzw[1] * a, this.xyzw[2] * a, result);\r\n }\r\n /** divide all components (x,y,z,w) by the 4d magnitude.\r\n *\r\n * * This is appropriate for normalizing a quaternion\r\n * * Use normalizeWeight to divide by the w component.\r\n */\r\n public normalizeXYZW(result?: Point4d): Point4d | undefined {\r\n const mag = Geometry.correctSmallFraction(this.magnitudeXYZW());\r\n result = result ? result : new Point4d();\r\n return this.safeDivideOrNull(mag, result);\r\n }\r\n\r\n /**\r\n * Return the determinant of the 3x3 matrix using components i,j,k of the 3 inputs.\r\n */\r\n public static determinantIndexed3X3(pointA: Point4d, pointB: Point4d, pointC: Point4d, i: number, j: number, k: number) {\r\n return Geometry.tripleProduct(\r\n pointA.xyzw[i], pointA.xyzw[j], pointA.xyzw[k],\r\n pointB.xyzw[i], pointB.xyzw[j], pointB.xyzw[k],\r\n pointC.xyzw[i], pointC.xyzw[j], pointC.xyzw[k]);\r\n }\r\n /**\r\n * Return a Point4d perpendicular to all 3 inputs. (A higher level cross product concept)\r\n * @param pointA first point\r\n * @param pointB second point\r\n * @param pointC third point\r\n */\r\n public static perpendicularPoint4dPlane(pointA: Point4d, pointB: Point4d, pointC: Point4d): Point4d {\r\n return Point4d.create(\r\n Point4d.determinantIndexed3X3(pointA, pointB, pointC, 1, 2, 3),\r\n -Point4d.determinantIndexed3X3(pointA, pointB, pointC, 2, 3, 0),\r\n Point4d.determinantIndexed3X3(pointA, pointB, pointC, 3, 0, 1),\r\n -Point4d.determinantIndexed3X3(pointA, pointB, pointC, 0, 1, 2));\r\n }\r\n /** Treating this Point4d as plane coefficients, convert to origin and normal form. */\r\n public toPlane3dByOriginAndUnitNormal(result?: Plane3dByOriginAndUnitNormal): Plane3dByOriginAndUnitNormal | undefined {\r\n return Plane3dByOriginAndUnitNormal.createFrom(this, result);\r\n }\r\n /** Normalize so sum of squares of all 4 coordinates is 1. */\r\n public normalizeQuaternion() {\r\n const magnitude = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);\r\n\r\n if (magnitude > 0.0) {\r\n const f = 1.0 / magnitude;\r\n this.x *= f;\r\n this.y *= f;\r\n this.z *= f;\r\n this.w *= f;\r\n }\r\n return magnitude;\r\n }\r\n /** Return a (normalized) quaternion interpolated between two quaternions. */\r\n public static interpolateQuaternions(quaternion0: Point4d, fractionParameter: number, quaternion1: Point4d, result?: Point4d): Point4d {\r\n if (!result)\r\n result = new Point4d();\r\n const maxSafeCosine = 0.9995;\r\n\r\n // return exact quaternions for special values\r\n if (0.0 === fractionParameter) {\r\n result = quaternion0;\r\n return result;\r\n }\r\n if (1.0 === fractionParameter) {\r\n result = quaternion1;\r\n return result;\r\n }\r\n if (0.5 === fractionParameter) {\r\n quaternion0.plus(quaternion1, result);\r\n result.normalizeQuaternion();\r\n return result;\r\n }\r\n\r\n const q0 = quaternion0.clone();\r\n const q1 = quaternion1.clone();\r\n let dot = quaternion0.dotProduct(quaternion1);\r\n\r\n // prevent interpolation through the longer great arc\r\n if (dot < 0.0) {\r\n q1.negate(q1);\r\n dot = -dot;\r\n }\r\n\r\n // if nearly parallel, use interpolate and renormalize .\r\n if (dot > maxSafeCosine) {\r\n q0.interpolate(fractionParameter, q1, result);\r\n result.normalizeQuaternion();\r\n return result;\r\n }\r\n\r\n // safety check\r\n if (dot < -1.0)\r\n dot = -1.0;\r\n else if (dot > 1.0)\r\n dot = 1.0;\r\n\r\n // create orthonormal basis {q0, q2}\r\n const q2 = new Point4d();\r\n q1.plusScaled(q0, -dot, q2); // bsiDPoint4d_addScaledDPoint4d(& q2, & q1, & q0, -dot);\r\n q2.normalizeQuaternion();\r\n\r\n const angle = Math.acos(dot);\r\n const angleOfInterpolation = angle * fractionParameter;\r\n result = Point4d.createAdd2Scaled(q0, Math.cos(angleOfInterpolation), q2, Math.sin(angleOfInterpolation));\r\n return result;\r\n }\r\n /** Measure the \"angle\" between two points, using all 4 components in the dot product that\r\n * gives the cosine of the angle.\r\n */\r\n public radiansToPoint4dXYZW(other: Point4d): number | undefined {\r\n const magA = this.magnitudeXYZW();\r\n const magB = other.magnitudeXYZW();\r\n const dot = this.dotProduct(other); // == cos (theta) * magA * magB\r\n const cos = Geometry.conditionalDivideFraction(dot, magA * magB);\r\n if (cos === undefined)\r\n return undefined;\r\n return Math.acos(cos);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Point4d.js","sourceRoot":"","sources":["../../../src/geometry4d/Point4d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,0CAAgF;AAChF,mDAAgD;AAChD,6FAA0F;AAC1F,uFAAoF;AACpF,mEAAwD;AACxD,mEAAkE;AAClE,+CAA4C;AAQ5C;;;;;;;;;GASG;AACH,SAAS,mBAAmB,CAAC,GAAW,EAAE,EAAU,EAAE,GAAW,EAC/D,CAAS,EAAE,EAAU,EAAE,IAAY;IACnC,OAAO,IAAI,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;GAOG;AACH,MAAa,OAAQ,SAAQ,iBAAO;IAGlC,kCAAkC;IAC3B,GAAG,CAAC,IAAY,CAAC,EAAE,IAAY,CAAC,EAAE,IAAY,CAAC,EAAE,IAAY,CAAC;QACnE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAA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AAI,OAAO,EAAE,CAAC;QACzB,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAE,0DAA0D;QACxF,EAAE,CAAC,mBAAmB,EAAE,CAAC;QAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,oBAAoB,GAAG,KAAK,GAAG,iBAAiB,CAAC;QACvD,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC1G,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;OAEG;IACI,oBAAoB,CAAC,KAAc;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,+BAA+B;QACpE,MAAM,GAAG,GAAG,mBAAQ,CAAC,yBAAyB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS;YACnB,OAAO,SAAS,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACF;AAzkBD,0BAykBC","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 Numerics\r\n */\r\nimport { BeJSONFunctions, Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Plane3d } from \"../geometry3d/Plane3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { XAndY, XYAndZ } from \"../geometry3d/XYZProps\";\r\n\r\n/**\r\n * 4d point packed in an array of 4 numbers.\r\n * @public\r\n */\r\nexport type Point4dProps = number[];\r\n/**\r\n *\r\n * @param ddg numerator second derivative\r\n * @param dh denominator derivative\r\n * @param ddh denominator second derivative\r\n * @param f primary function (g/h)\r\n * @param df derivative of (g/h)\r\n * @param divH = (1/h)\r\n * @internal\r\n */\r\nfunction quotientDerivative2(ddg: number, dh: number, ddh: number,\r\n f: number, df: number, divH: number): number {\r\n return divH * (ddg - 2.0 * df * dh - f * ddh);\r\n}\r\n\r\n/** 4 Dimensional point (x,y,z,w) used in perspective calculations.\r\n * * the coordinates are stored in a Float64Array of length 4.\r\n * * properties `x`, `y`, `z`, `w` access array members.\r\n * *\r\n * * The coordinates are physically stored as a single Float64Array with 4 entries. (w last)\r\n * *\r\n * @public\r\n */\r\nexport class Point4d extends Plane3d implements BeJSONFunctions {\r\n /** x,y,z,w are packed into a Float64Array */\r\n public xyzw: Float64Array;\r\n /** Set x,y,z,w of this point. */\r\n public set(x: number = 0, y: number = 0, z: number = 0, w: number = 0): Point4d {\r\n this.xyzw[0] = x;\r\n this.xyzw[1] = y;\r\n this.xyzw[2] = z;\r\n this.xyzw[3] = w;\r\n return this;\r\n }\r\n /** Set a component by index.\r\n * * No change if index is out of range.\r\n */\r\n public setComponent(index: number, value: number) {\r\n if (index >= 0 && index < 4) {\r\n this.xyzw[index] = value;\r\n }\r\n }\r\n /** The x component. */\r\n public get x() { return this.xyzw[0]; }\r\n public set x(val: number) { this.xyzw[0] = val; }\r\n /** The y component. */\r\n public get y() { return this.xyzw[1]; }\r\n public set y(val: number) { this.xyzw[1] = val; }\r\n /** The z component. */\r\n public get z() { return this.xyzw[2]; }\r\n public set z(val: number) { this.xyzw[2] = val; }\r\n /** The w component of this point. */\r\n public get w() { return this.xyzw[3]; }\r\n public set w(val: number) { this.xyzw[3] = val; }\r\n /** Construct from coordinates. */\r\n protected constructor(x: number = 0, y: number = 0, z: number = 0, w: number = 0) {\r\n super();\r\n this.xyzw = new Float64Array(4);\r\n this.xyzw[0] = x;\r\n this.xyzw[1] = y;\r\n this.xyzw[2] = z;\r\n this.xyzw[3] = w;\r\n }\r\n /** Return a Point4d with specified x,y,z,w */\r\n public static create(x: number = 0, y: number = 0, z: number = 0, w: number = 0, result?: Point4d): Point4d {\r\n return result ? result.set(x, y, z, w) : new Point4d(x, y, z, w);\r\n }\r\n /**\r\n * Create a \"Point4d as a plane\" from \"any\" other [[PlaneAltitudeEvaluator]] type.\r\n * @param source\r\n * @returns\r\n */\r\n public static createPlaneFrom(source: PlaneAltitudeEvaluator): Point4d | undefined {\r\n return new Point4d(source.normalX(), source.normalY(), source.normalZ(), source.altitudeXYZ(0, 0, 0));\r\n }\r\n /** Copy coordinates from `other`. */\r\n public setFrom(other: Point4d): Point4d {\r\n this.xyzw[0] = other.xyzw[0];\r\n this.xyzw[1] = other.xyzw[1];\r\n this.xyzw[2] = other.xyzw[2];\r\n this.xyzw[3] = other.xyzw[3];\r\n return this;\r\n }\r\n /** Clone this point */\r\n public clone(result?: Point4d): Point4d {\r\n return result ? result.setFrom(this) : new Point4d(this.xyzw[0], this.xyzw[1], this.xyzw[2], this.xyzw[3]);\r\n }\r\n /** Set this point's xyzw from a json array `[x,y,z,w]` */\r\n public setFromJSON(json?: Point4dProps) {\r\n if (Geometry.isNumberArray(json, 4))\r\n this.set(json[0], json[1], json[2], json[3]);\r\n else\r\n this.set(0, 0, 0, 0);\r\n }\r\n\r\n /** Create a new point with coordinates from a json array `[x,y,z,w]` */\r\n public static fromJSON(json?: Point4dProps): Point4d {\r\n const result = new Point4d();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /** Near-equality test, using `Geometry.isSameCoordinate` on all 4 x,y,z,w */\r\n public isAlmostEqual(other: Point4d): boolean {\r\n return Geometry.isSameCoordinate(this.x, other.x)\r\n && Geometry.isSameCoordinate(this.y, other.y)\r\n && Geometry.isSameCoordinate(this.z, other.z)\r\n && Geometry.isSameCoordinate(this.w, other.w);\r\n }\r\n /**\r\n * Test for same coordinate by direct x,y,z,w args\r\n * @param x x to test\r\n * @param y y to test\r\n * @param z z to test\r\n * @param w w to test\r\n */\r\n public isAlmostEqualXYZW(x: number, y: number, z: number, w: number): boolean {\r\n return Geometry.isSameCoordinate(this.x, x)\r\n && Geometry.isSameCoordinate(this.y, y)\r\n && Geometry.isSameCoordinate(this.z, z)\r\n && Geometry.isSameCoordinate(this.w, w);\r\n }\r\n\r\n /**\r\n * Convert an Angle to a JSON object.\r\n * @return {*} [x,y,z,w]\r\n */\r\n public toJSON(): Point4dProps {\r\n return [this.xyzw[0], this.xyzw[1], this.xyzw[2], this.xyzw[3]];\r\n }\r\n /** Return the 4d distance from this point to other, with all 4 components squared into the hypotenuse.\r\n * * x,y,z,w all participate without normalization.\r\n */\r\n public distanceXYZW(other: Point4d): number {\r\n return Geometry.hypotenuseXYZW(other.xyzw[0] - this.xyzw[0], other.xyzw[1] - this.xyzw[1], other.xyzw[2] - this.xyzw[2], other.xyzw[3] - this.xyzw[3]);\r\n }\r\n /** Return the squared 4d distance from this point to other, with all 4 components squared into the hypotenuse.\r\n * * x,y,z,w all participate without normalization.\r\n */\r\n public distanceSquaredXYZW(other: Point4d): number {\r\n return Geometry.hypotenuseSquaredXYZW(other.xyzw[0] - this.xyzw[0], other.xyzw[1] - this.xyzw[1], other.xyzw[2] - this.xyzw[2], other.xyzw[3] - this.xyzw[3]);\r\n }\r\n /** Return the distance between the instance and other after normalizing by weights\r\n */\r\n public realDistanceXY(other: Point4d): number | undefined {\r\n const wA = this.w;\r\n const wB = other.w;\r\n if (Geometry.isSmallMetricDistance(wA) || Geometry.isSmallMetricDistance(wB))\r\n return undefined;\r\n return Geometry.hypotenuseXY(other.xyzw[0] / wB - this.xyzw[0] / wA, other.xyzw[1] / wB - this.xyzw[1] / wA);\r\n }\r\n /** Return the largest absolute distance between corresponding components\r\n * * x,y,z,w all participate without normalization.\r\n */\r\n public maxDiff(other: Point4d): number {\r\n return Math.max(Math.abs(other.xyzw[0] - this.xyzw[0]), Math.abs(other.xyzw[1] - this.xyzw[1]), Math.abs(other.xyzw[2] - this.xyzw[2]), Math.abs(other.xyzw[3] - this.xyzw[3]));\r\n }\r\n /** Return the largest absolute entry of all 4 components x,y,z,w */\r\n public maxAbs(): number {\r\n return Math.max(Math.abs(this.xyzw[0]), Math.abs(this.xyzw[1]), Math.abs(this.xyzw[2]), Math.abs(this.xyzw[3]));\r\n }\r\n /** Returns the magnitude including all 4 components x,y,z,w */\r\n public magnitudeXYZW(): number {\r\n return Geometry.hypotenuseXYZW(this.xyzw[0], this.xyzw[1], this.xyzw[2], this.xyzw[3]);\r\n }\r\n /** Returns the magnitude of the leading xyz components. w is ignored. (i.e. the leading xyz are NOT divided by w.) */\r\n public magnitudeSquaredXYZ(): number {\r\n return Geometry.hypotenuseSquaredXYZ(this.xyzw[0], this.xyzw[1], this.xyzw[2]);\r\n }\r\n\r\n /** Return the difference (this-other) using all 4 components x,y,z,w */\r\n public minus(other: Point4d, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] - other.xyzw[0], this.xyzw[1] - other.xyzw[1], this.xyzw[2] - other.xyzw[2], this.xyzw[3] - other.xyzw[3], result);\r\n }\r\n /** Return `((other.w * this) - (this.w * other))` */\r\n public crossWeightedMinus(other: Point4d, result?: Vector3d): Vector3d {\r\n const wa = this.xyzw[3];\r\n const wb = other.xyzw[3];\r\n return Vector3d.create(wb * this.xyzw[0] - wa * other.xyzw[0], wb * this.xyzw[1] - wa * other.xyzw[1], wb * this.xyzw[2] - wa * other.xyzw[2], result);\r\n }\r\n /** Return `((other.w * this) - (this.w * other))`, with other.w known to be 1 */\r\n public crossWeightedMinusPoint3d(other: Point3d, result?: Vector3d): Vector3d {\r\n const wa = this.xyzw[3];\r\n return Vector3d.create(this.xyzw[0] - wa * other.x, this.xyzw[1] - wa * other.y, this.xyzw[2] - wa * other.z, result);\r\n }\r\n /** Return the sum of this and other, using all 4 components x,y,z,w */\r\n public plus(other: Point4d, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + other.xyzw[0], this.xyzw[1] + other.xyzw[1], this.xyzw[2] + other.xyzw[2], this.xyzw[3] + other.xyzw[3], result);\r\n }\r\n /** Test if all components are nearly zero. */\r\n public get isAlmostZero(): boolean {\r\n return Geometry.isSmallMetricDistance(this.maxAbs());\r\n }\r\n /** Create a point with zero in all coordinates. */\r\n public static createZero(): Point4d { return new Point4d(0, 0, 0, 0); }\r\n /**\r\n * Create plane coefficients for the plane containing pointA, pointB, and 0010.\r\n * @param pointA first point\r\n * @param pointB second point\r\n */\r\n public static createPlanePointPointZ(pointA: Point4d, pointB: Point4d, result?: Point4d) {\r\n return Point4d.create(pointA.y * pointB.w - pointA.w * pointB.y, pointA.w * pointB.x - pointA.x * pointB.w, 0.0, pointA.x * pointB.y - pointA.y * pointB.x, result);\r\n }\r\n /**\r\n * extract 3 consecutive numbers from a Float64Array into the xyz values of a Point4d with w = 1.\r\n * @param data buffer of numbers\r\n * @param xIndex first index for x,y,z sequence\r\n */\r\n public static createFromPackedXYZ(data: Float64Array, xIndex: number = 0, result?: Point4d): Point4d | undefined {\r\n if (xIndex >= 0 && xIndex + 2 < data.length)\r\n return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], 1.0, result);\r\n return undefined;\r\n }\r\n /**\r\n * extract 4 consecutive numbers from a Float64Array into a Point4d.\r\n * @param data buffer of numbers\r\n * @param xIndex first index for x,y,z,w sequence\r\n */\r\n public static createFromPacked(data: Float64Array, xIndex: number = 0, result?: Point4d): Point4d | undefined {\r\n if (xIndex >= 0 && xIndex + 3 < data.length)\r\n return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], data[xIndex + 3], result);\r\n return undefined;\r\n }\r\n /**\r\n * extract 4 consecutive numbers from a Float64Array into a Point4d.\r\n * @param data buffer of numbers\r\n * @param xIndex first index for x,y,z,w sequence. Assumed to be a valid index!\r\n * @deprecated in 4.x. Use createFromPacked instead.\r\n */\r\n public static createFromPackedXYZW(data: Float64Array, xIndex: number = 0, result?: Point4d): Point4d {\r\n return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], data[xIndex + 3], result);\r\n }\r\n /** Create a `Point4d` with x,y,z from an `XYAndZ` input, and w from a separate number. */\r\n public static createFromPointAndWeight(xyz: XYAndZ, w: number): Point4d {\r\n return new Point4d(xyz.x, xyz.y, xyz.z, w);\r\n }\r\n /** Create a `Point4d` from\r\n * * Point2d, Point3d, or Point4d\r\n * * other structure with members x,y and optional z,w\r\n * * array of numbers\r\n * * default z is 0.0\r\n * * default w is 1.0 (array[3] can replace)\r\n */\r\n public static createFromPoint(point: XAndY | XYAndZ | Point4d | number[]): Point4d {\r\n if (point instanceof Point2d)\r\n return new Point4d(point.x, point.y, 0, 1);\r\n if (point instanceof Point3d)\r\n return new Point4d(point.x, point.y, point.z, 1);\r\n if (point instanceof Point4d)\r\n return point.clone();\r\n // hm ... some flavor of x,y,z subset ...\r\n if (Array.isArray(point)) {\r\n const x1 = point.length > 0 ? point[0] : 0.0;\r\n const y1 = point.length > 1 ? point[1] : 0.0;\r\n const z1 = point.length > 2 ? point[2] : 0.0;\r\n const w1 = point.length > 3 ? point[3] : 1.0;\r\n return new Point4d(x1, y1, z1, w1);\r\n }\r\n const x = point.x;\r\n const y = point.y;\r\n const z = point.hasOwnProperty(\"z\") ? (point as any).z : 0.0;\r\n const w = point.hasOwnProperty(\"w\") ? (point as any).w : 1.0;\r\n return new Point4d(x, y, z, w);\r\n\r\n }\r\n /** Return `point + vector * scalar` */\r\n public plusScaled(vector: Point4d, scaleFactor: number, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + vector.xyzw[0] * scaleFactor, this.xyzw[1] + vector.xyzw[1] * scaleFactor, this.xyzw[2] + vector.xyzw[2] * scaleFactor, this.xyzw[3] + vector.xyzw[3] * scaleFactor, result);\r\n }\r\n /** Return interpolation between instance and pointB at fraction\r\n */\r\n public interpolate(fraction: number, pointB: Point4d, result?: Point4d): Point4d {\r\n const v = 1.0 - fraction;\r\n return Point4d.create(this.xyzw[0] * v + pointB.xyzw[0] * fraction, this.xyzw[1] * v + pointB.xyzw[1] * fraction, this.xyzw[2] * v + pointB.xyzw[2] * fraction, this.xyzw[3] * v + pointB.xyzw[3] * fraction, result);\r\n }\r\n /** Return `point + vectorA * scalarA + vectorB * scalarB` */\r\n public plus2Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB, this.xyzw[1] + vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB, this.xyzw[2] + vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB, this.xyzw[3] + vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB, result);\r\n }\r\n /** Return `point + vectorA * scalarA + vectorB * scalarB + vectorC * scalarC` */\r\n public plus3Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, vectorC: Point4d, scalarC: number, result?: Point4d): Point4d {\r\n return Point4d.create(this.xyzw[0] + vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB + vectorC.xyzw[0] * scalarC, this.xyzw[1] + vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB + vectorC.xyzw[1] * scalarC, this.xyzw[2] + vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB + vectorC.xyzw[2] * scalarC, this.xyzw[3] + vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB + vectorC.xyzw[3] * scalarC, result);\r\n }\r\n /** Return `point + vectorA * scalarA + vectorB * scalarB` */\r\n public static createAdd2Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, result?: Point4d): Point4d {\r\n return Point4d.create(vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB, vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB, vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB, vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB, result);\r\n }\r\n /** Return `point + vectorA \\ scalarA + vectorB * scalarB + vectorC * scalarC` */\r\n public static createAdd3Scaled(vectorA: Point4d, scalarA: number, vectorB: Point4d, scalarB: number, vectorC: Point4d, scalarC: number, result?: Point4d): Point4d {\r\n return Point4d.create(vectorA.xyzw[0] * scalarA + vectorB.xyzw[0] * scalarB + vectorC.xyzw[0] * scalarC, vectorA.xyzw[1] * scalarA + vectorB.xyzw[1] * scalarB + vectorC.xyzw[1] * scalarC, vectorA.xyzw[2] * scalarA + vectorB.xyzw[2] * scalarB + vectorC.xyzw[2] * scalarC, vectorA.xyzw[3] * scalarA + vectorB.xyzw[3] * scalarB + vectorC.xyzw[3] * scalarC, result);\r\n }\r\n /** Return dot product of (4d) vectors from the instance to targetA and targetB */\r\n public dotVectorsToTargets(targetA: Point4d, targetB: Point4d): number {\r\n return (targetA.xyzw[0] - this.xyzw[0]) * (targetB.xyzw[0] - this.xyzw[0]) +\r\n (targetA.xyzw[1] - this.xyzw[1]) * (targetB.xyzw[1] - this.xyzw[1]) +\r\n (targetA.xyzw[2] - this.xyzw[2]) * (targetB.xyzw[2] - this.xyzw[2]) +\r\n (targetA.xyzw[3] - this.xyzw[3]) * (targetB.xyzw[3] - this.xyzw[3]);\r\n }\r\n /** return (4d) dot product of the instance and other point. */\r\n public dotProduct(other: Point4d): number {\r\n return this.xyzw[0] * other.xyzw[0] + this.xyzw[1] * other.xyzw[1] + this.xyzw[2] * other.xyzw[2] + this.xyzw[3] * other.xyzw[3];\r\n }\r\n /** return (4d) dot product of the instance with xyzw */\r\n public dotProductXYZW(x: number, y: number, z: number, w: number): number {\r\n return this.xyzw[0] * x + this.xyzw[1] * y + this.xyzw[2] * z + this.xyzw[3] * w;\r\n }\r\n /** dotProduct with (point.x, point.y, point.z, 1) Used in PlaneAltitudeEvaluator interface */\r\n public altitude(point: Point3d): number {\r\n return this.xyzw[0] * point.x + this.xyzw[1] * point.y + this.xyzw[2] * point.z + this.xyzw[3];\r\n }\r\n /** dotProduct with (x, y, z, 1) Used in PlaneAltitudeEvaluator interface */\r\n public altitudeXYZ(x: number, y: number, z: number): number {\r\n return this.xyzw[0] * x + this.xyzw[1] * y + this.xyzw[2] * z + this.xyzw[3];\r\n }\r\n /** dotProduct with (point.x, point.y, point.z, point.w) Used in PlaneAltitudeEvaluator interface */\r\n public weightedAltitude(point: Point4d): number {\r\n return this.xyzw[0] * point.x + this.xyzw[1] * point.y + this.xyzw[2] * point.z + this.xyzw[3] * point.w;\r\n }\r\n /** dotProduct with (vector.x, vector.y, vector.z, 0). Used in PlaneAltitudeEvaluator interface */\r\n public velocity(vector: Vector3d): number {\r\n return this.xyzw[0] * vector.x + this.xyzw[1] * vector.y + this.xyzw[2] * vector.z;\r\n }\r\n /** dotProduct with (x,y,z, 0). Used in PlaneAltitudeEvaluator interface */\r\n public velocityXYZ(x: number, y: number, z: number): number {\r\n return this.xyzw[0] * x + this.xyzw[1] * y + this.xyzw[2] * z;\r\n }\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n */\r\n public normalX(): number { return this.x; }\r\n /**\r\n * Return the x component of the normal used to evaluate altitude.\r\n */\r\n public normalY(): number { return this.y; }\r\n /**\r\n * Return the z component of the normal used to evaluate altitude.\r\n */\r\n public normalZ(): number { return this.z; }\r\n\r\n /** unit X vector */\r\n public static unitX(): Point4d { return new Point4d(1, 0, 0, 0); }\r\n /** unit Y vector */\r\n public static unitY(): Point4d { return new Point4d(0, 1, 0, 0); }\r\n /** unit Z vector */\r\n public static unitZ(): Point4d { return new Point4d(0, 0, 1, 0); }\r\n /** unit W vector */\r\n public static unitW(): Point4d { return new Point4d(0, 0, 0, 1); }\r\n /** Divide by denominator, but return undefined if denominator is zero. */\r\n public safeDivideOrNull(denominator: number, result?: Point4d): Point4d | undefined {\r\n if (denominator !== 0.0) {\r\n return this.scale(1.0 / denominator, result);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * * Return xyz projection of spacePoint to the plane (this Point4d is understood as plane coefficients, not point coordinates)\r\n * * If the xyz part of `this` are all zero, (a clone of) `spacePoint` is returned.\r\n */\r\n public projectPointToPlane(spacePoint: Point3d, result?: Point3d): Point3d {\r\n const h = this.altitude(spacePoint);\r\n const nn = this.magnitudeSquaredXYZ();\r\n // this unusual tol is needed so that toPlane3dByOriginAndUnitNormal agrees with its original implementation\r\n const alpha = Geometry.conditionalDivideCoordinate(-h, nn, Geometry.largeFractionResult * Geometry.largeFractionResult);\r\n if (alpha === undefined)\r\n return spacePoint.clone(result);\r\n return spacePoint.plusXYZ(alpha * this.x, alpha * this.y, alpha * this.z, result);\r\n }\r\n /** scale all components (including w!!) */\r\n public scale(scale: number, result?: Point4d): Point4d {\r\n result = result ? result : new Point4d();\r\n result.xyzw[0] = this.xyzw[0] * scale;\r\n result.xyzw[1] = this.xyzw[1] * scale;\r\n result.xyzw[2] = this.xyzw[2] * scale;\r\n result.xyzw[3] = this.xyzw[3] * scale;\r\n return result;\r\n }\r\n /** Negate components (including w!!) */\r\n public negate(result?: Point4d): Point4d {\r\n result = result ? result : new Point4d();\r\n result.xyzw[0] = -this.xyzw[0];\r\n result.xyzw[1] = -this.xyzw[1];\r\n result.xyzw[2] = -this.xyzw[2];\r\n result.xyzw[3] = -this.xyzw[3];\r\n return result;\r\n }\r\n /**\r\n * If `this.w` is nonzero, return a 4d point `(x/w,y/w,z/w, 1)`\r\n * If `this.w` is zero, return undefined.\r\n * @param result optional result\r\n */\r\n public normalizeWeight(result?: Point4d): Point4d | undefined {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n result = result ? result : new Point4d();\r\n return this.safeDivideOrNull(mag, result);\r\n }\r\n /**\r\n * If `this.w` is nonzero, return a 3d point `(x/w,y/w,z/w)`\r\n * If `this.w` is zero, return undefined.\r\n * @param result optional result\r\n */\r\n public realPoint(result?: Point3d): Point3d | undefined {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n if (mag === 0.0)\r\n return undefined;\r\n const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.\r\n return Point3d.create(this.xyzw[0] * a, this.xyzw[1] * a, this.xyzw[2] * a, result);\r\n }\r\n\r\n /** Convert the homogeneous point to a (strongly typed) point or vector.\r\n * * If `this.w` is nonzero, return a Point3d `(x/w,y/w,z/w)`\r\n * * If `this.w` is zero, return a Vector3d `(x,y,z)`\r\n */\r\n public realPointOrVector(): Point3d | Vector3d {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n if (mag === 0.0)\r\n return Vector3d.create(this.x, this.y, this.z);\r\n const a = 1.0 / mag; // in zero case everything multiplies right back to true zero.\r\n return Point3d.create(this.x * a, this.y * a, this.z * a);\r\n }\r\n /**\r\n * * If w is nonzero, return Point3d with x/w,y/w,z/w.\r\n * * If w is zero, return 000\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n * @param w w coordinate\r\n * @param result optional result\r\n */\r\n public static createRealPoint3dDefault000(x: number, y: number, z: number, w: number, result?: Point3d): Point3d {\r\n const mag = Geometry.correctSmallFraction(w);\r\n const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.\r\n return Point3d.create(x * a, y * a, z * a, result);\r\n }\r\n /**\r\n * * If w is nonzero, return Vector3d which is the derivative of the projected xyz with given w and 4d derivatives.\r\n * * If w is zero, return 000\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n * @param w w coordinate\r\n * @param dx x coordinate of derivative\r\n * @param dy y coordinate of derivative\r\n * @param dz z coordinate of derivative\r\n * @param dw w coordinate of derivative\r\n * @param result optional result\r\n */\r\n public static createRealDerivativeRay3dDefault000(x: number, y: number, z: number, w: number, dx: number, dy: number, dz: number, dw: number, result?: Ray3d): Ray3d {\r\n const mag = Geometry.correctSmallFraction(w);\r\n // real point is X/w.\r\n // real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.\r\n const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.\r\n const aa = a * a;\r\n return Ray3d.createXYZUVW(x * a, y * a, z * a, (dx * w - dw * x) * aa, (dy * w - dw * y) * aa, (dz * w - dw * z) * aa, result);\r\n }\r\n /**\r\n * * If w is nonzero, return Vector3d which is the derivative of the projected xyz with given w and 4d derivatives.\r\n * * If w is zero, return 000\r\n * @param x x coordinate\r\n * @param y y coordinate\r\n * @param z z coordinate\r\n * @param w w coordinate\r\n * @param dx x coordinate of derivative\r\n * @param dy y coordinate of derivative\r\n * @param dz z coordinate of derivative\r\n * @param dw w coordinate of derivative\r\n * @param result optional result\r\n */\r\n public static createRealDerivativePlane3dByOriginAndVectorsDefault000(x: number, y: number, z: number, w: number, dx: number, dy: number, dz: number, dw: number, ddx: number, ddy: number, ddz: number, ddw: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const mag = Geometry.correctSmallFraction(w);\r\n // real point is X/w.\r\n // real derivative is (X' * w - X *w) / ww, and weight is always 0 by cross products.\r\n const a = mag === 0 ? 0.0 : (1.0 / mag); // in zero case everything multiplies right back to true zero.\r\n const aa = a * a;\r\n const fx = x * a;\r\n const fy = y * a;\r\n const fz = z * a;\r\n const dfx = (dx * w - dw * x) * aa;\r\n const dfy = (dy * w - dw * y) * aa;\r\n const dfz = (dz * w - dw * z) * aa;\r\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(fx, fy, fz, dfx, dfy, dfz, quotientDerivative2(ddx, dw, ddw, fx, dfx, a), quotientDerivative2(ddy, dw, ddw, fy, dfy, a), quotientDerivative2(ddz, dw, ddw, fz, dfz, a), result);\r\n }\r\n /**\r\n * * If this.w is nonzero, return Point3d with x/w,y/w,z/w.\r\n * * If this.w is zero, return 000\r\n */\r\n public realPointDefault000(result?: Point3d): Point3d {\r\n const mag = Geometry.correctSmallFraction(this.xyzw[3]);\r\n if (mag === 0.0)\r\n return Point3d.create(0, 0, 0, result);\r\n result = result ? result : new Point3d();\r\n const a = 1.0 / mag;\r\n return Point3d.create(this.xyzw[0] * a, this.xyzw[1] * a, this.xyzw[2] * a, result);\r\n }\r\n /** divide all components (x,y,z,w) by the 4d magnitude.\r\n *\r\n * * This is appropriate for normalizing a quaternion\r\n * * Use normalizeWeight to divide by the w component.\r\n */\r\n public normalizeXYZW(result?: Point4d): Point4d | undefined {\r\n const mag = Geometry.correctSmallFraction(this.magnitudeXYZW());\r\n result = result ? result : new Point4d();\r\n return this.safeDivideOrNull(mag, result);\r\n }\r\n\r\n /**\r\n * Return the determinant of the 3x3 matrix using components i,j,k of the 3 inputs.\r\n */\r\n public static determinantIndexed3X3(pointA: Point4d, pointB: Point4d, pointC: Point4d, i: number, j: number, k: number) {\r\n return Geometry.tripleProduct(\r\n pointA.xyzw[i], pointA.xyzw[j], pointA.xyzw[k],\r\n pointB.xyzw[i], pointB.xyzw[j], pointB.xyzw[k],\r\n pointC.xyzw[i], pointC.xyzw[j], pointC.xyzw[k]);\r\n }\r\n /**\r\n * Return a Point4d perpendicular to all 3 inputs. (A higher level cross product concept)\r\n * @param pointA first point\r\n * @param pointB second point\r\n * @param pointC third point\r\n */\r\n public static perpendicularPoint4dPlane(pointA: Point4d, pointB: Point4d, pointC: Point4d): Point4d {\r\n return Point4d.create(\r\n Point4d.determinantIndexed3X3(pointA, pointB, pointC, 1, 2, 3),\r\n -Point4d.determinantIndexed3X3(pointA, pointB, pointC, 2, 3, 0),\r\n Point4d.determinantIndexed3X3(pointA, pointB, pointC, 3, 0, 1),\r\n -Point4d.determinantIndexed3X3(pointA, pointB, pointC, 0, 1, 2));\r\n }\r\n /** Treating this Point4d as plane coefficients, convert to origin and normal form. */\r\n public toPlane3dByOriginAndUnitNormal(result?: Plane3dByOriginAndUnitNormal): Plane3dByOriginAndUnitNormal | undefined {\r\n return Plane3dByOriginAndUnitNormal.createFrom(this, result);\r\n }\r\n /** Normalize so sum of squares of all 4 coordinates is 1. */\r\n public normalizeQuaternion() {\r\n const magnitude = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);\r\n\r\n if (magnitude > 0.0) {\r\n const f = 1.0 / magnitude;\r\n this.x *= f;\r\n this.y *= f;\r\n this.z *= f;\r\n this.w *= f;\r\n }\r\n return magnitude;\r\n }\r\n /** Return a (normalized) quaternion interpolated between two quaternions. */\r\n public static interpolateQuaternions(quaternion0: Point4d, fractionParameter: number, quaternion1: Point4d, result?: Point4d): Point4d {\r\n if (!result)\r\n result = new Point4d();\r\n const maxSafeCosine = 0.9995;\r\n\r\n // return exact quaternions for special values\r\n if (0.0 === fractionParameter) {\r\n result = quaternion0;\r\n return result;\r\n }\r\n if (1.0 === fractionParameter) {\r\n result = quaternion1;\r\n return result;\r\n }\r\n if (0.5 === fractionParameter) {\r\n quaternion0.plus(quaternion1, result);\r\n result.normalizeQuaternion();\r\n return result;\r\n }\r\n\r\n const q0 = quaternion0.clone();\r\n const q1 = quaternion1.clone();\r\n let dot = quaternion0.dotProduct(quaternion1);\r\n\r\n // prevent interpolation through the longer great arc\r\n if (dot < 0.0) {\r\n q1.negate(q1);\r\n dot = -dot;\r\n }\r\n\r\n // if nearly parallel, use interpolate and renormalize .\r\n if (dot > maxSafeCosine) {\r\n q0.interpolate(fractionParameter, q1, result);\r\n result.normalizeQuaternion();\r\n return result;\r\n }\r\n\r\n // safety check\r\n if (dot < -1.0)\r\n dot = -1.0;\r\n else if (dot > 1.0)\r\n dot = 1.0;\r\n\r\n // create orthonormal basis {q0, q2}\r\n const q2 = new Point4d();\r\n q1.plusScaled(q0, -dot, q2); // bsiDPoint4d_addScaledDPoint4d(& q2, & q1, & q0, -dot);\r\n q2.normalizeQuaternion();\r\n\r\n const angle = Math.acos(dot);\r\n const angleOfInterpolation = angle * fractionParameter;\r\n result = Point4d.createAdd2Scaled(q0, Math.cos(angleOfInterpolation), q2, Math.sin(angleOfInterpolation));\r\n return result;\r\n }\r\n /** Measure the \"angle\" between two points, using all 4 components in the dot product that\r\n * gives the cosine of the angle.\r\n */\r\n public radiansToPoint4dXYZW(other: Point4d): number | undefined {\r\n const magA = this.magnitudeXYZW();\r\n const magB = other.magnitudeXYZW();\r\n const dot = this.dotProduct(other); // == cos (theta) * magA * magB\r\n const cos = Geometry.conditionalDivideFraction(dot, magA * magB);\r\n if (cos === undefined)\r\n return undefined;\r\n return Math.acos(cos);\r\n }\r\n}\r\n"]}
@@ -1,3 +1,6 @@
1
+ /** @packageDocumentation
2
+ * @module Numerics
3
+ */
1
4
  import { CurvePrimitive } from "../curve/CurvePrimitive";
2
5
  import { Plane3dByOriginAndVectors } from "../geometry3d/Plane3dByOriginAndVectors";
3
6
  import { Point3d } from "../geometry3d/Point3dVector3d";
@@ -1 +1 @@
1
- {"version":3,"file":"Newton.d.ts","sourceRoot":"","sources":["../../../src/numerics/Newton.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAMxD;;;;GAIG;AACH,8BAAsB,sBAAsB;IAC1C,wGAAwG;aACxF,WAAW,IAAI,OAAO;IACtC;;;OAGG;aACa,eAAe,IAAI,MAAM;IACzC;;;OAGG;aACa,gBAAgB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAC/D;;;;;;;;;;;OAWG;IACH,SAAS,aACP,iBAAiB,GAAE,MAAgB,EACnC,2BAA2B,GAAE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