@itwin/core-geometry 4.10.0-dev.3 → 4.10.0-dev.30
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.
- package/CHANGELOG.md +31 -1
- package/lib/cjs/Geometry.d.ts +2 -2
- package/lib/cjs/Geometry.js +2 -2
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.d.ts +7 -7
- package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPrimitive.js +1 -1
- package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
- package/lib/cjs/core-geometry.d.ts +1 -1
- package/lib/cjs/core-geometry.d.ts.map +1 -1
- package/lib/cjs/core-geometry.js +1 -1
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts +21 -10
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +66 -38
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +27 -8
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +44 -25
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveFactory.d.ts +11 -13
- package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
- package/lib/cjs/curve/CurveFactory.js +19 -46
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +2 -2
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +5 -4
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +40 -65
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +131 -70
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
- package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
- package/lib/cjs/geometry3d/Angle.d.ts +5 -5
- package/lib/cjs/geometry3d/Angle.js +5 -5
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +101 -13
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +156 -57
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/BilinearPatch.js +4 -4
- package/lib/cjs/geometry3d/BilinearPatch.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +35 -31
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +55 -31
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +6 -5
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +6 -5
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +2 -2
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +2 -2
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +4 -2
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +4 -2
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry4d/Map4d.d.ts +5 -5
- package/lib/cjs/geometry4d/Map4d.js +5 -5
- package/lib/cjs/geometry4d/Map4d.js.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.d.ts +4 -7
- package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.js +4 -7
- package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Point4d.js +2 -1
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/numerics/Newton.d.ts +3 -0
- package/lib/cjs/numerics/Newton.d.ts.map +1 -1
- package/lib/cjs/numerics/Newton.js +2 -5
- package/lib/cjs/numerics/Newton.js.map +1 -1
- package/lib/cjs/numerics/Polynomials.d.ts +46 -201
- package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/Polynomials.js +132 -445
- package/lib/cjs/numerics/Polynomials.js.map +1 -1
- package/lib/cjs/numerics/SmallSystem.d.ts +164 -0
- package/lib/cjs/numerics/SmallSystem.d.ts.map +1 -0
- package/lib/cjs/numerics/SmallSystem.js +321 -0
- package/lib/cjs/numerics/SmallSystem.js.map +1 -0
- package/lib/cjs/polyface/PolyfaceClip.d.ts +3 -3
- package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
- package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
- package/lib/cjs/polyface/multiclip/OffsetMeshContext.js +7 -7
- package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -1
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +2 -2
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/cjs/topology/InsertAndRetriangulateContext.js +2 -2
- package/lib/cjs/topology/InsertAndRetriangulateContext.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +1 -1
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +2 -2
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/esm/Geometry.d.ts +2 -2
- package/lib/esm/Geometry.js +2 -2
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.d.ts +7 -7
- package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPrimitive.js +1 -1
- package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
- package/lib/esm/core-geometry.d.ts +1 -1
- package/lib/esm/core-geometry.d.ts.map +1 -1
- package/lib/esm/core-geometry.js +1 -1
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +21 -10
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +66 -38
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +27 -8
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +44 -25
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +11 -13
- package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
- package/lib/esm/curve/CurveFactory.js +17 -44
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +1 -1
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +4 -3
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +35 -60
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +130 -69
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
- package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
- package/lib/esm/geometry3d/Angle.d.ts +5 -5
- package/lib/esm/geometry3d/Angle.js +5 -5
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +101 -13
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +156 -57
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/BilinearPatch.js +1 -1
- package/lib/esm/geometry3d/BilinearPatch.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +35 -31
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +55 -31
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +6 -5
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +6 -5
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +2 -2
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +1 -1
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +4 -2
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +4 -2
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry4d/Map4d.d.ts +5 -5
- package/lib/esm/geometry4d/Map4d.js +5 -5
- package/lib/esm/geometry4d/Map4d.js.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.d.ts +4 -7
- package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.js +4 -7
- package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Point4d.js +2 -1
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/numerics/Newton.d.ts +3 -0
- package/lib/esm/numerics/Newton.d.ts.map +1 -1
- package/lib/esm/numerics/Newton.js +1 -4
- package/lib/esm/numerics/Newton.js.map +1 -1
- package/lib/esm/numerics/Polynomials.d.ts +46 -201
- package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
- package/lib/esm/numerics/Polynomials.js +132 -444
- package/lib/esm/numerics/Polynomials.js.map +1 -1
- package/lib/esm/numerics/SmallSystem.d.ts +164 -0
- package/lib/esm/numerics/SmallSystem.d.ts.map +1 -0
- package/lib/esm/numerics/SmallSystem.js +317 -0
- package/lib/esm/numerics/SmallSystem.js.map +1 -0
- package/lib/esm/polyface/PolyfaceClip.d.ts +3 -3
- package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +1 -1
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts +1 -1
- package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -1
- package/lib/esm/polyface/multiclip/OffsetMeshContext.js +4 -4
- package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -1
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +1 -1
- package/lib/esm/topology/Graph.js.map +1 -1
- package/lib/esm/topology/InsertAndRetriangulateContext.js +1 -1
- package/lib/esm/topology/InsertAndRetriangulateContext.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +1 -1
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +1 -1
- package/lib/esm/topology/Merging.js.map +1 -1
- package/package.json +7 -19
|
@@ -363,7 +363,8 @@ export class Point4d extends Plane3d {
|
|
|
363
363
|
projectPointToPlane(spacePoint, result) {
|
|
364
364
|
const h = this.altitude(spacePoint);
|
|
365
365
|
const nn = this.magnitudeSquaredXYZ();
|
|
366
|
-
|
|
366
|
+
// this unusual tol is needed so that toPlane3dByOriginAndUnitNormal agrees with its original implementation
|
|
367
|
+
const alpha = Geometry.conditionalDivideCoordinate(-h, nn, Geometry.largeFractionResult * Geometry.largeFractionResult);
|
|
367
368
|
if (alpha === undefined)
|
|
368
369
|
return spacePoint.clone(result);
|
|
369
370
|
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,OAAO,EAAmB,QAAQ,EAA0B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Ac;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,QAAQ,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","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":[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,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,QAAQ,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","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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Newton.d.ts","sourceRoot":"","sources":["../../../src/numerics/Newton.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Newton.d.ts","sourceRoot":"","sources":["../../../src/numerics/Newton.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,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,MAAU,EACvC,aAAa,GAAE,MAAW;IAM5B,sEAAsE;IACtE,SAAS,CAAC,YAAY,EAAE,MAAM,CAAK;IACnC,gDAAgD;IAChD,SAAS,CAAC,4BAA4B,EAAE,MAAM,CAAC;IAC/C,4FAA4F;IAC5F,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACrC,8BAA8B;IAC9B,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IACjC,uDAAuD;IAChD,aAAa,EAAE,MAAM,CAAK;IACjC;;;;;OAKG;IACI,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAQ9C;;;;;;OAMG;IACI,aAAa,IAAI,OAAO;CAYhC;AACD;;;;GAIG;AACH,8BAAsB,oBAAoB;I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tB;AAED;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,sBAAsB;IACzE,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,KAAK,CAAQ;gBACT,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc;IAOnD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;CAmB/D;AAED;;;GAGG;AACH,qBAAa,8BAA+B,SAAQ,oBAAoB;IACtE,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAA4B;gBAC/B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO;IAM5C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAoB5C;AAED;;;GAGG;AACH,qBAAa,gCAAiC,SAAQ,sBAAsB;IAC1E,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,OAAO,CAA4B;gBAC/B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc;IAOnD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;CAqC/D"}
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @packageDocumentation
|
|
6
|
-
* @module Numerics
|
|
7
|
-
*/
|
|
8
5
|
import { Geometry } from "../Geometry";
|
|
9
6
|
import { Plane3dByOriginAndVectors } from "../geometry3d/Plane3dByOriginAndVectors";
|
|
10
7
|
import { Point2d, Vector2d } from "../geometry3d/Point2dVector2d";
|
|
11
8
|
import { Ray3d } from "../geometry3d/Ray3d";
|
|
12
|
-
import { SmallSystem } from "./
|
|
9
|
+
import { SmallSystem } from "./SmallSystem";
|
|
13
10
|
// cspell:word currentdFdX XYRR
|
|
14
11
|
/**
|
|
15
12
|
* Base class for Newton iterations in various dimensions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Newton.js","sourceRoot":"","sources":["../../../src/numerics/Newton.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,+BAA+B;AAE/B;;;;GAIG;AACH,MAAM,OAAgB,sBAAsB;IAa1C;;;;;;;;;;;OAWG;IACH,YACE,oBAA4B,OAAO,EACnC,8BAAsC,CAAC,EACvC,gBAAwB,EAAE;QAM5B,sEAAsE;QAC5D,iBAAY,GAAW,CAAC,CAAC;QAOnC,uDAAuD;QAChD,kBAAa,GAAW,CAAC,CAAC;QAb/B,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;QAC5C,IAAI,CAAC,4BAA4B,GAAG,2BAA2B,CAAC;QAChE,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAWD;;;;;OAKG;IACI,eAAe,CAAC,KAAa;QAClC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC9C,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,4BAA4B,CAAC;QAChE,CAAC;QACD,IAA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AO,CAAC,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAClC,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,EAC/B,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,EAC/B,GAAG,EACH,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACzE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACrC,GAAG,EACH,CAAC,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,EACxC,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACzE,GAAG,CACJ,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Numerics\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { SmallSystem } from \"./Polynomials\";\r\n\r\n// cspell:word currentdFdX XYRR\r\n\r\n/**\r\n * Base class for Newton iterations in various dimensions.\r\n * Dimension-specific classes carry all dimension-related data and answer generalized queries from this base class.\r\n * @internal\r\n */\r\nexport abstract class AbstractNewtonIterator {\r\n /** Compute a step. The current x and function values must be retained for use in later method calls. */\r\n public abstract computeStep(): boolean;\r\n /**\r\n * Return the current step size, scaled for use in tolerance tests.\r\n * * This is a single number, typically the max of various per-dimension `dx/(1+x)` for the x and dx of that dimension.\r\n */\r\n public abstract currentStepSize(): number;\r\n /**\r\n * Apply the current step (in all dimensions).\r\n * @param isFinalStep true if this is a final step.\r\n */\r\n public abstract applyCurrentStep(isFinalStep: boolean): boolean;\r\n /**\r\n * The constructor.\r\n * @param stepSizeTarget tolerance to consider a single step converged.\r\n * This number should be \"moderately\" strict. Because 2 successive convergences are required,\r\n * it is expected that a first \"accept\" for (say) 10 to 14 digit step will be followed by another\r\n * iteration. A well behaved newton would then hypothetically double the number of digits to\r\n * 20 to 28. Since the IEEE double only carries 16 digits, this second-convergence step will\r\n * typically achieve full precision.\r\n * @param successiveConvergenceTarget number of successive convergences required for acceptance.\r\n * @param maxIterations max number of iterations. A typical newton step converges in 3 to 6 iterations.\r\n * Allow 15 to 20 to catch difficult cases.\r\n */\r\n protected constructor(\r\n stepSizeTolerance: number = 1.0e-11,\r\n successiveConvergenceTarget: number = 2,\r\n maxIterations: number = 15,\r\n ) {\r\n this._stepSizeTolerance = stepSizeTolerance;\r\n this._successiveConvergenceTarget = successiveConvergenceTarget;\r\n this._maxIterations = maxIterations;\r\n }\r\n /** Number of consecutive steps which passed convergence condition. */\r\n protected _numAccepted: number = 0;\r\n /** Target number of successive convergences. */\r\n protected _successiveConvergenceTarget: number;\r\n /** Convergence target (the implementation-specific currentStepSize is compared to this). */\r\n protected _stepSizeTolerance: number;\r\n /** Max iterations allowed. */\r\n protected _maxIterations: number;\r\n /** Number of iterations (incremented at each step). */\r\n public numIterations: number = 0;\r\n /**\r\n * Test if a step is converged.\r\n * * Convergence is accepted with enough (_successiveConvergenceTarget) small steps (according to _stepSizeTolerance)\r\n * occur in succession.\r\n * @param delta step size as reported by currentStepSize.\r\n */\r\n public testConvergence(delta: number): boolean {\r\n if (Math.abs(delta) < this._stepSizeTolerance) {\r\n this._numAccepted++;\r\n return this._numAccepted >= this._successiveConvergenceTarget;\r\n }\r\n this._numAccepted = 0;\r\n return false;\r\n }\r\n /**\r\n * Run iterations, calling various methods from base and derived classes:\r\n * * computeStep -- typically evaluate derivatives and solve linear system.\r\n * * currentStepSize -- return numeric measure of the step just computed by computeStep.\r\n * * testConvergence -- test if the step from currentStepSize (along with recent steps) is converged.\r\n * * applyCurrentStep -- apply the step to the independent variables.\r\n */\r\n public runIterations(): boolean {\r\n this._numAccepted = 0;\r\n this.numIterations = 0;\r\n while (this.numIterations++ < this._maxIterations && this.computeStep()) {\r\n if (this.testConvergence(this.currentStepSize()) && this.applyCurrentStep(true)) {\r\n // console.log(\"iter: \" + this.numIterations); // print number of Newton iterations for debug\r\n return true;\r\n }\r\n this.applyCurrentStep(false);\r\n }\r\n return false;\r\n }\r\n}\r\n/**\r\n * Object to evaluate a newton function. The object must retain most-recent function and derivative\r\n * values for immediate query.\r\n * @internal\r\n */\r\nexport abstract class NewtonEvaluatorRtoRD {\r\n /** Evaluate the function and its derivative at x. */\r\n public abstract evaluate(x: number): boolean;\r\n /** Most recent function value, i.e., f(x_n). */\r\n public currentF!: number;\r\n /** Most recent evaluated derivative, i.e., f'(x_n). */\r\n public currentdFdX!: number;\r\n}\r\n/**\r\n * Newton iterator for use when both function and derivative can be evaluated.\r\n * To solve `f(x) = 0`, the Newton iteration is `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n)`.\r\n * To solve `f(x) = target` which is equivalent to solving `g(x) = f(x) - target = 0`, the Newton iteration is\r\n * `x_{n+1} = x_n - dx = x_n - g(x_n)/g'(x_n) = x_n - (f(x_n)-target)/f'(x_n)`.\r\n * @internal\r\n */\r\nexport class Newton1dUnbounded extends AbstractNewtonIterator {\r\n private _func: NewtonEvaluatorRtoRD;\r\n /** Current step is dx. */\r\n private _currentStep!: number;\r\n /** Current X is x_n. */\r\n private _currentX!: number;\r\n /** The target */\r\n private _target!: number;\r\n /**\r\n * Constructor for 1D newton iteration with derivatives.\r\n * @param func function that returns both function value and derivative.\r\n */\r\n public constructor(func: NewtonEvaluatorRtoRD, maxIterations?: number) {\r\n super(undefined, undefined, maxIterations);\r\n this._func = func;\r\n this.setTarget(0);\r\n }\r\n /** Set the independent variable, i.e., x_n. */\r\n public setX(x: number): boolean {\r\n this._currentX = x;\r\n return true;\r\n }\r\n /** Get the independent variable, i.e., x_n. */\r\n public getX(): number {\r\n return this._currentX;\r\n }\r\n /** Set the target function value. */\r\n public setTarget(y: number): void {\r\n this._target = y;\r\n }\r\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\r\n public applyCurrentStep(): boolean {\r\n // console.log(this._currentX - this._currentStep); // print approximations for debug\r\n return this.setX(this._currentX - this._currentStep);\r\n }\r\n /** Compute the univariate newton step dx. */\r\n public computeStep(): boolean {\r\n if (this._func.evaluate(this._currentX)) {\r\n const dx = Geometry.conditionalDivideFraction(this._func.currentF - this._target, this._func.currentdFdX);\r\n if (dx !== undefined) {\r\n this._currentStep = dx;\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\r\n public currentStepSize(): number {\r\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\r\n }\r\n}\r\n\r\n/**\r\n * Object to evaluate a newton function (without derivative). The object must retain most-recent function value.\r\n * @internal\r\n */\r\nexport abstract class NewtonEvaluatorRtoR {\r\n /** Evaluate function value into member currentF */\r\n public abstract evaluate(x: number): boolean;\r\n /** Most recent function evaluation, i.e., f(x_n). */\r\n public currentF!: number;\r\n}\r\n\r\n/**\r\n * Newton iteration for a univariate function, using approximate derivatives.\r\n * To approximate the derivatives we use a small step `h`, i.e., `f'(x_n) = (f(x_n + h) - f(x_n)) / h`.\r\n * Therefore, to solve `f(x) = 0`, the iteration is\r\n * `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n) = x_n - f(x_n) * h / (f(x_n + h) - f(x_n))`.\r\n * @internal\r\n */\r\nexport class Newton1dUnboundedApproximateDerivative extends AbstractNewtonIterator {\r\n private _func: NewtonEvaluatorRtoR;\r\n /** Current step is dx. */\r\n private _currentStep!: number;\r\n /** Current X is x_n. */\r\n private _currentX!: number;\r\n /**\r\n * Step size for approximate derivative for the iteration.\r\n * * Initialized to 1e-8, which is appropriate for iteration in fraction space.\r\n * * Should be larger for iteration with real distance as x.\r\n */\r\n public derivativeH: number; // h\r\n\r\n /**\r\n * Constructor for 1D newton iteration with approximate derivatives.\r\n * @param func function that only returns function value (and not derivative).\r\n */\r\n public constructor(func: NewtonEvaluatorRtoR, maxIterations?: number) {\r\n super(undefined, undefined, maxIterations);\r\n this._func = func;\r\n this.derivativeH = 1.0e-8;\r\n }\r\n /** Set the independent variable, i.e., x_n. */\r\n public setX(x: number): boolean {\r\n this._currentX = x;\r\n return true;\r\n }\r\n /** Get the independent variable, i.e., x_n. */\r\n public getX(): number {\r\n return this._currentX;\r\n }\r\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\r\n public applyCurrentStep(): boolean {\r\n // console.log(this._currentX - this._currentStep); // print approximations for debug\r\n return this.setX(this._currentX - this._currentStep);\r\n }\r\n /** Univariate newton step dx, computed with approximate derivative. */\r\n public computeStep(): boolean {\r\n if (this._func.evaluate(this._currentX)) {\r\n const fA = this._func.currentF; // f(x_n)\r\n if (this._func.evaluate(this._currentX + this.derivativeH)) {\r\n const fB = this._func.currentF; // f(x_n + h)\r\n const dx = Geometry.conditionalDivideFraction(fA, (fB - fA) / this.derivativeH);\r\n if (dx !== undefined) {\r\n this._currentStep = dx;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\r\n public currentStepSize(): number {\r\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\r\n }\r\n}\r\n\r\n/**\r\n * Object to evaluate a 2-parameter newton function with derivatives.\r\n * @internal\r\n */\r\nexport abstract class NewtonEvaluatorRRtoRRD {\r\n /**\r\n * Iteration controller calls this to ask for evaluation of the function and its two partial derivatives.\r\n * * The implementation returns true, it must set the currentF object.\r\n */\r\n public abstract evaluate(x: number, y: number): boolean;\r\n /**\r\n * Most recent function evaluation as parts of the plane.\r\n * * See doc of [[Newton2dUnboundedWithDerivative]] class for info on 2d newton method.\r\n * * For `F(u,v) := (x(u,v), y(u,v))` the returned plane stores the following evaluations at current value `X := (u,v)`:\r\n * * `origin` = F(X) = (x(X), y(X))\r\n * * `vectorU` = F_u(X) = partial deriv of F wrt u at X = (x_u(X), y_u(X)) = 1st col of Jacobian matrix evaluated at X\r\n * * `vectorV` = F_v(X) = partial deriv of F wrt v at X = (x_v(X), y_v(X)) = 2nd col of Jacobian matrix evaluated at X\r\n */\r\n public currentF!: Plane3dByOriginAndVectors;\r\n /**\r\n * Constructor.\r\n * * This creates a currentF object to (repeatedly) receive function and derivatives.\r\n */\r\n public constructor() {\r\n this.currentF = Plane3dByOriginAndVectors.createXYPlane();\r\n }\r\n}\r\n\r\n/**\r\n * Implement evaluation steps for newton iteration in 2 dimensions, using caller supplied NewtonEvaluatorRRtoRRD object.\r\n * * Suppose we want to find the roots of `F(u,v) := (x(u,v), y(u,v))`. Writing `X := (u,v)` and `F(X)` as column vectors,\r\n * the 2D Newton's iteration to find a root of `F` is given by:\r\n * `X_{n+1} = X_n - dX = X_n - JInv(X_n)F(X_n)`, where `JInv` is the inverse of the Jacobian matrix `J`, and `J` is\r\n * defined by the partial derivatives of the component functions of F:\r\n *\r\n * `[dx/du dx/dv]`\r\n *\r\n * `[dy/du dy/dv]`\r\n * @internal\r\n */\r\nexport class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {\r\n private _func: NewtonEvaluatorRRtoRRD;\r\n /** Current step, or dX = (du, dv). */\r\n private _currentStep: Vector2d;\r\n /** Current uv parameters, or X_n = (u_n, v_n). */\r\n private _currentUV: Point2d;\r\n /**\r\n * Constructor for 2D newton iteration with derivatives.\r\n * @param func function that returns both function value and derivative.\r\n */\r\n public constructor(func: NewtonEvaluatorRRtoRRD, maxIterations?: number) {\r\n super(undefined, undefined, maxIterations);\r\n this._func = func;\r\n this._currentStep = Vector2d.createZero();\r\n this._currentUV = Point2d.createZero();\r\n }\r\n /** Set the current uv parameters, i.e., `X_n = (u_n, v_n)`. */\r\n public setUV(u: number, v: number): boolean {\r\n this._currentUV.set(u, v);\r\n return true;\r\n }\r\n /** Get the current u parameter of X_n, i.e., u_n. */\r\n public getU(): number {\r\n return this._currentUV.x;\r\n }\r\n /** Get the current v parameter of X_n, i.e., v_n. */\r\n public getV(): number {\r\n return this._currentUV.y;\r\n }\r\n /** Update the current uv parameter by currentStep, i.e., compute `X_{n+1} := X_n - dX = (u_n - du, v_n - dv)`. */\r\n public applyCurrentStep(): boolean {\r\n // console.log(\"(\" + (this._currentUV.x - this._currentStep.x) + \",\" + (this._currentUV.y - this._currentStep.y) + \")\");\r\n return this.setUV(this._currentUV.x - this._currentStep.x, this._currentUV.y - this._currentStep.y);\r\n }\r\n /**\r\n * Evaluate the functions and derivatives at `X_n = (u_n, v_n)`, and solve the Jacobian matrix equation to\r\n * compute `dX = (du, dv)`.\r\n */\r\n public computeStep(): boolean {\r\n if (!this._func.evaluate(this._currentUV.x, this._currentUV.y))\r\n return false;\r\n const fA = this._func.currentF;\r\n const jCol0 = fA.vectorU;\r\n const jCol1 = fA.vectorV;\r\n const fX = fA.origin;\r\n // Given X_{n+1} = X_n - dX = X_n - JInv(X_n) F(X_n), we solve J(X_n) dX = F(X_n) for dX:\r\n if (SmallSystem.linearSystem2d(jCol0.x, jCol1.x, jCol0.y, jCol1.y, fX.x, fX.y, this._currentStep))\r\n return true;\r\n return false;\r\n }\r\n /**\r\n * Return the current relative step size, i.e., the larger absolute component of `dX / (1 + |X_n|)`\r\n */\r\n public currentStepSize(): number {\r\n return Geometry.maxAbsXY(\r\n this._currentStep.x / (1.0 + Math.abs(this._currentUV.x)),\r\n this._currentStep.y / (1.0 + Math.abs(this._currentUV.y)),\r\n );\r\n }\r\n}\r\n/**\r\n * SimpleNewton has static methods for newton methods with evaluated functions presented as immediate arguments\r\n * (not function object).\r\n * @internal\r\n */\r\nexport class SimpleNewton {\r\n /**\r\n * Run a one-dimensional newton iteration with separate functions for function and derivative.\r\n * * Completion is at 2 (TWO) successive passes at `absoluteTolerance + relTol * abs(x)`, where relTol is\r\n * chosen internally.\r\n * * `absoluteTolerance` is usually aggressively tight -- should come into play only for x near zero.\r\n * * The `relTol` is fluffy (for instance around 1e-11) but in properly converging cases the extra pass after\r\n * first success normally moves to full machine precision.\r\n * * This is an open-loop newton -- it just runs, and returns undefined if anything bad happens.\r\n */\r\n public static runNewton1D(\r\n x: number,\r\n func: (x: number) => number | undefined,\r\n derivative: (x: number) => number | undefined,\r\n absoluteTolerance: number = Geometry.smallFloatingPoint,\r\n ): number | undefined {\r\n let numConverged = 0;\r\n let tolerance: number;\r\n const relTol = 1.0e-11;\r\n for (let iteration = 0; iteration < 20; iteration++) {\r\n const f = func(x);\r\n const df = derivative(x);\r\n if (f !== undefined && df !== undefined) {\r\n const dx = Geometry.conditionalDivideCoordinate(f, df);\r\n if (dx === undefined)\r\n return undefined;\r\n x -= dx;\r\n // console.log(x); // print approximations for debug\r\n tolerance = absoluteTolerance + Math.abs(x) * relTol;\r\n if (Math.abs(dx) < tolerance) {\r\n numConverged++;\r\n if (dx === 0.0 || numConverged > 1) // bypass convergence count on true 0 dx\r\n return x;\r\n } else {\r\n numConverged = 0;\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Class to evaluate XY intersection between 2 curve primitives using the Newton method.\r\n * @internal\r\n */\r\nexport class CurveCurveIntersectionXYRRToRRD extends NewtonEvaluatorRRtoRRD {\r\n private _curveP: CurvePrimitive;\r\n private _curveQ: CurvePrimitive;\r\n private _rayP: Ray3d;\r\n private _rayQ: Ray3d;\r\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\r\n super();\r\n this._curveP = curveP;\r\n this._curveQ = curveQ;\r\n this._rayP = Ray3d.createZero();\r\n this._rayQ = Ray3d.createZero();\r\n }\r\n public evaluate(fractionU: number, fractionV: number): boolean {\r\n /**\r\n * To find an intersection between xy-curves P(u) = (x_p(u), y_p(u)) and Q(v) = (x_q(v), y_q(v)) we should solve\r\n * F(u,v) := P(u) - Q(v) = (0,0)\r\n * Using the Newton method we can find the fractions u and v at the intersection via\r\n * [u_{n+1}] [u_n] [x_p'(u_n) -x_q'(v_n)] [x_p(u_n) - x_q(v_n)]\r\n * = - Inv( )\r\n * [v_{n+1}] [v_n] [y_p'(u_n) -y_q'(v_n)] [y_p(u_n) - y_q(v_n)]\r\n * Note that this is xy intersection so we can ignore z.\r\n */\r\n this._curveP.fractionToPointAndDerivative(fractionU, this._rayP);\r\n this._curveQ.fractionToPointAndDerivative(fractionV, this._rayQ);\r\n this.currentF.setOriginAndVectorsXYZ(\r\n this._rayP.origin.x - this._rayQ.origin.x, this._rayP.origin.y - this._rayQ.origin.y, 0.0,\r\n this._rayP.direction.x, this._rayP.direction.y, 0.0,\r\n -this._rayQ.direction.x, -this._rayQ.direction.y, 0.0,\r\n );\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Class to evaluate XY close approach between a curve primitive and a point using the Newton method.\r\n * @internal\r\n */\r\nexport class CurvePointCloseApproachXYRtoRD extends NewtonEvaluatorRtoRD {\r\n private _curveP: CurvePrimitive;\r\n private _pointQ: Point3d;\r\n private _planeP: Plane3dByOriginAndVectors;\r\n constructor(curveP: CurvePrimitive, pointQ: Point3d) {\r\n super();\r\n this._curveP = curveP;\r\n this._pointQ = pointQ;\r\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\r\n }\r\n public evaluate(fractionU: number): boolean {\r\n /**\r\n * To find a close approach between xy-curve P(u) and xy-point q we should solve\r\n * F(u) := P'(u).(P(u) - q) = 0\r\n * For a solution u, the segment S(u) := P(u) - q is perpendicular to the curve tangent P'(u), which means S(u) is a close approach.\r\n * Using the Newton method we can find the fractions u at the close approach location via\r\n * u_{n+1} = u_n + F(u_n)/F'(u_n) = u_n + [ P'(u_n).S(u_n) ]/[ P''(u_n).S(u_n) + P'(u_n).P'(u_n) ]\r\n * Note that this is xy close approach so we can ignore z.\r\n */\r\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\r\n const segX = this._planeP.origin.x - this._pointQ.x;\r\n const segY = this._planeP.origin.y - this._pointQ.y;\r\n const pDerivX = this._planeP.vectorU.x;\r\n const pDerivY = this._planeP.vectorU.y;\r\n const p2DerivX = this._planeP.vectorV.x;\r\n const p2DerivY = this._planeP.vectorV.y;\r\n this.currentF = pDerivX * segX + pDerivY * segY;\r\n this.currentdFdX = p2DerivX * segX + pDerivX * pDerivX + p2DerivY * segY + pDerivY * pDerivY;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Class to evaluate XY close approach between 2 curve primitives using the Newton method.\r\n * @internal\r\n */\r\nexport class CurveCurveCloseApproachXYRRtoRRD extends NewtonEvaluatorRRtoRRD {\r\n private _curveP: CurvePrimitive;\r\n private _curveQ: CurvePrimitive;\r\n private _planeP: Plane3dByOriginAndVectors;\r\n private _planeQ: Plane3dByOriginAndVectors;\r\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\r\n super();\r\n this._curveP = curveP;\r\n this._curveQ = curveQ;\r\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\r\n this._planeQ = Plane3dByOriginAndVectors.createXYPlane();\r\n }\r\n public evaluate(fractionU: number, fractionV: number): boolean {\r\n /**\r\n * To find a close approach between xy-curves P(u) and Q(v) we should solve\r\n * F(u,v) := (P'(u).(P(u) - Q(v)), Q'(v).(P(u) - Q(v))) = (0,0)\r\n * For a solution (u,v), the segment S(u,v) := P(u) - Q(v) is perpendicular to the curve tangents P'(u) and Q'(v),\r\n * which means S(u,v) is a close approach.\r\n * Using the Newton method we can find the fractions u and v at the close approach location via\r\n * [u_{n+1}] [u_n] [P''(u_n).S(u_n,v_n) + P'(u_n).P'(u_n) -P'(u_n).Q'(v_n)] [P'(u_n).S(u_n,v_n)]\r\n * = - Inv( )\r\n * [v_{n+1}] [v_n] [Q'(v_n).P'(u_n) Q''(v_n).S(u_n,v_n) - Q'(v_n).Q'(v_n)] [Q'(v_n).S(u_n,v_n)]\r\n * Note that this is xy close approach so we can ignore z.\r\n */\r\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\r\n this._curveQ.fractionToPointAnd2Derivatives(fractionV, this._planeQ);\r\n const segX = this._planeP.origin.x - this._planeQ.origin.x;\r\n const segY = this._planeP.origin.y - this._planeQ.origin.y;\r\n const pDerivX = this._planeP.vectorU.x;\r\n const pDerivY = this._planeP.vectorU.y;\r\n const qDerivX = this._planeQ.vectorU.x;\r\n const qDerivY = this._planeQ.vectorU.y;\r\n const p2DerivX = this._planeP.vectorV.x;\r\n const p2DerivY = this._planeP.vectorV.y;\r\n const q2DerivX = this._planeQ.vectorV.x;\r\n const q2DerivY = this._planeQ.vectorV.y;\r\n this.currentF.setOriginAndVectorsXYZ(\r\n pDerivX * segX + pDerivY * segY,\r\n qDerivX * segX + qDerivY * segY,\r\n 0.0,\r\n p2DerivX * segX + p2DerivY * segY + pDerivX * pDerivX + pDerivY * pDerivY,\r\n qDerivX * pDerivX + qDerivY * pDerivY,\r\n 0.0,\r\n -(pDerivX * qDerivX + pDerivY * qDerivY),\r\n q2DerivX * segX + q2DerivY * segY - qDerivX * qDerivX - qDerivY * qDerivY,\r\n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,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAClC,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,EAC/B,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,EAC/B,GAAG,EACH,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACzE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACrC,GAAG,EACH,CAAC,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,EACxC,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACzE,GAAG,CACJ,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Numerics\r\n */\r\n\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { SmallSystem } from \"./SmallSystem\";\r\n\r\n// cspell:word currentdFdX XYRR\r\n\r\n/**\r\n * Base class for Newton iterations in various dimensions.\r\n * Dimension-specific classes carry all dimension-related data and answer generalized queries from this base class.\r\n * @internal\r\n */\r\nexport abstract class AbstractNewtonIterator {\r\n /** Compute a step. The current x and function values must be retained for use in later method calls. */\r\n public abstract computeStep(): boolean;\r\n /**\r\n * Return the current step size, scaled for use in tolerance tests.\r\n * * This is a single number, typically the max of various per-dimension `dx/(1+x)` for the x and dx of that dimension.\r\n */\r\n public abstract currentStepSize(): number;\r\n /**\r\n * Apply the current step (in all dimensions).\r\n * @param isFinalStep true if this is a final step.\r\n */\r\n public abstract applyCurrentStep(isFinalStep: boolean): boolean;\r\n /**\r\n * The constructor.\r\n * @param stepSizeTarget tolerance to consider a single step converged.\r\n * This number should be \"moderately\" strict. Because 2 successive convergences are required,\r\n * it is expected that a first \"accept\" for (say) 10 to 14 digit step will be followed by another\r\n * iteration. A well behaved newton would then hypothetically double the number of digits to\r\n * 20 to 28. Since the IEEE double only carries 16 digits, this second-convergence step will\r\n * typically achieve full precision.\r\n * @param successiveConvergenceTarget number of successive convergences required for acceptance.\r\n * @param maxIterations max number of iterations. A typical newton step converges in 3 to 6 iterations.\r\n * Allow 15 to 20 to catch difficult cases.\r\n */\r\n protected constructor(\r\n stepSizeTolerance: number = 1.0e-11,\r\n successiveConvergenceTarget: number = 2,\r\n maxIterations: number = 15,\r\n ) {\r\n this._stepSizeTolerance = stepSizeTolerance;\r\n this._successiveConvergenceTarget = successiveConvergenceTarget;\r\n this._maxIterations = maxIterations;\r\n }\r\n /** Number of consecutive steps which passed convergence condition. */\r\n protected _numAccepted: number = 0;\r\n /** Target number of successive convergences. */\r\n protected _successiveConvergenceTarget: number;\r\n /** Convergence target (the implementation-specific currentStepSize is compared to this). */\r\n protected _stepSizeTolerance: number;\r\n /** Max iterations allowed. */\r\n protected _maxIterations: number;\r\n /** Number of iterations (incremented at each step). */\r\n public numIterations: number = 0;\r\n /**\r\n * Test if a step is converged.\r\n * * Convergence is accepted with enough (_successiveConvergenceTarget) small steps (according to _stepSizeTolerance)\r\n * occur in succession.\r\n * @param delta step size as reported by currentStepSize.\r\n */\r\n public testConvergence(delta: number): boolean {\r\n if (Math.abs(delta) < this._stepSizeTolerance) {\r\n this._numAccepted++;\r\n return this._numAccepted >= this._successiveConvergenceTarget;\r\n }\r\n this._numAccepted = 0;\r\n return false;\r\n }\r\n /**\r\n * Run iterations, calling various methods from base and derived classes:\r\n * * computeStep -- typically evaluate derivatives and solve linear system.\r\n * * currentStepSize -- return numeric measure of the step just computed by computeStep.\r\n * * testConvergence -- test if the step from currentStepSize (along with recent steps) is converged.\r\n * * applyCurrentStep -- apply the step to the independent variables.\r\n */\r\n public runIterations(): boolean {\r\n this._numAccepted = 0;\r\n this.numIterations = 0;\r\n while (this.numIterations++ < this._maxIterations && this.computeStep()) {\r\n if (this.testConvergence(this.currentStepSize()) && this.applyCurrentStep(true)) {\r\n // console.log(\"iter: \" + this.numIterations); // print number of Newton iterations for debug\r\n return true;\r\n }\r\n this.applyCurrentStep(false);\r\n }\r\n return false;\r\n }\r\n}\r\n/**\r\n * Object to evaluate a newton function. The object must retain most-recent function and derivative\r\n * values for immediate query.\r\n * @internal\r\n */\r\nexport abstract class NewtonEvaluatorRtoRD {\r\n /** Evaluate the function and its derivative at x. */\r\n public abstract evaluate(x: number): boolean;\r\n /** Most recent function value, i.e., f(x_n). */\r\n public currentF!: number;\r\n /** Most recent evaluated derivative, i.e., f'(x_n). */\r\n public currentdFdX!: number;\r\n}\r\n/**\r\n * Newton iterator for use when both function and derivative can be evaluated.\r\n * To solve `f(x) = 0`, the Newton iteration is `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n)`.\r\n * To solve `f(x) = target` which is equivalent to solving `g(x) = f(x) - target = 0`, the Newton iteration is\r\n * `x_{n+1} = x_n - dx = x_n - g(x_n)/g'(x_n) = x_n - (f(x_n)-target)/f'(x_n)`.\r\n * @internal\r\n */\r\nexport class Newton1dUnbounded extends AbstractNewtonIterator {\r\n private _func: NewtonEvaluatorRtoRD;\r\n /** Current step is dx. */\r\n private _currentStep!: number;\r\n /** Current X is x_n. */\r\n private _currentX!: number;\r\n /** The target */\r\n private _target!: number;\r\n /**\r\n * Constructor for 1D newton iteration with derivatives.\r\n * @param func function that returns both function value and derivative.\r\n */\r\n public constructor(func: NewtonEvaluatorRtoRD, maxIterations?: number) {\r\n super(undefined, undefined, maxIterations);\r\n this._func = func;\r\n this.setTarget(0);\r\n }\r\n /** Set the independent variable, i.e., x_n. */\r\n public setX(x: number): boolean {\r\n this._currentX = x;\r\n return true;\r\n }\r\n /** Get the independent variable, i.e., x_n. */\r\n public getX(): number {\r\n return this._currentX;\r\n }\r\n /** Set the target function value. */\r\n public setTarget(y: number): void {\r\n this._target = y;\r\n }\r\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\r\n public applyCurrentStep(): boolean {\r\n // console.log(this._currentX - this._currentStep); // print approximations for debug\r\n return this.setX(this._currentX - this._currentStep);\r\n }\r\n /** Compute the univariate newton step dx. */\r\n public computeStep(): boolean {\r\n if (this._func.evaluate(this._currentX)) {\r\n const dx = Geometry.conditionalDivideFraction(this._func.currentF - this._target, this._func.currentdFdX);\r\n if (dx !== undefined) {\r\n this._currentStep = dx;\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\r\n public currentStepSize(): number {\r\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\r\n }\r\n}\r\n\r\n/**\r\n * Object to evaluate a newton function (without derivative). The object must retain most-recent function value.\r\n * @internal\r\n */\r\nexport abstract class NewtonEvaluatorRtoR {\r\n /** Evaluate function value into member currentF */\r\n public abstract evaluate(x: number): boolean;\r\n /** Most recent function evaluation, i.e., f(x_n). */\r\n public currentF!: number;\r\n}\r\n\r\n/**\r\n * Newton iteration for a univariate function, using approximate derivatives.\r\n * To approximate the derivatives we use a small step `h`, i.e., `f'(x_n) = (f(x_n + h) - f(x_n)) / h`.\r\n * Therefore, to solve `f(x) = 0`, the iteration is\r\n * `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n) = x_n - f(x_n) * h / (f(x_n + h) - f(x_n))`.\r\n * @internal\r\n */\r\nexport class Newton1dUnboundedApproximateDerivative extends AbstractNewtonIterator {\r\n private _func: NewtonEvaluatorRtoR;\r\n /** Current step is dx. */\r\n private _currentStep!: number;\r\n /** Current X is x_n. */\r\n private _currentX!: number;\r\n /**\r\n * Step size for approximate derivative for the iteration.\r\n * * Initialized to 1e-8, which is appropriate for iteration in fraction space.\r\n * * Should be larger for iteration with real distance as x.\r\n */\r\n public derivativeH: number; // h\r\n\r\n /**\r\n * Constructor for 1D newton iteration with approximate derivatives.\r\n * @param func function that only returns function value (and not derivative).\r\n */\r\n public constructor(func: NewtonEvaluatorRtoR, maxIterations?: number) {\r\n super(undefined, undefined, maxIterations);\r\n this._func = func;\r\n this.derivativeH = 1.0e-8;\r\n }\r\n /** Set the independent variable, i.e., x_n. */\r\n public setX(x: number): boolean {\r\n this._currentX = x;\r\n return true;\r\n }\r\n /** Get the independent variable, i.e., x_n. */\r\n public getX(): number {\r\n return this._currentX;\r\n }\r\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\r\n public applyCurrentStep(): boolean {\r\n // console.log(this._currentX - this._currentStep); // print approximations for debug\r\n return this.setX(this._currentX - this._currentStep);\r\n }\r\n /** Univariate newton step dx, computed with approximate derivative. */\r\n public computeStep(): boolean {\r\n if (this._func.evaluate(this._currentX)) {\r\n const fA = this._func.currentF; // f(x_n)\r\n if (this._func.evaluate(this._currentX + this.derivativeH)) {\r\n const fB = this._func.currentF; // f(x_n + h)\r\n const dx = Geometry.conditionalDivideFraction(fA, (fB - fA) / this.derivativeH);\r\n if (dx !== undefined) {\r\n this._currentStep = dx;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\r\n public currentStepSize(): number {\r\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\r\n }\r\n}\r\n\r\n/**\r\n * Object to evaluate a 2-parameter newton function with derivatives.\r\n * @internal\r\n */\r\nexport abstract class NewtonEvaluatorRRtoRRD {\r\n /**\r\n * Iteration controller calls this to ask for evaluation of the function and its two partial derivatives.\r\n * * The implementation returns true, it must set the currentF object.\r\n */\r\n public abstract evaluate(x: number, y: number): boolean;\r\n /**\r\n * Most recent function evaluation as parts of the plane.\r\n * * See doc of [[Newton2dUnboundedWithDerivative]] class for info on 2d newton method.\r\n * * For `F(u,v) := (x(u,v), y(u,v))` the returned plane stores the following evaluations at current value `X := (u,v)`:\r\n * * `origin` = F(X) = (x(X), y(X))\r\n * * `vectorU` = F_u(X) = partial deriv of F wrt u at X = (x_u(X), y_u(X)) = 1st col of Jacobian matrix evaluated at X\r\n * * `vectorV` = F_v(X) = partial deriv of F wrt v at X = (x_v(X), y_v(X)) = 2nd col of Jacobian matrix evaluated at X\r\n */\r\n public currentF!: Plane3dByOriginAndVectors;\r\n /**\r\n * Constructor.\r\n * * This creates a currentF object to (repeatedly) receive function and derivatives.\r\n */\r\n public constructor() {\r\n this.currentF = Plane3dByOriginAndVectors.createXYPlane();\r\n }\r\n}\r\n\r\n/**\r\n * Implement evaluation steps for newton iteration in 2 dimensions, using caller supplied NewtonEvaluatorRRtoRRD object.\r\n * * Suppose we want to find the roots of `F(u,v) := (x(u,v), y(u,v))`. Writing `X := (u,v)` and `F(X)` as column vectors,\r\n * the 2D Newton's iteration to find a root of `F` is given by:\r\n * `X_{n+1} = X_n - dX = X_n - JInv(X_n)F(X_n)`, where `JInv` is the inverse of the Jacobian matrix `J`, and `J` is\r\n * defined by the partial derivatives of the component functions of F:\r\n *\r\n * `[dx/du dx/dv]`\r\n *\r\n * `[dy/du dy/dv]`\r\n * @internal\r\n */\r\nexport class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {\r\n private _func: NewtonEvaluatorRRtoRRD;\r\n /** Current step, or dX = (du, dv). */\r\n private _currentStep: Vector2d;\r\n /** Current uv parameters, or X_n = (u_n, v_n). */\r\n private _currentUV: Point2d;\r\n /**\r\n * Constructor for 2D newton iteration with derivatives.\r\n * @param func function that returns both function value and derivative.\r\n */\r\n public constructor(func: NewtonEvaluatorRRtoRRD, maxIterations?: number) {\r\n super(undefined, undefined, maxIterations);\r\n this._func = func;\r\n this._currentStep = Vector2d.createZero();\r\n this._currentUV = Point2d.createZero();\r\n }\r\n /** Set the current uv parameters, i.e., `X_n = (u_n, v_n)`. */\r\n public setUV(u: number, v: number): boolean {\r\n this._currentUV.set(u, v);\r\n return true;\r\n }\r\n /** Get the current u parameter of X_n, i.e., u_n. */\r\n public getU(): number {\r\n return this._currentUV.x;\r\n }\r\n /** Get the current v parameter of X_n, i.e., v_n. */\r\n public getV(): number {\r\n return this._currentUV.y;\r\n }\r\n /** Update the current uv parameter by currentStep, i.e., compute `X_{n+1} := X_n - dX = (u_n - du, v_n - dv)`. */\r\n public applyCurrentStep(): boolean {\r\n // console.log(\"(\" + (this._currentUV.x - this._currentStep.x) + \",\" + (this._currentUV.y - this._currentStep.y) + \")\");\r\n return this.setUV(this._currentUV.x - this._currentStep.x, this._currentUV.y - this._currentStep.y);\r\n }\r\n /**\r\n * Evaluate the functions and derivatives at `X_n = (u_n, v_n)`, and solve the Jacobian matrix equation to\r\n * compute `dX = (du, dv)`.\r\n */\r\n public computeStep(): boolean {\r\n if (!this._func.evaluate(this._currentUV.x, this._currentUV.y))\r\n return false;\r\n const fA = this._func.currentF;\r\n const jCol0 = fA.vectorU;\r\n const jCol1 = fA.vectorV;\r\n const fX = fA.origin;\r\n // Given X_{n+1} = X_n - dX = X_n - JInv(X_n) F(X_n), we solve J(X_n) dX = F(X_n) for dX:\r\n if (SmallSystem.linearSystem2d(jCol0.x, jCol1.x, jCol0.y, jCol1.y, fX.x, fX.y, this._currentStep))\r\n return true;\r\n return false;\r\n }\r\n /**\r\n * Return the current relative step size, i.e., the larger absolute component of `dX / (1 + |X_n|)`\r\n */\r\n public currentStepSize(): number {\r\n return Geometry.maxAbsXY(\r\n this._currentStep.x / (1.0 + Math.abs(this._currentUV.x)),\r\n this._currentStep.y / (1.0 + Math.abs(this._currentUV.y)),\r\n );\r\n }\r\n}\r\n/**\r\n * SimpleNewton has static methods for newton methods with evaluated functions presented as immediate arguments\r\n * (not function object).\r\n * @internal\r\n */\r\nexport class SimpleNewton {\r\n /**\r\n * Run a one-dimensional newton iteration with separate functions for function and derivative.\r\n * * Completion is at 2 (TWO) successive passes at `absoluteTolerance + relTol * abs(x)`, where relTol is\r\n * chosen internally.\r\n * * `absoluteTolerance` is usually aggressively tight -- should come into play only for x near zero.\r\n * * The `relTol` is fluffy (for instance around 1e-11) but in properly converging cases the extra pass after\r\n * first success normally moves to full machine precision.\r\n * * This is an open-loop newton -- it just runs, and returns undefined if anything bad happens.\r\n */\r\n public static runNewton1D(\r\n x: number,\r\n func: (x: number) => number | undefined,\r\n derivative: (x: number) => number | undefined,\r\n absoluteTolerance: number = Geometry.smallFloatingPoint,\r\n ): number | undefined {\r\n let numConverged = 0;\r\n let tolerance: number;\r\n const relTol = 1.0e-11;\r\n for (let iteration = 0; iteration < 20; iteration++) {\r\n const f = func(x);\r\n const df = derivative(x);\r\n if (f !== undefined && df !== undefined) {\r\n const dx = Geometry.conditionalDivideCoordinate(f, df);\r\n if (dx === undefined)\r\n return undefined;\r\n x -= dx;\r\n // console.log(x); // print approximations for debug\r\n tolerance = absoluteTolerance + Math.abs(x) * relTol;\r\n if (Math.abs(dx) < tolerance) {\r\n numConverged++;\r\n if (dx === 0.0 || numConverged > 1) // bypass convergence count on true 0 dx\r\n return x;\r\n } else {\r\n numConverged = 0;\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Class to evaluate XY intersection between 2 curve primitives using the Newton method.\r\n * @internal\r\n */\r\nexport class CurveCurveIntersectionXYRRToRRD extends NewtonEvaluatorRRtoRRD {\r\n private _curveP: CurvePrimitive;\r\n private _curveQ: CurvePrimitive;\r\n private _rayP: Ray3d;\r\n private _rayQ: Ray3d;\r\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\r\n super();\r\n this._curveP = curveP;\r\n this._curveQ = curveQ;\r\n this._rayP = Ray3d.createZero();\r\n this._rayQ = Ray3d.createZero();\r\n }\r\n public evaluate(fractionU: number, fractionV: number): boolean {\r\n /**\r\n * To find an intersection between xy-curves P(u) = (x_p(u), y_p(u)) and Q(v) = (x_q(v), y_q(v)) we should solve\r\n * F(u,v) := P(u) - Q(v) = (0,0)\r\n * Using the Newton method we can find the fractions u and v at the intersection via\r\n * [u_{n+1}] [u_n] [x_p'(u_n) -x_q'(v_n)] [x_p(u_n) - x_q(v_n)]\r\n * = - Inv( )\r\n * [v_{n+1}] [v_n] [y_p'(u_n) -y_q'(v_n)] [y_p(u_n) - y_q(v_n)]\r\n * Note that this is xy intersection so we can ignore z.\r\n */\r\n this._curveP.fractionToPointAndDerivative(fractionU, this._rayP);\r\n this._curveQ.fractionToPointAndDerivative(fractionV, this._rayQ);\r\n this.currentF.setOriginAndVectorsXYZ(\r\n this._rayP.origin.x - this._rayQ.origin.x, this._rayP.origin.y - this._rayQ.origin.y, 0.0,\r\n this._rayP.direction.x, this._rayP.direction.y, 0.0,\r\n -this._rayQ.direction.x, -this._rayQ.direction.y, 0.0,\r\n );\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Class to evaluate XY close approach between a curve primitive and a point using the Newton method.\r\n * @internal\r\n */\r\nexport class CurvePointCloseApproachXYRtoRD extends NewtonEvaluatorRtoRD {\r\n private _curveP: CurvePrimitive;\r\n private _pointQ: Point3d;\r\n private _planeP: Plane3dByOriginAndVectors;\r\n constructor(curveP: CurvePrimitive, pointQ: Point3d) {\r\n super();\r\n this._curveP = curveP;\r\n this._pointQ = pointQ;\r\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\r\n }\r\n public evaluate(fractionU: number): boolean {\r\n /**\r\n * To find a close approach between xy-curve P(u) and xy-point q we should solve\r\n * F(u) := P'(u).(P(u) - q) = 0\r\n * For a solution u, the segment S(u) := P(u) - q is perpendicular to the curve tangent P'(u), which means S(u) is a close approach.\r\n * Using the Newton method we can find the fractions u at the close approach location via\r\n * u_{n+1} = u_n + F(u_n)/F'(u_n) = u_n + [ P'(u_n).S(u_n) ]/[ P''(u_n).S(u_n) + P'(u_n).P'(u_n) ]\r\n * Note that this is xy close approach so we can ignore z.\r\n */\r\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\r\n const segX = this._planeP.origin.x - this._pointQ.x;\r\n const segY = this._planeP.origin.y - this._pointQ.y;\r\n const pDerivX = this._planeP.vectorU.x;\r\n const pDerivY = this._planeP.vectorU.y;\r\n const p2DerivX = this._planeP.vectorV.x;\r\n const p2DerivY = this._planeP.vectorV.y;\r\n this.currentF = pDerivX * segX + pDerivY * segY;\r\n this.currentdFdX = p2DerivX * segX + pDerivX * pDerivX + p2DerivY * segY + pDerivY * pDerivY;\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Class to evaluate XY close approach between 2 curve primitives using the Newton method.\r\n * @internal\r\n */\r\nexport class CurveCurveCloseApproachXYRRtoRRD extends NewtonEvaluatorRRtoRRD {\r\n private _curveP: CurvePrimitive;\r\n private _curveQ: CurvePrimitive;\r\n private _planeP: Plane3dByOriginAndVectors;\r\n private _planeQ: Plane3dByOriginAndVectors;\r\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\r\n super();\r\n this._curveP = curveP;\r\n this._curveQ = curveQ;\r\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\r\n this._planeQ = Plane3dByOriginAndVectors.createXYPlane();\r\n }\r\n public evaluate(fractionU: number, fractionV: number): boolean {\r\n /**\r\n * To find a close approach between xy-curves P(u) and Q(v) we should solve\r\n * F(u,v) := (P'(u).(P(u) - Q(v)), Q'(v).(P(u) - Q(v))) = (0,0)\r\n * For a solution (u,v), the segment S(u,v) := P(u) - Q(v) is perpendicular to the curve tangents P'(u) and Q'(v),\r\n * which means S(u,v) is a close approach.\r\n * Using the Newton method we can find the fractions u and v at the close approach location via\r\n * [u_{n+1}] [u_n] [P''(u_n).S(u_n,v_n) + P'(u_n).P'(u_n) -P'(u_n).Q'(v_n)] [P'(u_n).S(u_n,v_n)]\r\n * = - Inv( )\r\n * [v_{n+1}] [v_n] [Q'(v_n).P'(u_n) Q''(v_n).S(u_n,v_n) - Q'(v_n).Q'(v_n)] [Q'(v_n).S(u_n,v_n)]\r\n * Note that this is xy close approach so we can ignore z.\r\n */\r\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\r\n this._curveQ.fractionToPointAnd2Derivatives(fractionV, this._planeQ);\r\n const segX = this._planeP.origin.x - this._planeQ.origin.x;\r\n const segY = this._planeP.origin.y - this._planeQ.origin.y;\r\n const pDerivX = this._planeP.vectorU.x;\r\n const pDerivY = this._planeP.vectorU.y;\r\n const qDerivX = this._planeQ.vectorU.x;\r\n const qDerivY = this._planeQ.vectorU.y;\r\n const p2DerivX = this._planeP.vectorV.x;\r\n const p2DerivY = this._planeP.vectorV.y;\r\n const q2DerivX = this._planeQ.vectorV.x;\r\n const q2DerivY = this._planeQ.vectorV.y;\r\n this.currentF.setOriginAndVectorsXYZ(\r\n pDerivX * segX + pDerivY * segY,\r\n qDerivX * segX + qDerivY * segY,\r\n 0.0,\r\n p2DerivX * segX + p2DerivY * segY + pDerivX * pDerivX + pDerivY * pDerivY,\r\n qDerivX * pDerivX + qDerivY * pDerivY,\r\n 0.0,\r\n -(pDerivX * qDerivX + pDerivY * qDerivY),\r\n q2DerivX * segX + q2DerivY * segY - qDerivX * qDerivX - qDerivY * qDerivY,\r\n 0.0,\r\n );\r\n return true;\r\n }\r\n}\r\n"]}
|