@itwin/core-geometry 4.2.0-dev.3 → 4.2.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 +59 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts +4 -3
- package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.js +1 -1
- package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/cjs/clipping/BooleanClipNode.d.ts +4 -3
- package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
- package/lib/cjs/clipping/ClipPlane.d.ts +12 -8
- package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPlane.js +5 -3
- package/lib/cjs/clipping/ClipPlane.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +20 -8
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +77 -2
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/ClipVector.d.ts +6 -5
- package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipVector.js +1 -1
- package/lib/cjs/clipping/ClipVector.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +6 -4
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +3 -2
- package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +4 -3
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js +2 -2
- package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/cjs/core-geometry.d.ts +1 -3
- package/lib/cjs/core-geometry.d.ts.map +1 -1
- package/lib/cjs/core-geometry.js +1 -3
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +4 -4
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CoordinateXYZ.d.ts +15 -15
- package/lib/cjs/curve/CoordinateXYZ.d.ts.map +1 -1
- package/lib/cjs/curve/CoordinateXYZ.js +15 -15
- package/lib/cjs/curve/CoordinateXYZ.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +4 -17
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +3 -22
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveCurve.d.ts +41 -26
- package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurve.js +73 -40
- package/lib/cjs/curve/CurveCurve.js.map +1 -1
- package/lib/cjs/curve/CurveFactory.d.ts +1 -1
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +12 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +13 -2
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurveOps.d.ts +1 -1
- package/lib/cjs/curve/CurveOps.js.map +1 -1
- package/lib/cjs/curve/CurveProcessor.d.ts +1 -1
- package/lib/cjs/curve/CurveProcessor.js.map +1 -1
- package/lib/cjs/curve/CurveTypes.d.ts +19 -0
- package/lib/cjs/curve/CurveTypes.d.ts.map +1 -0
- package/lib/cjs/curve/{CurveChain.js → CurveTypes.js} +1 -1
- package/lib/cjs/curve/CurveTypes.js.map +1 -0
- package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts +1 -1
- package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/cjs/curve/ParityRegion.d.ts +1 -1
- package/lib/cjs/curve/ParityRegion.js.map +1 -1
- package/lib/cjs/curve/Path.d.ts +1 -1
- package/lib/cjs/curve/Path.d.ts.map +1 -1
- package/lib/cjs/curve/Path.js +1 -1
- package/lib/cjs/curve/Path.js.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +2 -2
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/cjs/curve/Query/CurveSplitContext.d.ts +1 -1
- package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
- package/lib/cjs/curve/Query/CylindricalRange.d.ts +1 -1
- package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
- package/lib/cjs/curve/Query/InOutTests.d.ts +1 -1
- package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountChain.d.ts +1 -1
- package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +16 -2
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +18 -1
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/UnionRegion.d.ts +1 -1
- package/lib/cjs/curve/UnionRegion.js +1 -1
- package/lib/cjs/curve/UnionRegion.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +225 -0
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
- package/lib/cjs/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +249 -189
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
- package/lib/{esm/curve → cjs/curve/internalContexts}/CurveCurveIntersectXY.d.ts +14 -27
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
- package/lib/cjs/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +31 -42
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
- package/lib/cjs/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +11 -12
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
- package/lib/cjs/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +12 -14
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +1 -0
- package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/BarycentricTriangle.js +1 -0
- package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.d.ts +57 -36
- package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.js +99 -74
- package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +0 -8
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +0 -16
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +4 -4
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +12 -0
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +0 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +0 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.d.ts +3 -1
- package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +4 -3
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/geometry3d/ReusableObjectCache.d.ts +2 -1
- package/lib/cjs/geometry3d/ReusableObjectCache.d.ts.map +1 -1
- package/lib/cjs/geometry3d/ReusableObjectCache.js +1 -1
- package/lib/cjs/geometry3d/ReusableObjectCache.js.map +1 -1
- package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -1
- package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/cjs/numerics/Polynomials.d.ts +2 -2
- package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/Polynomials.js +2 -2
- package/lib/cjs/numerics/Polynomials.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/solid/LinearSweep.d.ts +1 -1
- package/lib/cjs/solid/LinearSweep.js.map +1 -1
- package/lib/cjs/solid/RotationalSweep.d.ts +1 -1
- package/lib/cjs/solid/RotationalSweep.js.map +1 -1
- package/lib/cjs/solid/RuledSweep.d.ts +1 -1
- package/lib/cjs/solid/RuledSweep.js.map +1 -1
- package/lib/cjs/solid/SweepContour.d.ts +1 -1
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.d.ts +4 -3
- package/lib/esm/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.js +1 -1
- package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.d.ts +4 -3
- package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
- package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
- package/lib/esm/clipping/ClipPlane.d.ts +12 -8
- package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPlane.js +5 -3
- package/lib/esm/clipping/ClipPlane.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +20 -8
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +77 -2
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/ClipVector.d.ts +6 -5
- package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
- package/lib/esm/clipping/ClipVector.js +1 -1
- package/lib/esm/clipping/ClipVector.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +6 -4
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +3 -2
- package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +4 -3
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js +2 -2
- package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
- package/lib/esm/core-geometry.d.ts +1 -3
- package/lib/esm/core-geometry.d.ts.map +1 -1
- package/lib/esm/core-geometry.js +1 -3
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +4 -4
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CoordinateXYZ.d.ts +15 -15
- package/lib/esm/curve/CoordinateXYZ.d.ts.map +1 -1
- package/lib/esm/curve/CoordinateXYZ.js +15 -15
- package/lib/esm/curve/CoordinateXYZ.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +4 -17
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +2 -20
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveCurve.d.ts +41 -26
- package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurve.js +73 -40
- package/lib/esm/curve/CurveCurve.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +1 -1
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +12 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +11 -1
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurveOps.d.ts +1 -1
- package/lib/esm/curve/CurveOps.js.map +1 -1
- package/lib/esm/curve/CurveProcessor.d.ts +1 -1
- package/lib/esm/curve/CurveProcessor.js.map +1 -1
- package/lib/esm/curve/CurveTypes.d.ts +19 -0
- package/lib/esm/curve/CurveTypes.d.ts.map +1 -0
- package/lib/esm/curve/{CurveChain.js → CurveTypes.js} +1 -1
- package/lib/esm/curve/CurveTypes.js.map +1 -0
- package/lib/esm/curve/CurveWireMomentsXYZ.d.ts +1 -1
- package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/esm/curve/ParityRegion.d.ts +1 -1
- package/lib/esm/curve/ParityRegion.js.map +1 -1
- package/lib/esm/curve/Path.d.ts +1 -1
- package/lib/esm/curve/Path.d.ts.map +1 -1
- package/lib/esm/curve/Path.js +1 -1
- package/lib/esm/curve/Path.js.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/esm/curve/Query/CurveSplitContext.d.ts +1 -1
- package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
- package/lib/esm/curve/Query/CylindricalRange.d.ts +1 -1
- package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
- package/lib/esm/curve/Query/InOutTests.d.ts +1 -1
- package/lib/esm/curve/Query/InOutTests.js.map +1 -1
- package/lib/esm/curve/Query/StrokeCountChain.d.ts +1 -1
- package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +16 -2
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +16 -0
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/UnionRegion.d.ts +1 -1
- package/lib/esm/curve/UnionRegion.js +1 -1
- package/lib/esm/curve/UnionRegion.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +225 -0
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
- package/lib/esm/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +249 -189
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
- package/lib/{cjs/curve → esm/curve/internalContexts}/CurveCurveIntersectXY.d.ts +14 -27
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
- package/lib/esm/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +30 -40
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
- package/lib/esm/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +11 -12
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
- package/lib/esm/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +11 -13
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/esm/geometry3d/BarycentricTriangle.d.ts +1 -0
- package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
- package/lib/esm/geometry3d/BarycentricTriangle.js +1 -0
- package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.d.ts +57 -36
- package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.js +99 -74
- package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +0 -8
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +0 -16
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +4 -4
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +12 -0
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +0 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +0 -1
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.d.ts +3 -1
- package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +4 -3
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/geometry3d/ReusableObjectCache.d.ts +2 -1
- package/lib/esm/geometry3d/ReusableObjectCache.d.ts.map +1 -1
- package/lib/esm/geometry3d/ReusableObjectCache.js +1 -1
- package/lib/esm/geometry3d/ReusableObjectCache.js.map +1 -1
- package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -1
- package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/esm/numerics/Polynomials.d.ts +2 -2
- package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
- package/lib/esm/numerics/Polynomials.js +2 -2
- package/lib/esm/numerics/Polynomials.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/solid/LinearSweep.d.ts +1 -1
- package/lib/esm/solid/LinearSweep.js.map +1 -1
- package/lib/esm/solid/RotationalSweep.d.ts +1 -1
- package/lib/esm/solid/RotationalSweep.js.map +1 -1
- package/lib/esm/solid/RuledSweep.d.ts +1 -1
- package/lib/esm/solid/RuledSweep.js.map +1 -1
- package/lib/esm/solid/SweepContour.d.ts +1 -1
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/package.json +3 -3
- package/lib/cjs/curve/CurveChain.d.ts +0 -17
- package/lib/cjs/curve/CurveChain.d.ts.map +0 -1
- package/lib/cjs/curve/CurveChain.js.map +0 -1
- package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts +0 -164
- package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
- package/lib/cjs/curve/CurveCurveCloseApproachXY.js.map +0 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +0 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.js.map +0 -1
- package/lib/cjs/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
- package/lib/cjs/curve/CurveCurveIntersectXYZ.js.map +0 -1
- package/lib/esm/curve/CurveChain.d.ts +0 -17
- package/lib/esm/curve/CurveChain.d.ts.map +0 -1
- package/lib/esm/curve/CurveChain.js.map +0 -1
- package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts +0 -164
- package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
- package/lib/esm/curve/CurveCurveCloseApproachXY.js.map +0 -1
- package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +0 -1
- package/lib/esm/curve/CurveCurveIntersectXY.js.map +0 -1
- package/lib/esm/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
- package/lib/esm/curve/CurveCurveIntersectXYZ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ray3d.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAA+C,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAa,eAAe,EAAY,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGpC;;;;;;GAMG;AACH,qBAAa,KAAM,YAAW,eAAe;IAC3C,qBAAqB;IACd,MAAM,EAAE,OAAO,CAAC;IACvB,0EAA0E;IACnE,SAAS,EAAE,QAAQ,CAAC;IAC3B,0BAA0B;IACnB,CAAC,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;IACvC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAW;
|
|
1
|
+
{"version":3,"file":"Ray3d.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAA+C,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAa,eAAe,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AClH,OAAO,GAAG,SAAS;IAiFtB;;;OAGG;IACI,iCAAiC,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAO1F;;;;;;;;;;;;OAYG;WACW,yBAAyB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,uBAAuB;IAgC1F;;;;;;;;OAQG;WACW,0BAA0B,CACtC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAC/E,KAAK;CAcT"}
|
|
@@ -230,9 +230,9 @@ class Ray3d {
|
|
|
230
230
|
* Return a transform for rigid axes at ray origin with z in ray direction.
|
|
231
231
|
* * If the direction vector is zero, axes default to identity (from [[Matrix3d.createRigidHeadsUp]])
|
|
232
232
|
*/
|
|
233
|
-
toRigidZFrame() {
|
|
234
|
-
const axes = Matrix3d_1.Matrix3d.createRigidHeadsUp(this.direction, Geometry_1.AxisOrder.ZXY);
|
|
235
|
-
return Transform_1.Transform.createOriginAndMatrix(this.origin, axes);
|
|
233
|
+
toRigidZFrame(result) {
|
|
234
|
+
const axes = Ray3d._workMatrix = Matrix3d_1.Matrix3d.createRigidHeadsUp(this.direction, Geometry_1.AxisOrder.ZXY, Ray3d._workMatrix);
|
|
235
|
+
return Transform_1.Transform.createOriginAndMatrix(this.origin, axes, result);
|
|
236
236
|
}
|
|
237
237
|
/** Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d. */
|
|
238
238
|
setFromJSON(json) {
|
|
@@ -344,6 +344,7 @@ class Ray3d {
|
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
346
346
|
* Compute the intersection of the ray with a triangle.
|
|
347
|
+
* * This method is faster than `BarycentricTriangle.intersectRay3d`.
|
|
347
348
|
* @param vertex0 first vertex of the triangle
|
|
348
349
|
* @param vertex1 second vertex of the triangle
|
|
349
350
|
* @param vertex2 third vertex of the triangle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sEAAoH;AACpH,0CAAmE;AACnE,yDAAsD;AACtD,yCAAsC;AAEtC,uDAA6C;AAC7C,uDAAsD;AACtD,mCAA2C;AAC3C,2CAAwC;AAGxC,qBAAqB;AACrB;;;;;;GAMG;AACH,MAAa,KAAK;IAYhB,oCAAoC;IACpC,YAAoB,MAAe,EAAE,SAAmB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACrB,CAAC;IACO,MAAM,CAAC,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QACrF,OAAO,IAAI,KAAK,CAAC,yBAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,0BAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,kCAAkC;IAC3B,MAAM,CAAC,WAAW;QACvB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,kCAAkC;IAC3B,MAAM,CAAC,WAAW;QACvB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,kCAAkC;IAC3B,MAAM,CAAC,WAAW;QACvB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAA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AAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;SACnE;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlhBD,sBAkhBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n// cspell:word Cramer\r\n/**\r\n * A Ray3d contains\r\n * * an `origin` point.\r\n * * a `direction` vector (The vector is not required to be normalized).\r\n * * an optional weight (number).\r\n * @public\r\n */\r\nexport class Ray3d implements BeJSONFunctions {\r\n /** The ray origin */\r\n public origin: Point3d;\r\n /** The ray direction. This is commonly (but not always) a unit vector. */\r\n public direction: Vector3d;\r\n /** Numeric annotation. */\r\n public a?: number; // optional (e.g. weight)\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workVector2?: Vector3d;\r\n private static _workVector3?: Vector3d;\r\n private static _workVector4?: Vector3d;\r\n // constructor (captures references)\r\n private constructor(origin: Point3d, direction: Vector3d) {\r\n this.origin = origin;\r\n this.direction = direction;\r\n this.a = undefined;\r\n }\r\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\r\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\r\n }\r\n /** Create a ray on the x axis. */\r\n public static createXAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 1, 0, 0);\r\n }\r\n /** Create a ray on the y axis. */\r\n public static createYAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 1, 0);\r\n }\r\n /** Create a ray on the z axis. */\r\n public static createZAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 0, 1);\r\n }\r\n /** Create a ray with all zeros. */\r\n public static createZero(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setZero();\r\n result.direction.setZero();\r\n return result;\r\n }\r\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\r\n }\r\n /**\r\n * Test for nearly equal Ray3d objects.\r\n * * This tests for near equality of origin and direction -- i.e. member-by-member comparison.\r\n * * Use [[isAlmostEqualPointSet]] to allow origins to be anywhere along the common ray and to have to allow the\r\n * directions to be scaled or opposing.\r\n */\r\n public isAlmostEqual(other: Ray3d): boolean {\r\n return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);\r\n }\r\n /**\r\n * Return the dot product of the ray's direction vector with a vector from the ray origin\r\n * to the `spacePoint`.\r\n * * If the instance is the unit normal of a plane, then this method returns the (signed) altitude\r\n * of `spacePoint` with respect to the plane.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane\r\n */\r\n public dotProductToPoint(spacePoint: Point3d): number {\r\n return this.direction.dotProductStartEnd(this.origin, spacePoint);\r\n }\r\n /** Return the fractional coordinate (along the direction vector) of the `spacePoint` projected to the ray. */\r\n public pointToFraction(spacePoint: Point3d): number {\r\n return Geometry.safeDivideFraction(\r\n this.dotProductToPoint(spacePoint),\r\n this.direction.magnitudeSquared(),\r\n 0,\r\n );\r\n }\r\n /** Return the `spacePoint` projected onto the ray. */\r\n public projectPointToRay(spacePoint: Point3d): Point3d {\r\n /**\r\n * To project a point to the ray, we can create a vector called \"v\" from ray origin to the spacePoint and project\r\n * that vector to the ray direction vector \"r\". The projection is \"((v.r)/||r||^2) r\" where \"v.r\" is the dot\r\n * product. Note that pointToFraction returns \"(v.r)/||r||^2\".\r\n * Note: If r is the normal of a plane, then projection length \"(v.r)/||r||\" is the signed altitude of the\r\n * spacePoint with respect to the plane.\r\n */\r\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\r\n }\r\n /**\r\n * Test for nearly equal rays, allowing origin float and direction scaling.\r\n * * Use [[isAlmostEqual]] to require member-by-member comparison.\r\n */\r\n public isAlmostEqualPointSet(other: Ray3d): boolean {\r\n /**\r\n * This function tests two rays to determine if they define the same infinite lines.\r\n * So the origins can be different as long as they are on the infinite line (they can\r\n * \"float\") but the directions must be parallel or antiparallel.\r\n */\r\n if (!this.direction.isParallelTo(other.direction, true))\r\n return false;\r\n /**\r\n * In exact math, we consider a ray to have an infinite line as direction (not a finite vector).\r\n * Therefore, in exact math it is not possible for one origin to be on the other ray but not vice\r\n * versa. However, we test both ways because first check may pass due to round-off errors.\r\n */\r\n let workPoint = this.projectPointToRay(other.origin);\r\n if (!other.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n workPoint = other.projectPointToRay(this.origin);\r\n if (!this.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n return true;\r\n }\r\n /** Create a ray from origin and direction. */\r\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(origin, direction);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), direction.clone());\r\n }\r\n /**\r\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian\r\n * coordinates and derivatives.\r\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\r\n * @param weightedDerivative `[x,y,z,w]` derivatives\r\n * @param result\r\n */\r\n public static createWeightedDerivative(\r\n weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d,\r\n ): Ray3d | undefined {\r\n const w = weightedPoint[3];\r\n const dw = weightedDerivative[3];\r\n const x = weightedPoint[0];\r\n const y = weightedPoint[1];\r\n const z = weightedPoint[2];\r\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\r\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\r\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\r\n if (Geometry.isSmallMetricDistance(w))\r\n return undefined;\r\n const divW = 1.0 / w;\r\n const divWW = divW * divW;\r\n return Ray3d.createXYZUVW(\r\n x * divW, y * divW, z * divW,\r\n dx * divWW, dy * divWW, dz * divWW,\r\n result,\r\n );\r\n }\r\n /** Create from coordinates of the origin and direction. */\r\n public static createXYZUVW(\r\n originX: number, originY: number, originZ: number,\r\n directionX: number, directionY: number, directionZ: number,\r\n result?: Ray3d,\r\n ): Ray3d {\r\n if (result) {\r\n result.getOriginRef().set(originX, originY, originZ);\r\n result.getDirectionRef().set(directionX, directionY, directionZ);\r\n return result;\r\n }\r\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\r\n }\r\n /** Capture origin and direction in a new Ray3d. */\r\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\r\n return new Ray3d(origin, direction);\r\n }\r\n /** Create from (clones of) origin, direction, and numeric weight. */\r\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setFrom(direction);\r\n result.a = a;\r\n return result;\r\n }\r\n result = new Ray3d(origin.clone(), direction.clone());\r\n result.a = a;\r\n return result;\r\n }\r\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\r\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setStartEnd(origin, target);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\r\n }\r\n /** Return a reference to the ray's origin. */\r\n public getOriginRef(): Point3d {\r\n return this.origin;\r\n }\r\n /** Return a reference to the ray's direction vector. */\r\n public getDirectionRef(): Vector3d {\r\n return this.direction;\r\n }\r\n /** Copy coordinates from origin and direction. */\r\n public set(origin: Point3d, direction: Vector3d): void {\r\n this.origin.setFrom(origin);\r\n this.direction.setFrom(direction);\r\n }\r\n /** Clone the ray. */\r\n public clone(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(this.origin.clone(), this.direction.clone());\r\n return result;\r\n }\r\n return new Ray3d(this.origin.clone(), this.direction.clone());\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: Ray3d): Ray3d {\r\n return Ray3d.create(\r\n transform.multiplyPoint3d(this.origin, result?.origin),\r\n transform.multiplyVector(this.direction, result?.direction),\r\n result,\r\n );\r\n }\r\n /** Create a clone and return the inverse transform of the clone. */\r\n public cloneInverseTransformed(transform: Transform, result?: Ray3d): Ray3d | undefined {\r\n if (!transform.computeCachedInverse(true))\r\n return undefined;\r\n return Ray3d.create(\r\n transform.multiplyInversePoint3d(this.origin, result?.origin)!,\r\n transform.matrix.multiplyInverseXYZAsVector3d(\r\n this.direction.x, this.direction.y, this.direction.z, result?.direction,\r\n )!,\r\n result,\r\n );\r\n }\r\n /** Apply a transform in place. */\r\n public transformInPlace(transform: Transform) {\r\n transform.multiplyPoint3d(this.origin, this.origin);\r\n transform.multiplyVector(this.direction, this.direction);\r\n }\r\n /** Copy data from another ray. */\r\n public setFrom(source: Ray3d): void {\r\n this.set(source.origin, source.direction);\r\n }\r\n /**\r\n * Return a point at fractional position along the ray.\r\n * * fraction 0 is the ray origin.\r\n * * fraction 1 is at the end of the direction vector when placed at the origin.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.origin.plusScaled(this.direction, fraction, result);\r\n }\r\n /**\r\n * Return a transform for rigid axes at ray origin with z in ray direction.\r\n * * If the direction vector is zero, axes default to identity (from [[Matrix3d.createRigidHeadsUp]])\r\n */\r\n public toRigidZFrame(): Transform | undefined {\r\n const axes = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY);\r\n return Transform.createOriginAndMatrix(this.origin, axes);\r\n }\r\n /** Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d. */\r\n public setFromJSON(json?: any) {\r\n if (!json) {\r\n this.origin.set(0, 0, 0);\r\n this.direction.set(0, 0, 1);\r\n return;\r\n }\r\n this.origin.setFromJSON(json.origin);\r\n this.direction.setFromJSON(json.direction);\r\n }\r\n /**\r\n * Construct a JSON object from this Ray3d.\r\n * @return {*} [origin,normal]\r\n */\r\n public toJSON(): any {\r\n return { origin: this.origin.toJSON(), direction: this.direction.toJSON() };\r\n }\r\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\r\n public static fromJSON(json?: any) {\r\n const result = Ray3d.createXAxis();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /**\r\n * Try to scale the direction vector to a given `magnitude`.\r\n * * Returns `false` if the ray direction is a zero vector.\r\n */\r\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\r\n if (this.direction.tryNormalizeInPlace()) {\r\n this.direction.scaleInPlace(magnitude);\r\n return true;\r\n }\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * Normalize the ray direction in place.\r\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\r\n * * Save the parameter `a` as the optional `a` member of the ray.\r\n * * Normalize the ray's direction vector.\r\n * * If parameter `a` is nearly zero,\r\n * * Set the `a` member to zero.\r\n * * Set the ray's direction vector to zero.\r\n * @param a value to be saved (e.g,. area).\r\n * @returns `true` if `a` is nonzero and normalization was successful. Otherwise, return `false`.\r\n */\r\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\r\n const tolerance = Geometry.smallMetricDistanceSquared;\r\n this.a = a;\r\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\r\n return true;\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /** Return distance from the ray to point in space. */\r\n public distance(spacePoint: Point3d): number {\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.dotProductToPoint(spacePoint);\r\n const aa = Geometry.inverseMetricDistanceSquared(uu);\r\n if (aa)\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\r\n else\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\r\n }\r\n /**\r\n * Return the intersection parameter of the line defined by the ray with a `plane`.\r\n * * Stores the point of intersection in the `result` point (if passed as a parameter) and returns the parameter\r\n * along the ray where the intersection occurs. If we call the parameter 'f' then the point of intersection would\r\n * be `ray.origin + f * ray.direction`. Therefore:\r\n * * if ray intersects the plane at its origin, the function returns f = 0.\r\n * * if intersects at `ray.origin + ray.direction`, the function returns f = 1.\r\n * * if intersects behind the ray origin, the function returns f < 0.\r\n * * if intersects after `ray.origin + ray.direction`, the function returns f > 1.\r\n * * Returns `undefined` if the ray and plane are parallel or coplanar.\r\n */\r\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\r\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\r\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\r\n const nDotN = this.direction.magnitudeSquared();\r\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\r\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\r\n if (undefined === division)\r\n return undefined;\r\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\r\n if (undefined === division1)\r\n return undefined;\r\n if (result) {\r\n this.origin.plusScaled(this.direction, division, result);\r\n }\r\n return division;\r\n }\r\n /**\r\n * Find the intersection of the line defined by the ray with a Range3d.\r\n * * Return the range of parameters (on the ray) which are \"inside\" the range.\r\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.isNull`.\r\n */\r\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\r\n if (range.isNull)\r\n return Range1d.createNull(result);\r\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\r\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\r\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\r\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z)\r\n )\r\n return interval;\r\n return interval;\r\n }\r\n /**\r\n * Compute the intersection of the ray with a triangle.\r\n * @param vertex0 first vertex of the triangle\r\n * @param vertex1 second vertex of the triangle\r\n * @param vertex2 third vertex of the triangle\r\n * @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line\r\n * intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)\r\n * @param parameterTol optional tolerance used to snap barycentric coordinates of the intersection point to\r\n * a triangle edge or vertex (if tolerance is not provided, Geometry.smallFloatingPoint is used)\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.\r\n */\r\n public intersectionWithTriangle(\r\n vertex0: Point3d, vertex1: Point3d, vertex2: Point3d, distanceTol?: number, parameterTol?: number, result?: Point3d,\r\n ): Point3d | undefined {\r\n /**\r\n * Suppose ray is shown by \"rayOrigin + t*rayVector\" and barycentric coordinate of point\r\n * P = w*v0 + u*v1 + v*v2 = (1-u-v)*v0 + u*v1 + v*v2 = v0 + u*(v1-v0) + v*(v2-v0)\r\n *\r\n * Then if ray intersects triangle at a point we have\r\n * v0 + u*(v1-v0) + v*(v2-v0) = rayOrigin + t*rayVector\r\n * or\r\n * -t*rayVector + u*(v1-v0) + v*(v2-v0) = rayOrigin - v0\r\n *\r\n * This equation can be reformulated as the following linear system:\r\n *\r\n * [ | | | ] [t] [ | ]\r\n * [-rayVector v1-v0 v2-v0] [u] = [rayOrigin - v0]\r\n * [ | | | ] [v] [ | ]\r\n *\r\n * Then to find t, u, and v use Cramer's Rule and also the fact that if matrix A = [c1,c2,c3], then\r\n * det(A) = c1.(c2 x c3) which leads to\r\n *\r\n * t = [(rayOrigin - v0).((v1-v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * u = [-rayVector.((rayOrigin - v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * v = [-rayVector.((v1-v0) x (rayOrigin - v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n *\r\n * Now note that swapping any 2 vectors c_i and c_j in formula c1.(c2 x c3) negates it. For example:\r\n * c1.(c2 x c3) = -c3.(c2 x c1) = c2.(c3 x c1)\r\n *\r\n * This leads to the final formulas used in the following code:\r\n * t = [(v2-v0).((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * u = [(rayOrigin - v0).(rayVector x (v2-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * v = [-rayVector.((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n *\r\n * Note that we should verify 0 <= u,v,w <= 1. To do so we only need to check 0 <= u <= 1, 0 <= v, and u+v <= 1.\r\n * That's because w = 1-(u+v) and if we have those 4 checks, it's guaranteed that v <= 1 and 0 <= u+v and so\r\n * 0 <= w <= 1.\r\n *\r\n * More info be found at\r\n * https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm\r\n */\r\n if (distanceTol === undefined || distanceTol < 0) // we explicitly allow zero tolerance\r\n distanceTol = Geometry.smallMetricDistance;\r\n if (parameterTol === undefined || parameterTol < 0) // we explicitly allow zero tolerance\r\n parameterTol = Geometry.smallFloatingPoint;\r\n const edge1 = Ray3d._workVector0 = Vector3d.createStartEnd(vertex0, vertex1, Ray3d._workVector0);\r\n const edge2 = Ray3d._workVector1 = Vector3d.createStartEnd(vertex0, vertex2, Ray3d._workVector1);\r\n const h = Ray3d._workVector2 = this.direction.crossProduct(edge2, Ray3d._workVector2);\r\n const a = edge1.dotProduct(h);\r\n if (a >= -distanceTol && a <= distanceTol)\r\n return undefined; // ray is parallel to the triangle (includes coplanar case)\r\n const f = 1.0 / a;\r\n const s = Ray3d._workVector3 = Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);\r\n let u = f * s.dotProduct(h);\r\n if (u < 0.0) {\r\n if (u > -parameterTol)\r\n u = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u > 1.0) {\r\n if (u < 1.0 + parameterTol)\r\n u = 1.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);\r\n let v = f * this.direction.dotProduct(q);\r\n if (v < 0.0) {\r\n if (v > -parameterTol)\r\n v = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u + v > 1.0) {\r\n if (u + v < 1.0 + parameterTol)\r\n v = 1.0 - u;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n // at this stage, we know the line (parameterized as the ray) intersects the triangle\r\n const t = f * edge2.dotProduct(q);\r\n if (t <= distanceTol) // line intersection but not ray intersection\r\n return undefined;\r\n return this.origin.plusScaled(this.direction, t, result); // ray intersection\r\n }\r\n /**\r\n * Return the shortest vector `v` to `targetPoint` from the line defined by this ray.\r\n * * If the projection of `targetPoint` onto the line defined by this ray is q, then `v = targetPoint - q`.\r\n */\r\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\r\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\r\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\r\n return vectorV.plusScaled(this.direction, -fraction, result);\r\n }\r\n /**\r\n * Determine if two rays intersect, or are fully overlapped, or parallel but not coincident, or skew.\r\n * * Return a CurveLocationDetailPair which contains fraction and point on each ray and has\r\n * annotation (in member `approachType`) indicating one of these relationships:\r\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated\r\n * in detailA and detailB\r\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach.\r\n * The rays are skew in space.\r\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The\r\n * fractions and points are a representative single common point.\r\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are\r\n * at the minimum distance\r\n */\r\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\r\n const intersectionFractions = Vector2d.create();\r\n let fractionA, fractionB;\r\n let pointA, pointB;\r\n let pairType;\r\n if (\r\n SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\r\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\r\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z,\r\n intersectionFractions,\r\n )\r\n ) {\r\n fractionA = intersectionFractions.x;\r\n fractionB = intersectionFractions.y;\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\r\n } else {\r\n fractionB = 0.0;\r\n fractionA = rayA.pointToFraction(rayB.origin);\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\r\n }\r\n const pair = CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\r\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\r\n pair.approachType = pairType;\r\n return pair;\r\n }\r\n /**\r\n * Return a ray with `ray.origin` interpolated between `pt1` and `pt2` at the given `fraction`\r\n * and `ray.direction` set to the vector from `pt1` to `pt2` multiplied by the given `tangentScale`.\r\n * @param pt1 start point of the interpolation.\r\n * @param fraction fractional position between points.\r\n * @param pt2 end point of the interpolation.\r\n * @param tangentScale scale factor to apply to the startToEnd vector.\r\n * @param result optional receiver.\r\n */\r\n public static interpolatePointAndTangent(\r\n pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d,\r\n ): Ray3d {\r\n result = result ?? Ray3d.createZero();\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n const dz = pt2.z - pt1.z;\r\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\r\n if (fraction <= 0.5)\r\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\r\n else {\r\n const t: number = fraction - 1.0;\r\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Ray3d.js","sourceRoot":"","sources":["../../../src/geometry3d/Ray3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sEAAoH;AACpH,0CAAmE;AACnE,yDAAsD;AACtD,yCAAsC;AAEtC,uDAA6C;AAC7C,uDAAsD;AACtD,mCAA2C;AAC3C,2CAAwC;AAGxC,qBAAqB;AACrB;;;;;;GAMG;AACH,MAAa,KAAK;IAahB,oCAAoC;IACpC,YAAoB,MAAe,EAAE,SAAmB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,SAAS,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C;IACD;;;;;;;;OAQG;IACI,MAAM,CAAC,0BAA0B,CACtC,GAAW,EAAE,QAAgB,EAAE,GAAW,EAAE,YAAoB,EAAE,MAAc;QAEhF,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACtC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,CAAC,CAAC;QAC9E,IAAI,QAAQ,IAAI,GAAG;YACjB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAC,CAAC;aACpF;YACH,MAAM,CAAC,GAAW,QAAQ,GAAG,GAAG,CAAC;YACjC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;SACnE;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAphBD,sBAohBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { CurveCurveApproachType, CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { AxisOrder, BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"./Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"./Point2dVector2d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Range1d, Range3d } from \"./Range\";\r\nimport { Transform } from \"./Transform\";\r\nimport { XYAndZ } from \"./XYZProps\";\r\n\r\n// cspell:word Cramer\r\n/**\r\n * A Ray3d contains\r\n * * an `origin` point.\r\n * * a `direction` vector (The vector is not required to be normalized).\r\n * * an optional weight (number).\r\n * @public\r\n */\r\nexport class Ray3d implements BeJSONFunctions {\r\n /** The ray origin */\r\n public origin: Point3d;\r\n /** The ray direction. This is commonly (but not always) a unit vector. */\r\n public direction: Vector3d;\r\n /** Numeric annotation. */\r\n public a?: number; // optional (e.g. weight)\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workVector2?: Vector3d;\r\n private static _workVector3?: Vector3d;\r\n private static _workVector4?: Vector3d;\r\n private static _workMatrix?: Matrix3d;\r\n // constructor (captures references)\r\n private constructor(origin: Point3d, direction: Vector3d) {\r\n this.origin = origin;\r\n this.direction = direction;\r\n this.a = undefined;\r\n }\r\n private static _create(x: number, y: number, z: number, u: number, v: number, w: number) {\r\n return new Ray3d(Point3d.create(x, y, z), Vector3d.create(u, v, w));\r\n }\r\n /** Create a ray on the x axis. */\r\n public static createXAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 1, 0, 0);\r\n }\r\n /** Create a ray on the y axis. */\r\n public static createYAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 1, 0);\r\n }\r\n /** Create a ray on the z axis. */\r\n public static createZAxis(): Ray3d {\r\n return Ray3d._create(0, 0, 0, 0, 0, 1);\r\n }\r\n /** Create a ray with all zeros. */\r\n public static createZero(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setZero();\r\n result.direction.setZero();\r\n return result;\r\n }\r\n return new Ray3d(Point3d.createZero(), Vector3d.createZero());\r\n }\r\n /**\r\n * Test for nearly equal Ray3d objects.\r\n * * This tests for near equality of origin and direction -- i.e. member-by-member comparison.\r\n * * Use [[isAlmostEqualPointSet]] to allow origins to be anywhere along the common ray and to have to allow the\r\n * directions to be scaled or opposing.\r\n */\r\n public isAlmostEqual(other: Ray3d): boolean {\r\n return this.origin.isAlmostEqual(other.origin) && this.direction.isAlmostEqual(other.direction);\r\n }\r\n /**\r\n * Return the dot product of the ray's direction vector with a vector from the ray origin\r\n * to the `spacePoint`.\r\n * * If the instance is the unit normal of a plane, then this method returns the (signed) altitude\r\n * of `spacePoint` with respect to the plane.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ProjectVectorOnPlane\r\n */\r\n public dotProductToPoint(spacePoint: Point3d): number {\r\n return this.direction.dotProductStartEnd(this.origin, spacePoint);\r\n }\r\n /** Return the fractional coordinate (along the direction vector) of the `spacePoint` projected to the ray. */\r\n public pointToFraction(spacePoint: Point3d): number {\r\n return Geometry.safeDivideFraction(\r\n this.dotProductToPoint(spacePoint),\r\n this.direction.magnitudeSquared(),\r\n 0,\r\n );\r\n }\r\n /** Return the `spacePoint` projected onto the ray. */\r\n public projectPointToRay(spacePoint: Point3d): Point3d {\r\n /**\r\n * To project a point to the ray, we can create a vector called \"v\" from ray origin to the spacePoint and project\r\n * that vector to the ray direction vector \"r\". The projection is \"((v.r)/||r||^2) r\" where \"v.r\" is the dot\r\n * product. Note that pointToFraction returns \"(v.r)/||r||^2\".\r\n * Note: If r is the normal of a plane, then projection length \"(v.r)/||r||\" is the signed altitude of the\r\n * spacePoint with respect to the plane.\r\n */\r\n return this.origin.plusScaled(this.direction, this.pointToFraction(spacePoint));\r\n }\r\n /**\r\n * Test for nearly equal rays, allowing origin float and direction scaling.\r\n * * Use [[isAlmostEqual]] to require member-by-member comparison.\r\n */\r\n public isAlmostEqualPointSet(other: Ray3d): boolean {\r\n /**\r\n * This function tests two rays to determine if they define the same infinite lines.\r\n * So the origins can be different as long as they are on the infinite line (they can\r\n * \"float\") but the directions must be parallel or antiparallel.\r\n */\r\n if (!this.direction.isParallelTo(other.direction, true))\r\n return false;\r\n /**\r\n * In exact math, we consider a ray to have an infinite line as direction (not a finite vector).\r\n * Therefore, in exact math it is not possible for one origin to be on the other ray but not vice\r\n * versa. However, we test both ways because first check may pass due to round-off errors.\r\n */\r\n let workPoint = this.projectPointToRay(other.origin);\r\n if (!other.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n workPoint = other.projectPointToRay(this.origin);\r\n if (!this.origin.isAlmostEqualMetric(workPoint))\r\n return false;\r\n return true;\r\n }\r\n /** Create a ray from origin and direction. */\r\n public static create(origin: Point3d, direction: Vector3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(origin, direction);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), direction.clone());\r\n }\r\n /**\r\n * Given a homogeneous point and its derivative components, construct a Ray3d with cartesian\r\n * coordinates and derivatives.\r\n * @param weightedPoint `[x,y,z,w]` parts of weighted point.\r\n * @param weightedDerivative `[x,y,z,w]` derivatives\r\n * @param result\r\n */\r\n public static createWeightedDerivative(\r\n weightedPoint: Float64Array, weightedDerivative: Float64Array, result?: Ray3d,\r\n ): Ray3d | undefined {\r\n const w = weightedPoint[3];\r\n const dw = weightedDerivative[3];\r\n const x = weightedPoint[0];\r\n const y = weightedPoint[1];\r\n const z = weightedPoint[2];\r\n const dx = weightedDerivative[0] * w - weightedPoint[0] * dw;\r\n const dy = weightedDerivative[1] * w - weightedPoint[1] * dw;\r\n const dz = weightedDerivative[2] * w - weightedPoint[2] * dw;\r\n if (Geometry.isSmallMetricDistance(w))\r\n return undefined;\r\n const divW = 1.0 / w;\r\n const divWW = divW * divW;\r\n return Ray3d.createXYZUVW(\r\n x * divW, y * divW, z * divW,\r\n dx * divWW, dy * divWW, dz * divWW,\r\n result,\r\n );\r\n }\r\n /** Create from coordinates of the origin and direction. */\r\n public static createXYZUVW(\r\n originX: number, originY: number, originZ: number,\r\n directionX: number, directionY: number, directionZ: number,\r\n result?: Ray3d,\r\n ): Ray3d {\r\n if (result) {\r\n result.getOriginRef().set(originX, originY, originZ);\r\n result.getDirectionRef().set(directionX, directionY, directionZ);\r\n return result;\r\n }\r\n return new Ray3d(Point3d.create(originX, originY, originZ), Vector3d.create(directionX, directionY, directionZ));\r\n }\r\n /** Capture origin and direction in a new Ray3d. */\r\n public static createCapture(origin: Point3d, direction: Vector3d): Ray3d {\r\n return new Ray3d(origin, direction);\r\n }\r\n /** Create from (clones of) origin, direction, and numeric weight. */\r\n public static createPointVectorNumber(origin: Point3d, direction: Vector3d, a: number, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setFrom(direction);\r\n result.a = a;\r\n return result;\r\n }\r\n result = new Ray3d(origin.clone(), direction.clone());\r\n result.a = a;\r\n return result;\r\n }\r\n /** Create from origin and target. The direction vector is the full length (non-unit) vector from origin to target. */\r\n public static createStartEnd(origin: Point3d, target: Point3d, result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.origin.setFrom(origin);\r\n result.direction.setStartEnd(origin, target);\r\n return result;\r\n }\r\n return new Ray3d(origin.clone(), Vector3d.createStartEnd(origin, target));\r\n }\r\n /** Return a reference to the ray's origin. */\r\n public getOriginRef(): Point3d {\r\n return this.origin;\r\n }\r\n /** Return a reference to the ray's direction vector. */\r\n public getDirectionRef(): Vector3d {\r\n return this.direction;\r\n }\r\n /** Copy coordinates from origin and direction. */\r\n public set(origin: Point3d, direction: Vector3d): void {\r\n this.origin.setFrom(origin);\r\n this.direction.setFrom(direction);\r\n }\r\n /** Clone the ray. */\r\n public clone(result?: Ray3d): Ray3d {\r\n if (result) {\r\n result.set(this.origin.clone(), this.direction.clone());\r\n return result;\r\n }\r\n return new Ray3d(this.origin.clone(), this.direction.clone());\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: Ray3d): Ray3d {\r\n return Ray3d.create(\r\n transform.multiplyPoint3d(this.origin, result?.origin),\r\n transform.multiplyVector(this.direction, result?.direction),\r\n result,\r\n );\r\n }\r\n /** Create a clone and return the inverse transform of the clone. */\r\n public cloneInverseTransformed(transform: Transform, result?: Ray3d): Ray3d | undefined {\r\n if (!transform.computeCachedInverse(true))\r\n return undefined;\r\n return Ray3d.create(\r\n transform.multiplyInversePoint3d(this.origin, result?.origin)!,\r\n transform.matrix.multiplyInverseXYZAsVector3d(\r\n this.direction.x, this.direction.y, this.direction.z, result?.direction,\r\n )!,\r\n result,\r\n );\r\n }\r\n /** Apply a transform in place. */\r\n public transformInPlace(transform: Transform) {\r\n transform.multiplyPoint3d(this.origin, this.origin);\r\n transform.multiplyVector(this.direction, this.direction);\r\n }\r\n /** Copy data from another ray. */\r\n public setFrom(source: Ray3d): void {\r\n this.set(source.origin, source.direction);\r\n }\r\n /**\r\n * Return a point at fractional position along the ray.\r\n * * fraction 0 is the ray origin.\r\n * * fraction 1 is at the end of the direction vector when placed at the origin.\r\n */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.origin.plusScaled(this.direction, fraction, result);\r\n }\r\n /**\r\n * Return a transform for rigid axes at ray origin with z in ray direction.\r\n * * If the direction vector is zero, axes default to identity (from [[Matrix3d.createRigidHeadsUp]])\r\n */\r\n public toRigidZFrame(result?: Transform): Transform | undefined {\r\n const axes = Ray3d._workMatrix = Matrix3d.createRigidHeadsUp(this.direction, AxisOrder.ZXY, Ray3d._workMatrix);\r\n return Transform.createOriginAndMatrix(this.origin, axes, result);\r\n }\r\n /** Convert {origin:[x,y,z], direction:[u,v,w]} to a Ray3d. */\r\n public setFromJSON(json?: any) {\r\n if (!json) {\r\n this.origin.set(0, 0, 0);\r\n this.direction.set(0, 0, 1);\r\n return;\r\n }\r\n this.origin.setFromJSON(json.origin);\r\n this.direction.setFromJSON(json.direction);\r\n }\r\n /**\r\n * Construct a JSON object from this Ray3d.\r\n * @return {*} [origin,normal]\r\n */\r\n public toJSON(): any {\r\n return { origin: this.origin.toJSON(), direction: this.direction.toJSON() };\r\n }\r\n /** Create a new ray from json object. See `setFromJSON` for json structure; */\r\n public static fromJSON(json?: any) {\r\n const result = Ray3d.createXAxis();\r\n result.setFromJSON(json);\r\n return result;\r\n }\r\n /**\r\n * Try to scale the direction vector to a given `magnitude`.\r\n * * Returns `false` if the ray direction is a zero vector.\r\n */\r\n public trySetDirectionMagnitudeInPlace(magnitude: number = 1.0): boolean {\r\n if (this.direction.tryNormalizeInPlace()) {\r\n this.direction.scaleInPlace(magnitude);\r\n return true;\r\n }\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /**\r\n * Normalize the ray direction in place.\r\n * * If parameter `a` is clearly nonzero and the direction vector can be normalized,\r\n * * Save the parameter `a` as the optional `a` member of the ray.\r\n * * Normalize the ray's direction vector.\r\n * * If parameter `a` is nearly zero,\r\n * * Set the `a` member to zero.\r\n * * Set the ray's direction vector to zero.\r\n * @param a value to be saved (e.g,. area).\r\n * @returns `true` if `a` is nonzero and normalization was successful. Otherwise, return `false`.\r\n */\r\n public tryNormalizeInPlaceWithAreaWeight(a: number): boolean {\r\n const tolerance = Geometry.smallMetricDistanceSquared;\r\n this.a = a;\r\n if (Math.abs(a) > tolerance && this.direction.tryNormalizeInPlace(tolerance))\r\n return true;\r\n this.direction.setZero();\r\n this.a = 0.0;\r\n return false;\r\n }\r\n /** Return distance from the ray to point in space. */\r\n public distance(spacePoint: Point3d): number {\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.dotProductToPoint(spacePoint);\r\n const aa = Geometry.inverseMetricDistanceSquared(uu);\r\n if (aa)\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint) - uv * uv * aa);\r\n else\r\n return Math.sqrt(this.origin.distanceSquared(spacePoint));\r\n }\r\n /**\r\n * Return the intersection parameter of the line defined by the ray with a `plane`.\r\n * * Stores the point of intersection in the `result` point (if passed as a parameter) and returns the parameter\r\n * along the ray where the intersection occurs. If we call the parameter 'f' then the point of intersection would\r\n * be `ray.origin + f * ray.direction`. Therefore:\r\n * * if ray intersects the plane at its origin, the function returns f = 0.\r\n * * if intersects at `ray.origin + ray.direction`, the function returns f = 1.\r\n * * if intersects behind the ray origin, the function returns f < 0.\r\n * * if intersects after `ray.origin + ray.direction`, the function returns f > 1.\r\n * * Returns `undefined` if the ray and plane are parallel or coplanar.\r\n */\r\n public intersectionWithPlane(plane: Plane3dByOriginAndUnitNormal, result?: Point3d): number | undefined {\r\n const vectorA = Vector3d.createStartEnd(plane.getOriginRef(), this.origin);\r\n const uDotN = this.direction.dotProduct(plane.getNormalRef());\r\n const nDotN = this.direction.magnitudeSquared();\r\n const aDotN = vectorA.dotProduct(plane.getNormalRef());\r\n const division = Geometry.conditionalDivideFraction(-aDotN, uDotN);\r\n if (undefined === division)\r\n return undefined;\r\n const division1 = Geometry.conditionalDivideFraction(nDotN, uDotN);\r\n if (undefined === division1)\r\n return undefined;\r\n if (result) {\r\n this.origin.plusScaled(this.direction, division, result);\r\n }\r\n return division;\r\n }\r\n /**\r\n * Find the intersection of the line defined by the ray with a Range3d.\r\n * * Return the range of parameters (on the ray) which are \"inside\" the range.\r\n * * Note that a range is always returned; if there is no intersection it is indicated by the test `result.isNull`.\r\n */\r\n public intersectionWithRange3d(range: Range3d, result?: Range1d): Range1d {\r\n if (range.isNull)\r\n return Range1d.createNull(result);\r\n const interval = Range1d.createXX(-Geometry.largeCoordinateResult, Geometry.largeCoordinateResult, result);\r\n if (interval.clipLinearMapToInterval(this.origin.x, this.direction.x, range.low.x, range.high.x)\r\n && interval.clipLinearMapToInterval(this.origin.y, this.direction.y, range.low.y, range.high.y)\r\n && interval.clipLinearMapToInterval(this.origin.z, this.direction.z, range.low.z, range.high.z)\r\n )\r\n return interval;\r\n return interval;\r\n }\r\n /**\r\n * Compute the intersection of the ray with a triangle.\r\n * * This method is faster than `BarycentricTriangle.intersectRay3d`.\r\n * @param vertex0 first vertex of the triangle\r\n * @param vertex1 second vertex of the triangle\r\n * @param vertex2 third vertex of the triangle\r\n * @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line\r\n * intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)\r\n * @param parameterTol optional tolerance used to snap barycentric coordinates of the intersection point to\r\n * a triangle edge or vertex (if tolerance is not provided, Geometry.smallFloatingPoint is used)\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.\r\n */\r\n public intersectionWithTriangle(\r\n vertex0: Point3d, vertex1: Point3d, vertex2: Point3d, distanceTol?: number, parameterTol?: number, result?: Point3d,\r\n ): Point3d | undefined {\r\n /**\r\n * Suppose ray is shown by \"rayOrigin + t*rayVector\" and barycentric coordinate of point\r\n * P = w*v0 + u*v1 + v*v2 = (1-u-v)*v0 + u*v1 + v*v2 = v0 + u*(v1-v0) + v*(v2-v0)\r\n *\r\n * Then if ray intersects triangle at a point we have\r\n * v0 + u*(v1-v0) + v*(v2-v0) = rayOrigin + t*rayVector\r\n * or\r\n * -t*rayVector + u*(v1-v0) + v*(v2-v0) = rayOrigin - v0\r\n *\r\n * This equation can be reformulated as the following linear system:\r\n *\r\n * [ | | | ] [t] [ | ]\r\n * [-rayVector v1-v0 v2-v0] [u] = [rayOrigin - v0]\r\n * [ | | | ] [v] [ | ]\r\n *\r\n * Then to find t, u, and v use Cramer's Rule and also the fact that if matrix A = [c1,c2,c3], then\r\n * det(A) = c1.(c2 x c3) which leads to\r\n *\r\n * t = [(rayOrigin - v0).((v1-v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * u = [-rayVector.((rayOrigin - v0) x (v2-v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n * v = [-rayVector.((v1-v0) x (rayOrigin - v0))] / [-rayVector.((v1-v0) x (v2-v0))]\r\n *\r\n * Now note that swapping any 2 vectors c_i and c_j in formula c1.(c2 x c3) negates it. For example:\r\n * c1.(c2 x c3) = -c3.(c2 x c1) = c2.(c3 x c1)\r\n *\r\n * This leads to the final formulas used in the following code:\r\n * t = [(v2-v0).((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * u = [(rayOrigin - v0).(rayVector x (v2-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n * v = [-rayVector.((rayOrigin - v0) x (v1-v0))] / [(v1-v0).(rayVector x (v2-v0))]\r\n *\r\n * Note that we should verify 0 <= u,v,w <= 1. To do so we only need to check 0 <= u <= 1, 0 <= v, and u+v <= 1.\r\n * That's because w = 1-(u+v) and if we have those 4 checks, it's guaranteed that v <= 1 and 0 <= u+v and so\r\n * 0 <= w <= 1.\r\n *\r\n * More info be found at\r\n * https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm\r\n */\r\n if (distanceTol === undefined || distanceTol < 0) // we explicitly allow zero tolerance\r\n distanceTol = Geometry.smallMetricDistance;\r\n if (parameterTol === undefined || parameterTol < 0) // we explicitly allow zero tolerance\r\n parameterTol = Geometry.smallFloatingPoint;\r\n const edge1 = Ray3d._workVector0 = Vector3d.createStartEnd(vertex0, vertex1, Ray3d._workVector0);\r\n const edge2 = Ray3d._workVector1 = Vector3d.createStartEnd(vertex0, vertex2, Ray3d._workVector1);\r\n const h = Ray3d._workVector2 = this.direction.crossProduct(edge2, Ray3d._workVector2);\r\n const a = edge1.dotProduct(h);\r\n if (a >= -distanceTol && a <= distanceTol)\r\n return undefined; // ray is parallel to the triangle (includes coplanar case)\r\n const f = 1.0 / a;\r\n const s = Ray3d._workVector3 = Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);\r\n let u = f * s.dotProduct(h);\r\n if (u < 0.0) {\r\n if (u > -parameterTol)\r\n u = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u > 1.0) {\r\n if (u < 1.0 + parameterTol)\r\n u = 1.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);\r\n let v = f * this.direction.dotProduct(q);\r\n if (v < 0.0) {\r\n if (v > -parameterTol)\r\n v = 0.0;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n } else if (u + v > 1.0) {\r\n if (u + v < 1.0 + parameterTol)\r\n v = 1.0 - u;\r\n else\r\n return undefined; // ray does not intersect the triangle\r\n }\r\n // at this stage, we know the line (parameterized as the ray) intersects the triangle\r\n const t = f * edge2.dotProduct(q);\r\n if (t <= distanceTol) // line intersection but not ray intersection\r\n return undefined;\r\n return this.origin.plusScaled(this.direction, t, result); // ray intersection\r\n }\r\n /**\r\n * Return the shortest vector `v` to `targetPoint` from the line defined by this ray.\r\n * * If the projection of `targetPoint` onto the line defined by this ray is q, then `v = targetPoint - q`.\r\n */\r\n public perpendicularPartOfVectorToTarget(targetPoint: XYAndZ, result?: Vector3d): Vector3d {\r\n const vectorV = Vector3d.createStartEnd(this.origin, targetPoint);\r\n const uu = this.direction.magnitudeSquared();\r\n const uv = this.direction.dotProductStartEnd(this.origin, targetPoint);\r\n const fraction = Geometry.safeDivideFraction(uv, uu, 0.0);\r\n return vectorV.plusScaled(this.direction, -fraction, result);\r\n }\r\n /**\r\n * Determine if two rays intersect, or are fully overlapped, or parallel but not coincident, or skew.\r\n * * Return a CurveLocationDetailPair which contains fraction and point on each ray and has\r\n * annotation (in member `approachType`) indicating one of these relationships:\r\n * * CurveCurveApproachType.Intersection -- the rays have a simple intersection, at fractions indicated\r\n * in detailA and detailB\r\n * * CurveCurveApproachType.PerpendicularChord -- there is pair of where the rays have closest approach.\r\n * The rays are skew in space.\r\n * * CurveCurveApproachType.CoincidentGeometry -- the rays are the same unbounded line in space. The\r\n * fractions and points are a representative single common point.\r\n * * CurveCurveApproachType.Parallel -- the rays are parallel (and not coincident). The two points are\r\n * at the minimum distance\r\n */\r\n public static closestApproachRay3dRay3d(rayA: Ray3d, rayB: Ray3d): CurveLocationDetailPair {\r\n const intersectionFractions = Vector2d.create();\r\n let fractionA, fractionB;\r\n let pointA, pointB;\r\n let pairType;\r\n if (\r\n SmallSystem.ray3dXYZUVWClosestApproachUnbounded(\r\n rayA.origin.x, rayA.origin.y, rayA.origin.z, rayA.direction.x, rayA.direction.y, rayA.direction.z,\r\n rayB.origin.x, rayB.origin.y, rayB.origin.z, rayB.direction.x, rayB.direction.y, rayB.direction.z,\r\n intersectionFractions,\r\n )\r\n ) {\r\n fractionA = intersectionFractions.x;\r\n fractionB = intersectionFractions.y;\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.Intersection : CurveCurveApproachType.PerpendicularChord;\r\n } else {\r\n fractionB = 0.0;\r\n fractionA = rayA.pointToFraction(rayB.origin);\r\n pointA = rayA.fractionToPoint(fractionA);\r\n pointB = rayB.fractionToPoint(fractionB);\r\n pairType = pointA.isAlmostEqualMetric(pointB) ?\r\n CurveCurveApproachType.CoincidentGeometry : CurveCurveApproachType.ParallelGeometry;\r\n }\r\n const pair = CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createRayFractionPoint(rayA, fractionA, rayA.fractionToPoint(fractionA)),\r\n CurveLocationDetail.createRayFractionPoint(rayB, fractionB, rayB.fractionToPoint(fractionB)));\r\n pair.approachType = pairType;\r\n return pair;\r\n }\r\n /**\r\n * Return a ray with `ray.origin` interpolated between `pt1` and `pt2` at the given `fraction`\r\n * and `ray.direction` set to the vector from `pt1` to `pt2` multiplied by the given `tangentScale`.\r\n * @param pt1 start point of the interpolation.\r\n * @param fraction fractional position between points.\r\n * @param pt2 end point of the interpolation.\r\n * @param tangentScale scale factor to apply to the startToEnd vector.\r\n * @param result optional receiver.\r\n */\r\n public static interpolatePointAndTangent(\r\n pt1: XYAndZ, fraction: number, pt2: XYAndZ, tangentScale: number, result?: Ray3d,\r\n ): Ray3d {\r\n result = result ?? Ray3d.createZero();\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n const dz = pt2.z - pt1.z;\r\n result.direction.set(tangentScale * dx, tangentScale * dy, tangentScale * dz);\r\n if (fraction <= 0.5)\r\n result.origin.set(pt1.x + fraction * dx, pt1.y + fraction * dy, pt1.z + fraction * dz);\r\n else {\r\n const t: number = fraction - 1.0;\r\n result.origin.set(pt2.x + t * dx, pt2.y + t * dy, pt2.z + t * dz);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GrowableXYZArray } from "./GrowableXYZArray";
|
|
2
|
+
import { IndexedXYZCollection } from "./IndexedXYZCollection";
|
|
2
3
|
/** @packageDocumentation
|
|
3
4
|
* @module ArraysAndInterfaces
|
|
4
5
|
*/
|
|
@@ -50,6 +51,6 @@ export declare class GrowableXYZArrayCache extends ReusableObjectCache<GrowableX
|
|
|
50
51
|
* Grab an array from the cache and immediately fill from a source
|
|
51
52
|
* @param source
|
|
52
53
|
*/
|
|
53
|
-
grabAndFill(source:
|
|
54
|
+
grabAndFill(source: IndexedXYZCollection): GrowableXYZArray;
|
|
54
55
|
}
|
|
55
56
|
//# sourceMappingURL=ReusableObjectCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReusableObjectCache.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/ReusableObjectCache.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ReusableObjectCache.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/ReusableObjectCache.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH;;;;;;GAMG;AACH,8BAAsB,mBAAmB,CAAC,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAC/C,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,CAAC;IACtC,OAAO,CAAC,cAAc,CAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,SAAS;IAMT;;;OAGG;IACI,WAAW,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS;IAOtC;;;;;OAKG;IACI,aAAa,IAAI,CAAC;IAUzB;;OAEG;IACI,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE;CAKhC;AACD;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IAC9E,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IACrD,SAAS,CAAC,cAAc,IAAI,gBAAgB;;IAE5C;;;OAGG;IACI,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,gBAAgB;CAMnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReusableObjectCache.js","sourceRoot":"","sources":["../../../src/geometry3d/ReusableObjectCache.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,yDAAsD;
|
|
1
|
+
{"version":3,"file":"ReusableObjectCache.js","sourceRoot":"","sources":["../../../src/geometry3d/ReusableObjectCache.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,yDAAsD;AAGtD;;GAEG;AACH;;;;;;GAMG;AACH,MAAsB,mBAAmB;IAOvC;;OAEG;IACH;QACE,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,GAA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,CAAC;IAEd,CAAC;CACF;AAdD,sDAcC","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\nimport { GrowableXYZArray } from \"./GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"./IndexedXYZCollection\";\r\n\r\n/** @packageDocumentation\r\n * @module ArraysAndInterfaces\r\n */\r\n/**\r\n * abstract class managing an array of objects of type T, available for reuse by trusted callers.\r\n * * Derived class must implement these methods:\r\n * * `createForCache()` -- create a new, ready-to-use object\r\n * * `clearForCache (data: T)` -- tidy up `data` so it can be reused.\r\n * @internal\r\n */\r\nexport abstract class ReusableObjectCache<T> {\r\n protected abstract clearForCache(data: T): void;\r\n protected abstract createForCache(): T;\r\n private _cachedObjects: T[];\r\n public numDrop: number;\r\n public numCreate: number;\r\n public numReuse: number;\r\n /**\r\n * create a new cache for objects of type T\r\n */\r\n protected constructor() {\r\n this._cachedObjects = [];\r\n this.numDrop = 0;\r\n this.numCreate = 0;\r\n this.numReuse = 0;\r\n }\r\n /** Present `data` for storage in the cache, and hence reuse by any subsequent `grabFromCache`\r\n * * `data` will be sent to `clearForCache`.\r\n * * caller should never refer to this instance again.\r\n */\r\n public dropToCache(data: T | undefined) {\r\n if (data) {\r\n this.numDrop++;\r\n this.clearForCache(data);\r\n this._cachedObjects.push(data);\r\n }\r\n }\r\n /**\r\n * grab an object from the cache.\r\n * * The returned object becomes property of the caller.\r\n * * That is, the cache does not remember it for any further management\r\n * @param data\r\n */\r\n public grabFromCache(): T {\r\n let data = this._cachedObjects.pop();\r\n if (data === undefined) {\r\n data = this.createForCache();\r\n this.numCreate++;\r\n } else {\r\n this.numReuse++;\r\n }\r\n return data;\r\n }\r\n /** Drop all entries of data[] to the cache.\r\n * @param data on input, the data to drop. on output, data is an empty array.\r\n */\r\n public dropAllToCache(data: T[]) {\r\n while (data.length > 0) {\r\n this.dropToCache(data.pop());\r\n }\r\n }\r\n}\r\n/**\r\n * Cache of GrowableXYZArray.\r\n * Intended for use by (for instance) clipping methods that can be structured to have disciplined reuse of a small number of arrays for a large number of steps.\r\n * @internal\r\n */\r\nexport class GrowableXYZArrayCache extends ReusableObjectCache<GrowableXYZArray> {\r\n protected clearForCache(data: GrowableXYZArray): void { data.length = 0; }\r\n protected createForCache(): GrowableXYZArray { return new GrowableXYZArray(10); }\r\n public constructor() { super(); }\r\n /**\r\n * Grab an array from the cache and immediately fill from a source\r\n * @param source\r\n */\r\n public grabAndFill(source: IndexedXYZCollection): GrowableXYZArray {\r\n const dest = this.grabFromCache();\r\n dest.pushFrom(source);\r\n return dest;\r\n\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module CartesianGeometry
|
|
3
3
|
*/
|
|
4
|
-
import { AnyRegion } from "../curve/
|
|
4
|
+
import { AnyRegion } from "../curve/CurveTypes";
|
|
5
5
|
import { Loop } from "../curve/Loop";
|
|
6
6
|
import { IndexedReadWriteXYZCollection, IndexedXYZCollection } from "./IndexedXYZCollection";
|
|
7
7
|
import { Point3d } from "./Point3dVector3d";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortablePolygon.js","sourceRoot":"","sources":["../../../src/geometry3d/SortablePolygon.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAM/F,8DAAsD;AACtD,4DAAyD;AACzD,wDAAqD;AACrD,wCAAqC;AACrC,wDAAqD;AACrD,kDAA+C;AAC/C,sDAAmD;AACnD,iEAA6F;AAE7F,6CAA0C;AAI1C;;;GAGG;AACH,MAAe,mBAAmB;CAuBjC;AACD;;GAEG;AACH,MAAM,cAAe,SAAQ,mBAAmB;IAG9C,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,YAAmB,IAAmC;QACpD,KAAK,EAAE,CAAC;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AAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACM,WAAW;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IACM,QAAQ;QACb,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IACM,kBAAkB,CAAC,UAAkB;QAC1C,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IACM,mBAAmB;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC;IACjD,CAAC;CACF;AAvKD,0CAuKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { AnyRegion } from \"../curve/CurveChain\";\r\nimport { CurveChain } from \"../curve/CurveCollection\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { ParityRegion } from \"../curve/ParityRegion\";\r\nimport { RegionOps } from \"../curve/RegionOps\";\r\nimport { UnionRegion } from \"../curve/UnionRegion\";\r\nimport { IndexedReadWriteXYZCollection, IndexedXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { PolygonOps } from \"./PolygonOps\";\r\nimport { Range3d } from \"./Range\";\r\nimport { XAndY } from \"./XYZProps\";\r\n\r\n/** abstract base class for area-related queries of a loop.\r\n * * subclasses have particular logic for `Loop` and polygon data.\r\n * @internal\r\n */\r\nabstract class SimpleRegionCarrier {\r\n public abstract classifyPointXY(xy: XAndY): number | undefined;\r\n // Find any point on an edge.\r\n // evaluate tangent.\r\n // move to left or right according to signedArea, producing an interior point for the loop.\r\n public abstract getAnyInteriorPoint(): Point3d | undefined;\r\n /**\r\n * * grab the loop formatted as a simple polygon.\r\n * * stroke if necessary.\r\n */\r\n public abstract grabPolygon(): IndexedReadWriteXYZCollection | undefined;\r\n /**\r\n * * grab the loop formatted as a strongly typed loop object\r\n */\r\n public abstract grabLoop(): Loop | undefined;\r\n /**\r\n * (Property access) Return the signed area of the loop\r\n */\r\n public abstract get signedArea(): number;\r\n /**\r\n * If the current `signedArea` has different sign versus `targetSign`, reverse the loop in place.\r\n */\r\n public abstract reverseForAreaSign(targetSign: number): void;\r\n}\r\n/**\r\n * Implement `LoopCarrier` queries with the area as a polygon carried in an `IndexedReadWriteXYZCollection`\r\n */\r\nclass PolygonCarrier extends SimpleRegionCarrier {\r\n public data: IndexedReadWriteXYZCollection;\r\n private _signedArea: number;\r\n public get signedArea(): number { return this._signedArea; }\r\n public constructor(data: IndexedReadWriteXYZCollection) {\r\n super();\r\n this.data = data;\r\n this._signedArea = PolygonOps.areaXY(data);\r\n }\r\n /**\r\n * classify xy parts of point wrt this loop.\r\n * @param xy\r\n * @internal\r\n */\r\n public classifyPointXY(xy: XAndY): number | undefined {\r\n return PolygonOps.classifyPointInPolygonXY(xy.x, xy.y, this.data);\r\n }\r\n /** Return some point \"inside\"\r\n * NEEDS WORK: this returns a point ON --\r\n */\r\n public getAnyInteriorPoint(): Point3d | undefined {\r\n for (let childIndex = 0; childIndex < this.data.length; childIndex++) {\r\n const q = this.constructInteriorPointNearEdge(childIndex, 0.2349);\r\n if (q !== undefined)\r\n return q;\r\n }\r\n return undefined;\r\n }\r\n public grabPolygon(): IndexedReadWriteXYZCollection | undefined { return this.data; }\r\n public grabLoop(): Loop | undefined {\r\n return Loop.createPolygon(this.data);\r\n }\r\n public reverseForAreaSign(targetSign: number) {\r\n if (targetSign * this._signedArea < 0.0) {\r\n this.data.reverseInPlace();\r\n this._signedArea *= -1.0;\r\n }\r\n }\r\n public constructInteriorPointNearEdge(edgeIndex: number, fractionAlong: number): Point3d | undefined {\r\n if (edgeIndex + 1 < this.data.length) {\r\n const point0 = this.data.getPoint3dAtUncheckedPointIndex(edgeIndex);\r\n const point1 = this.data.getPoint3dAtUncheckedPointIndex(edgeIndex + 1);\r\n const vector = point0.vectorTo(point1);\r\n const point = point0.interpolate(fractionAlong, point1);\r\n vector.rotate90CCWXY(vector);\r\n if (vector.normalizeInPlace()) {\r\n if (this._signedArea < 0)\r\n vector.scaleInPlace(-1.0);\r\n const refDistance = Math.sqrt(Math.abs(this._signedArea));\r\n for (let fraction = 1.0e-5; fraction < 3; fraction *= 5.0) {\r\n const candidatePoint = point.plusScaled(vector, fraction * refDistance);\r\n if (1 === this.classifyPointXY(candidatePoint))\r\n return candidatePoint;\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n}\r\n/**\r\n * Implement `LoopCarrier` queries with the area as a strongly typed `Loop`\r\n */\r\nclass LoopCarrier extends SimpleRegionCarrier {\r\n public data: Loop;\r\n private _signedArea: number;\r\n public get signedArea(): number { return this._signedArea; }\r\n public constructor(data: Loop) {\r\n super();\r\n this.data = data;\r\n const areaMoments = RegionOps.computeXYAreaMoments(data);\r\n this._signedArea = areaMoments !== undefined ? areaMoments.quantitySum : 0.0;\r\n }\r\n /**\r\n * classify xy parts of point wrt this loop.\r\n * @param xy\r\n * @internal\r\n */\r\n public classifyPointXY(xy: XAndY): number | undefined {\r\n return RegionOps.testPointInOnOutRegionXY(this.data, xy.x, xy.y);\r\n }\r\n public constructInteriorPointNearChild(childIndex: number, fractionAlong: number): Point3d | undefined {\r\n if (childIndex < this.data.children.length) {\r\n const primitive = this.data.children[childIndex];\r\n const ray = primitive.fractionToPointAndUnitTangent(fractionAlong);\r\n ray.direction.rotate90CCWXY(ray.direction);\r\n if (this._signedArea < 0.0)\r\n ray.direction.scaleInPlace(-1.0);\r\n const refDistance = Math.sqrt(Math.abs(this._signedArea));\r\n for (let fraction = 1.0e-5; fraction < 3; fraction *= 5.0) {\r\n const candidatePoint = ray.fractionToPoint(fraction * refDistance);\r\n if (1 === this.classifyPointXY(candidatePoint))\r\n return candidatePoint;\r\n }\r\n }\r\n return undefined;\r\n }\r\n /** Return some point \"inside\"\r\n * NEEDS WORK: this returns a point ON --\r\n */\r\n public getAnyInteriorPoint(): Point3d | undefined {\r\n for (let childIndex = 0; childIndex < this.data.children.length; childIndex++) {\r\n const q = this.constructInteriorPointNearChild(childIndex, 0.2349);\r\n if (q !== undefined)\r\n return q;\r\n }\r\n return undefined;\r\n }\r\n public grabPolygon(): IndexedReadWriteXYZCollection | undefined {\r\n const strokes = this.data.cloneStroked();\r\n if (strokes instanceof CurveChain) {\r\n const linestring = LineString3d.create();\r\n for (const child of strokes.children) {\r\n if (child instanceof CurvePrimitive) {\r\n child.emitStrokes(linestring);\r\n }\r\n }\r\n return linestring.numPoints() > 0 ? linestring.packedPoints : undefined;\r\n }\r\n return undefined;\r\n }\r\n public grabLoop(): Loop | undefined {\r\n return this.data;\r\n }\r\n public reverseForAreaSign(targetSign: number) {\r\n if (targetSign * this._signedArea < 0.0) {\r\n this.data.reverseChildrenInPlace();\r\n this._signedArea *= -1.0;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A `SortablePolygon` carries a (single) loop with data useful for sorting for inner-outer structure.\r\n * @internal\r\n */\r\nexport class SortablePolygon {\r\n private _loopCarrier: SimpleRegionCarrier;\r\n public anyPoint?: Point3d;\r\n public sortKey: number;\r\n public range: Range3d;\r\n public parentIndex?: number;\r\n public isHole: boolean;\r\n public outputSetIndex?: number;\r\n /**\r\n *\r\n * @param loop Loop to capture.\r\n */\r\n public constructor(loop: IndexedReadWriteXYZCollection | Loop, range: Range3d) {\r\n if (loop instanceof IndexedReadWriteXYZCollection)\r\n this._loopCarrier = new PolygonCarrier(loop);\r\n else\r\n this._loopCarrier = new LoopCarrier(loop);\r\n this.range = range;\r\n this.sortKey = Math.abs(this._loopCarrier.signedArea);\r\n this.isHole = false;\r\n }\r\n /** Push loop with sort data onto the array.\r\n * * No action if no clear normal.\r\n * * return true if pushed.\r\n */\r\n public static pushPolygon(loops: SortablePolygon[], loop: IndexedReadWriteXYZCollection): boolean {\r\n const range = loop.getRange();\r\n const sortablePolygon = new SortablePolygon(loop, range);\r\n if (sortablePolygon.sortKey > 0.0) {\r\n loops.push(sortablePolygon);\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** Push loop with sort data onto the array.\r\n * * No action if no clear normal.\r\n * * return true if pushed.\r\n */\r\n public static pushLoop(loops: SortablePolygon[], loop: Loop): boolean {\r\n const range = loop.range();\r\n const sortablePolygon = new SortablePolygon(loop, range);\r\n if (sortablePolygon.sortKey > 0.0) {\r\n loops.push(sortablePolygon);\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** Push loop with sort data onto the array.\r\n * * No action if no clear normal.\r\n * * return true if pushed.\r\n */\r\n private static assignParentsAndDepth(loops: SortablePolygon[]): void {\r\n // Sort largest to smallest ...\r\n loops.sort((loopA: SortablePolygon, loopB: SortablePolygon) => (loopB.sortKey - loopA.sortKey));\r\n // starting with smallest loop, point each loop to smallest containing parent.\r\n for (let i = loops.length; i-- > 0;) {\r\n const thisLoop = loops[i];\r\n const xy = thisLoop._loopCarrier.getAnyInteriorPoint();\r\n if (xy !== undefined) {\r\n // find smallest containing parent (search forward only to hit)\r\n loops[i].parentIndex = undefined;\r\n loops[i].outputSetIndex = undefined;\r\n for (let j = i; j-- > 0;) {\r\n const otherLoop = loops[j];\r\n if (otherLoop.range.containsXY(xy.x, xy.y)) {\r\n if (1 === otherLoop._loopCarrier.classifyPointXY(xy)) {\r\n thisLoop.parentIndex = j;\r\n // The loops are searched from small area to larger. Any other containing loop is larger, so otherLoop must be the smallest.\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static assemblePolygonSet(loops: SortablePolygon[]): IndexedReadWriteXYZCollection[][] {\r\n const outputSets: IndexedReadWriteXYZCollection[][] = [];\r\n\r\n // In large-to-small order:\r\n // If a loop has no parent or has a \"hole\" as parent it is outer.\r\n // otherwise (i.e. it has a non-hole parent) it becomes a hole in the parent.\r\n for (const loopData of loops) {\r\n loopData.isHole = false;\r\n const parentIndex = loopData.parentIndex;\r\n if (parentIndex !== undefined)\r\n loopData.isHole = !loops[parentIndex].isHole;\r\n if (!loopData.isHole) {\r\n loopData._loopCarrier.reverseForAreaSign(1.0);\r\n loopData.outputSetIndex = outputSets.length;\r\n outputSets.push([]);\r\n outputSets[loopData.outputSetIndex].push(loopData._loopCarrier.grabPolygon()!);\r\n } else {\r\n loopData._loopCarrier.reverseForAreaSign(-1.0);\r\n const outputSetIndex = loops[parentIndex!].outputSetIndex!;\r\n outputSets[outputSetIndex].push(loopData._loopCarrier.grabPolygon()!);\r\n }\r\n }\r\n return outputSets;\r\n }\r\n private static assembleLoopSet(loops: SortablePolygon[]): AnyRegion[] {\r\n const outputSets: AnyRegion[] = [];\r\n const numLoops = loops.length;\r\n // In large-to-small order:\r\n // If a loop has no parent or has a \"hole\" as parent it is outer.\r\n // otherwise (i.e. it has a non-hole parent) it becomes a hole in the parent.\r\n for (let candidateIndex = 0; candidateIndex < numLoops; candidateIndex++) {\r\n const candidateData = loops[candidateIndex];\r\n const parentIndex = candidateData.parentIndex;\r\n candidateData.isHole = parentIndex !== undefined ? !loops[parentIndex].isHole : false;\r\n\r\n if (!candidateData.isHole) {\r\n candidateData._loopCarrier.reverseForAreaSign(1.0);\r\n const candidateLoop = candidateData._loopCarrier.grabLoop()!;\r\n let candidateParityRegion: ParityRegion | undefined;\r\n // find all directly contained children . . .\r\n for (let childIndex = candidateIndex + 1; childIndex < numLoops; childIndex++) {\r\n const childData = loops[childIndex];\r\n if (childData.parentIndex === candidateIndex) {\r\n if (candidateParityRegion === undefined) {\r\n candidateParityRegion = ParityRegion.create();\r\n candidateParityRegion.tryAddChild(candidateLoop);\r\n childData._loopCarrier.reverseForAreaSign(-1.0);\r\n candidateParityRegion.tryAddChild(childData._loopCarrier.grabLoop());\r\n } else {\r\n childData._loopCarrier.reverseForAreaSign(-1.0);\r\n candidateParityRegion.tryAddChild(childData._loopCarrier.grabLoop());\r\n }\r\n }\r\n }\r\n if (candidateParityRegion !== undefined)\r\n outputSets.push(candidateParityRegion);\r\n else if (candidateLoop !== undefined)\r\n outputSets.push(candidateLoop);\r\n }\r\n }\r\n return outputSets;\r\n }\r\n\r\n public static sortAsAnyRegion(loops: SortablePolygon[]): AnyRegion {\r\n this.assignParentsAndDepth(loops);\r\n const regions = this.assembleLoopSet(loops);\r\n if (regions.length === 1)\r\n return regions[0];\r\n else {\r\n const unionRegion = UnionRegion.create();\r\n for (const region of regions)\r\n unionRegion.tryAddChild(region);\r\n return unionRegion;\r\n }\r\n }\r\n public static sortAsArrayOfArrayOfPolygons(loops: SortablePolygon[]): IndexedReadWriteXYZCollection[][] {\r\n this.assignParentsAndDepth(loops);\r\n return this.assemblePolygonSet(loops);\r\n }\r\n public grabPolygon(): IndexedXYZCollection | undefined {\r\n return this._loopCarrier.grabPolygon();\r\n }\r\n public grabLoop(): Loop | undefined {\r\n return this._loopCarrier.grabLoop();\r\n }\r\n public reverseForAreaSign(targetSign: number) {\r\n this._loopCarrier.reverseForAreaSign(targetSign);\r\n }\r\n public getAnyInteriorPoint(): Point3d | undefined {\r\n return this._loopCarrier.getAnyInteriorPoint();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SortablePolygon.js","sourceRoot":"","sources":["../../../src/geometry3d/SortablePolygon.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAM/F,8DAAsD;AACtD,4DAAyD;AACzD,wDAAqD;AACrD,wCAAqC;AACrC,wDAAqD;AACrD,kDAA+C;AAC/C,sDAAmD;AACnD,iEAA6F;AAE7F,6CAA0C;AAI1C;;;GAGG;AACH,MAAe,mBAAmB;CAuBjC;AACD;;GAEG;AACH,MAAM,cAAe,SAAQ,mBAAmB;IAG9C,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;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CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACM,WAAW;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IACM,QAAQ;QACb,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IACM,kBAAkB,CAAC,UAAkB;QAC1C,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IACM,mBAAmB;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC;IACjD,CAAC;CACF;AAvKD,0CAuKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { AnyRegion } from \"../curve/CurveTypes\";\r\nimport { CurveChain } from \"../curve/CurveCollection\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { ParityRegion } from \"../curve/ParityRegion\";\r\nimport { RegionOps } from \"../curve/RegionOps\";\r\nimport { UnionRegion } from \"../curve/UnionRegion\";\r\nimport { IndexedReadWriteXYZCollection, IndexedXYZCollection } from \"./IndexedXYZCollection\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { PolygonOps } from \"./PolygonOps\";\r\nimport { Range3d } from \"./Range\";\r\nimport { XAndY } from \"./XYZProps\";\r\n\r\n/** abstract base class for area-related queries of a loop.\r\n * * subclasses have particular logic for `Loop` and polygon data.\r\n * @internal\r\n */\r\nabstract class SimpleRegionCarrier {\r\n public abstract classifyPointXY(xy: XAndY): number | undefined;\r\n // Find any point on an edge.\r\n // evaluate tangent.\r\n // move to left or right according to signedArea, producing an interior point for the loop.\r\n public abstract getAnyInteriorPoint(): Point3d | undefined;\r\n /**\r\n * * grab the loop formatted as a simple polygon.\r\n * * stroke if necessary.\r\n */\r\n public abstract grabPolygon(): IndexedReadWriteXYZCollection | undefined;\r\n /**\r\n * * grab the loop formatted as a strongly typed loop object\r\n */\r\n public abstract grabLoop(): Loop | undefined;\r\n /**\r\n * (Property access) Return the signed area of the loop\r\n */\r\n public abstract get signedArea(): number;\r\n /**\r\n * If the current `signedArea` has different sign versus `targetSign`, reverse the loop in place.\r\n */\r\n public abstract reverseForAreaSign(targetSign: number): void;\r\n}\r\n/**\r\n * Implement `LoopCarrier` queries with the area as a polygon carried in an `IndexedReadWriteXYZCollection`\r\n */\r\nclass PolygonCarrier extends SimpleRegionCarrier {\r\n public data: IndexedReadWriteXYZCollection;\r\n private _signedArea: number;\r\n public get signedArea(): number { return this._signedArea; }\r\n public constructor(data: IndexedReadWriteXYZCollection) {\r\n super();\r\n this.data = data;\r\n this._signedArea = PolygonOps.areaXY(data);\r\n }\r\n /**\r\n * classify xy parts of point wrt this loop.\r\n * @param xy\r\n * @internal\r\n */\r\n public classifyPointXY(xy: XAndY): number | undefined {\r\n return PolygonOps.classifyPointInPolygonXY(xy.x, xy.y, this.data);\r\n }\r\n /** Return some point \"inside\"\r\n * NEEDS WORK: this returns a point ON --\r\n */\r\n public getAnyInteriorPoint(): Point3d | undefined {\r\n for (let childIndex = 0; childIndex < this.data.length; childIndex++) {\r\n const q = this.constructInteriorPointNearEdge(childIndex, 0.2349);\r\n if (q !== undefined)\r\n return q;\r\n }\r\n return undefined;\r\n }\r\n public grabPolygon(): IndexedReadWriteXYZCollection | undefined { return this.data; }\r\n public grabLoop(): Loop | undefined {\r\n return Loop.createPolygon(this.data);\r\n }\r\n public reverseForAreaSign(targetSign: number) {\r\n if (targetSign * this._signedArea < 0.0) {\r\n this.data.reverseInPlace();\r\n this._signedArea *= -1.0;\r\n }\r\n }\r\n public constructInteriorPointNearEdge(edgeIndex: number, fractionAlong: number): Point3d | undefined {\r\n if (edgeIndex + 1 < this.data.length) {\r\n const point0 = this.data.getPoint3dAtUncheckedPointIndex(edgeIndex);\r\n const point1 = this.data.getPoint3dAtUncheckedPointIndex(edgeIndex + 1);\r\n const vector = point0.vectorTo(point1);\r\n const point = point0.interpolate(fractionAlong, point1);\r\n vector.rotate90CCWXY(vector);\r\n if (vector.normalizeInPlace()) {\r\n if (this._signedArea < 0)\r\n vector.scaleInPlace(-1.0);\r\n const refDistance = Math.sqrt(Math.abs(this._signedArea));\r\n for (let fraction = 1.0e-5; fraction < 3; fraction *= 5.0) {\r\n const candidatePoint = point.plusScaled(vector, fraction * refDistance);\r\n if (1 === this.classifyPointXY(candidatePoint))\r\n return candidatePoint;\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n}\r\n/**\r\n * Implement `LoopCarrier` queries with the area as a strongly typed `Loop`\r\n */\r\nclass LoopCarrier extends SimpleRegionCarrier {\r\n public data: Loop;\r\n private _signedArea: number;\r\n public get signedArea(): number { return this._signedArea; }\r\n public constructor(data: Loop) {\r\n super();\r\n this.data = data;\r\n const areaMoments = RegionOps.computeXYAreaMoments(data);\r\n this._signedArea = areaMoments !== undefined ? areaMoments.quantitySum : 0.0;\r\n }\r\n /**\r\n * classify xy parts of point wrt this loop.\r\n * @param xy\r\n * @internal\r\n */\r\n public classifyPointXY(xy: XAndY): number | undefined {\r\n return RegionOps.testPointInOnOutRegionXY(this.data, xy.x, xy.y);\r\n }\r\n public constructInteriorPointNearChild(childIndex: number, fractionAlong: number): Point3d | undefined {\r\n if (childIndex < this.data.children.length) {\r\n const primitive = this.data.children[childIndex];\r\n const ray = primitive.fractionToPointAndUnitTangent(fractionAlong);\r\n ray.direction.rotate90CCWXY(ray.direction);\r\n if (this._signedArea < 0.0)\r\n ray.direction.scaleInPlace(-1.0);\r\n const refDistance = Math.sqrt(Math.abs(this._signedArea));\r\n for (let fraction = 1.0e-5; fraction < 3; fraction *= 5.0) {\r\n const candidatePoint = ray.fractionToPoint(fraction * refDistance);\r\n if (1 === this.classifyPointXY(candidatePoint))\r\n return candidatePoint;\r\n }\r\n }\r\n return undefined;\r\n }\r\n /** Return some point \"inside\"\r\n * NEEDS WORK: this returns a point ON --\r\n */\r\n public getAnyInteriorPoint(): Point3d | undefined {\r\n for (let childIndex = 0; childIndex < this.data.children.length; childIndex++) {\r\n const q = this.constructInteriorPointNearChild(childIndex, 0.2349);\r\n if (q !== undefined)\r\n return q;\r\n }\r\n return undefined;\r\n }\r\n public grabPolygon(): IndexedReadWriteXYZCollection | undefined {\r\n const strokes = this.data.cloneStroked();\r\n if (strokes instanceof CurveChain) {\r\n const linestring = LineString3d.create();\r\n for (const child of strokes.children) {\r\n if (child instanceof CurvePrimitive) {\r\n child.emitStrokes(linestring);\r\n }\r\n }\r\n return linestring.numPoints() > 0 ? linestring.packedPoints : undefined;\r\n }\r\n return undefined;\r\n }\r\n public grabLoop(): Loop | undefined {\r\n return this.data;\r\n }\r\n public reverseForAreaSign(targetSign: number) {\r\n if (targetSign * this._signedArea < 0.0) {\r\n this.data.reverseChildrenInPlace();\r\n this._signedArea *= -1.0;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A `SortablePolygon` carries a (single) loop with data useful for sorting for inner-outer structure.\r\n * @internal\r\n */\r\nexport class SortablePolygon {\r\n private _loopCarrier: SimpleRegionCarrier;\r\n public anyPoint?: Point3d;\r\n public sortKey: number;\r\n public range: Range3d;\r\n public parentIndex?: number;\r\n public isHole: boolean;\r\n public outputSetIndex?: number;\r\n /**\r\n *\r\n * @param loop Loop to capture.\r\n */\r\n public constructor(loop: IndexedReadWriteXYZCollection | Loop, range: Range3d) {\r\n if (loop instanceof IndexedReadWriteXYZCollection)\r\n this._loopCarrier = new PolygonCarrier(loop);\r\n else\r\n this._loopCarrier = new LoopCarrier(loop);\r\n this.range = range;\r\n this.sortKey = Math.abs(this._loopCarrier.signedArea);\r\n this.isHole = false;\r\n }\r\n /** Push loop with sort data onto the array.\r\n * * No action if no clear normal.\r\n * * return true if pushed.\r\n */\r\n public static pushPolygon(loops: SortablePolygon[], loop: IndexedReadWriteXYZCollection): boolean {\r\n const range = loop.getRange();\r\n const sortablePolygon = new SortablePolygon(loop, range);\r\n if (sortablePolygon.sortKey > 0.0) {\r\n loops.push(sortablePolygon);\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** Push loop with sort data onto the array.\r\n * * No action if no clear normal.\r\n * * return true if pushed.\r\n */\r\n public static pushLoop(loops: SortablePolygon[], loop: Loop): boolean {\r\n const range = loop.range();\r\n const sortablePolygon = new SortablePolygon(loop, range);\r\n if (sortablePolygon.sortKey > 0.0) {\r\n loops.push(sortablePolygon);\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** Push loop with sort data onto the array.\r\n * * No action if no clear normal.\r\n * * return true if pushed.\r\n */\r\n private static assignParentsAndDepth(loops: SortablePolygon[]): void {\r\n // Sort largest to smallest ...\r\n loops.sort((loopA: SortablePolygon, loopB: SortablePolygon) => (loopB.sortKey - loopA.sortKey));\r\n // starting with smallest loop, point each loop to smallest containing parent.\r\n for (let i = loops.length; i-- > 0;) {\r\n const thisLoop = loops[i];\r\n const xy = thisLoop._loopCarrier.getAnyInteriorPoint();\r\n if (xy !== undefined) {\r\n // find smallest containing parent (search forward only to hit)\r\n loops[i].parentIndex = undefined;\r\n loops[i].outputSetIndex = undefined;\r\n for (let j = i; j-- > 0;) {\r\n const otherLoop = loops[j];\r\n if (otherLoop.range.containsXY(xy.x, xy.y)) {\r\n if (1 === otherLoop._loopCarrier.classifyPointXY(xy)) {\r\n thisLoop.parentIndex = j;\r\n // The loops are searched from small area to larger. Any other containing loop is larger, so otherLoop must be the smallest.\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static assemblePolygonSet(loops: SortablePolygon[]): IndexedReadWriteXYZCollection[][] {\r\n const outputSets: IndexedReadWriteXYZCollection[][] = [];\r\n\r\n // In large-to-small order:\r\n // If a loop has no parent or has a \"hole\" as parent it is outer.\r\n // otherwise (i.e. it has a non-hole parent) it becomes a hole in the parent.\r\n for (const loopData of loops) {\r\n loopData.isHole = false;\r\n const parentIndex = loopData.parentIndex;\r\n if (parentIndex !== undefined)\r\n loopData.isHole = !loops[parentIndex].isHole;\r\n if (!loopData.isHole) {\r\n loopData._loopCarrier.reverseForAreaSign(1.0);\r\n loopData.outputSetIndex = outputSets.length;\r\n outputSets.push([]);\r\n outputSets[loopData.outputSetIndex].push(loopData._loopCarrier.grabPolygon()!);\r\n } else {\r\n loopData._loopCarrier.reverseForAreaSign(-1.0);\r\n const outputSetIndex = loops[parentIndex!].outputSetIndex!;\r\n outputSets[outputSetIndex].push(loopData._loopCarrier.grabPolygon()!);\r\n }\r\n }\r\n return outputSets;\r\n }\r\n private static assembleLoopSet(loops: SortablePolygon[]): AnyRegion[] {\r\n const outputSets: AnyRegion[] = [];\r\n const numLoops = loops.length;\r\n // In large-to-small order:\r\n // If a loop has no parent or has a \"hole\" as parent it is outer.\r\n // otherwise (i.e. it has a non-hole parent) it becomes a hole in the parent.\r\n for (let candidateIndex = 0; candidateIndex < numLoops; candidateIndex++) {\r\n const candidateData = loops[candidateIndex];\r\n const parentIndex = candidateData.parentIndex;\r\n candidateData.isHole = parentIndex !== undefined ? !loops[parentIndex].isHole : false;\r\n\r\n if (!candidateData.isHole) {\r\n candidateData._loopCarrier.reverseForAreaSign(1.0);\r\n const candidateLoop = candidateData._loopCarrier.grabLoop()!;\r\n let candidateParityRegion: ParityRegion | undefined;\r\n // find all directly contained children . . .\r\n for (let childIndex = candidateIndex + 1; childIndex < numLoops; childIndex++) {\r\n const childData = loops[childIndex];\r\n if (childData.parentIndex === candidateIndex) {\r\n if (candidateParityRegion === undefined) {\r\n candidateParityRegion = ParityRegion.create();\r\n candidateParityRegion.tryAddChild(candidateLoop);\r\n childData._loopCarrier.reverseForAreaSign(-1.0);\r\n candidateParityRegion.tryAddChild(childData._loopCarrier.grabLoop());\r\n } else {\r\n childData._loopCarrier.reverseForAreaSign(-1.0);\r\n candidateParityRegion.tryAddChild(childData._loopCarrier.grabLoop());\r\n }\r\n }\r\n }\r\n if (candidateParityRegion !== undefined)\r\n outputSets.push(candidateParityRegion);\r\n else if (candidateLoop !== undefined)\r\n outputSets.push(candidateLoop);\r\n }\r\n }\r\n return outputSets;\r\n }\r\n\r\n public static sortAsAnyRegion(loops: SortablePolygon[]): AnyRegion {\r\n this.assignParentsAndDepth(loops);\r\n const regions = this.assembleLoopSet(loops);\r\n if (regions.length === 1)\r\n return regions[0];\r\n else {\r\n const unionRegion = UnionRegion.create();\r\n for (const region of regions)\r\n unionRegion.tryAddChild(region);\r\n return unionRegion;\r\n }\r\n }\r\n public static sortAsArrayOfArrayOfPolygons(loops: SortablePolygon[]): IndexedReadWriteXYZCollection[][] {\r\n this.assignParentsAndDepth(loops);\r\n return this.assemblePolygonSet(loops);\r\n }\r\n public grabPolygon(): IndexedXYZCollection | undefined {\r\n return this._loopCarrier.grabPolygon();\r\n }\r\n public grabLoop(): Loop | undefined {\r\n return this._loopCarrier.grabLoop();\r\n }\r\n public reverseForAreaSign(targetSign: number) {\r\n this._loopCarrier.reverseForAreaSign(targetSign);\r\n }\r\n public getAnyInteriorPoint(): Point3d | undefined {\r\n return this._loopCarrier.getAnyInteriorPoint();\r\n }\r\n}\r\n"]}
|
|
@@ -213,7 +213,7 @@ class YawPitchRollAngles {
|
|
|
213
213
|
*/
|
|
214
214
|
static createFromMatrix3d(matrix, result) {
|
|
215
215
|
/**
|
|
216
|
-
* The rotation matrix
|
|
216
|
+
* The rotation matrix form is
|
|
217
217
|
*
|
|
218
218
|
* Matrix3d.createRowValues(
|
|
219
219
|
* cz * cy, -(sz * cx + cz * sy * sx), (sz * sx - cz * sy * cx),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YawPitchRollAngles.js","sourceRoot":"","sources":["../../../src/geometry3d/Y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AI,CAAC,aAAa,EAAE,CAAC;YACzC,IAAI,WAAW,GAAG,SAAS,GAAG,WAAW,EAAE;gBACzC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACtB;iBAAM,IAAI,WAAW,GAAG,SAAS,GAAG,WAAW,EAAE;gBAChD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACtB;iBAAM;gBACL,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACtC,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACtC,IAAI,IAAI,IAAI,IAAI,EAAE;oBAChB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;iBACtB;qBAAM;oBACL,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;iBACtB;aACF;SACF;QACD,eAAe;QACf,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,mBAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACnF,CAAC;CACF;AAjSD,gDAiSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { AngleProps, Geometry } from \"../Geometry\";\r\nimport { Angle } from \"./Angle\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n// cspell:word Tait\r\n\r\n/**\r\n * Angle properties of a `YawPitchRoll` orientation\r\n * @public\r\n */\r\nexport interface YawPitchRollProps {\r\n /** yaw field */\r\n yaw?: AngleProps;\r\n /** pitch field */\r\n pitch?: AngleProps;\r\n /** roll field */\r\n roll?: AngleProps;\r\n}\r\n\r\n/**\r\n * Three angles that determine the orientation of an object in space, sometimes referred to as [Tait–Bryan angles]\r\n * (https://en.wikipedia.org/wiki/Euler_angles).\r\n * * The matrix construction can be replicated by this logic:\r\n * * xyz coordinates have\r\n * * x forward\r\n * * y to left\r\n * * z up\r\n * * Note that this is a right handed coordinate system.\r\n * * yaw is a rotation of x towards y, i.e. around positive z (counterclockwise):\r\n * * `yawMatrix = Matrix3d.createRotationAroundAxisIndex(2, Angle.createDegrees(yawDegrees));`\r\n * * pitch is a rotation that raises x towards z, i.e. rotation around **negative y** (**clockwise**):\r\n * * `pitchMatrix = Matrix3d.createRotationAroundAxisIndex(1, Angle.createDegrees(-pitchDegrees));`\r\n * * roll is rotation of y towards z, i.e. rotation around positive x (counterclockwise):\r\n * * `rollMatrix = Matrix3d.createRotationAroundAxisIndex(0, Angle.createDegrees(rollDegrees));`\r\n * * The YPR matrix is the product\r\n * * `result = yawMatrix.multiplyMatrixMatrix(pitchMatrix.multiplyMatrixMatrix(rollMatrix));`\r\n * * Note that this is for \"column based\" matrix with vectors multiplying on the right of the matrix.\r\n * Hence a vector is first rotated by roll, then the pitch, finally yaw. So multiplication order in\r\n * the sense of AxisOrder is `RPY` (i.e., XYZ), in contrast to the familiar name `YPR`.\r\n * @public\r\n */\r\nexport class YawPitchRollAngles {\r\n /** The yaw angle: counterclockwise rotation angle around z */\r\n public yaw: Angle;\r\n /** The pitch angle: **clockwise** rotation angle around y */\r\n public pitch: Angle;\r\n /** The roll angle: counterclockwise rotation angle around x */\r\n public roll: Angle;\r\n /**\r\n * Constructor\r\n * @param yaw counterclockwise rotation angle around z\r\n * @param pitch **clockwise** rotation angle around y\r\n * @param roll counterclockwise rotation angle around x\r\n */\r\n constructor(yaw: Angle = Angle.zero(), pitch: Angle = Angle.zero(), roll: Angle = Angle.zero()) {\r\n this.yaw = yaw;\r\n this.pitch = pitch;\r\n this.roll = roll;\r\n }\r\n /** Freeze this YawPitchRollAngles */\r\n public freeze(): Readonly<this> {\r\n this.yaw.freeze();\r\n this.pitch.freeze();\r\n this.roll.freeze();\r\n return Object.freeze(this);\r\n }\r\n /**\r\n * Constructor for YawPitchRollAngles with angles in degrees.\r\n * @param yawDegrees counterclockwise rotation angle (in degrees) around z\r\n * @param pitchDegrees **clockwise** rotation angle (in degrees) around y\r\n * @param rollDegrees counterclockwise rotation angle (in degrees) around x\r\n */\r\n public static createDegrees(yawDegrees: number, pitchDegrees: number, rollDegrees: number): YawPitchRollAngles {\r\n return new YawPitchRollAngles(\r\n Angle.createDegrees(yawDegrees),\r\n Angle.createDegrees(pitchDegrees),\r\n Angle.createDegrees(rollDegrees),\r\n );\r\n }\r\n /**\r\n * Constructor for YawPitchRollAngles with angles in radians.\r\n * @param yawRadians counterclockwise rotation angle (in radians) around z\r\n * @param pitchRadians **clockwise** rotation angle (in radians) around y\r\n * @param rollRadians counterclockwise rotation angle (in radians) around x\r\n */\r\n public static createRadians(yawRadians: number, pitchRadians: number, rollRadians: number): YawPitchRollAngles {\r\n return new YawPitchRollAngles(\r\n Angle.createRadians(yawRadians),\r\n Angle.createRadians(pitchRadians),\r\n Angle.createRadians(rollRadians),\r\n );\r\n }\r\n /** Construct a `YawPitchRoll` object from an object with 3 named angles */\r\n public static fromJSON(json?: YawPitchRollProps): YawPitchRollAngles {\r\n json = json ? json : {};\r\n return new YawPitchRollAngles(\r\n Angle.fromJSON(json.yaw),\r\n Angle.fromJSON(json.pitch),\r\n Angle.fromJSON(json.roll),\r\n );\r\n }\r\n /** Populate yaw, pitch and roll fields using `Angle.fromJSON` */\r\n public setFromJSON(json?: YawPitchRollProps): void {\r\n json = json ? json : {};\r\n this.yaw = Angle.fromJSON(json.yaw);\r\n this.pitch = Angle.fromJSON(json.pitch);\r\n this.roll = Angle.fromJSON(json.roll);\r\n }\r\n /**\r\n * Convert to a JSON object of form { pitch: 20 , roll: 30 , yaw: 10 }. Angles are in degrees.\r\n * Any values that are exactly zero (with tolerance `Geometry.smallAngleRadians`) are omitted.\r\n */\r\n public toJSON(): YawPitchRollProps {\r\n const val: YawPitchRollProps = {};\r\n if (!this.pitch.isAlmostZero)\r\n val.pitch = this.pitch.toJSON();\r\n if (!this.roll.isAlmostZero)\r\n val.roll = this.roll.toJSON();\r\n if (!this.yaw.isAlmostZero)\r\n val.yaw = this.yaw.toJSON();\r\n return val;\r\n }\r\n /**\r\n * Install all rotations from `other` into `this`.\r\n * @param other YawPitchRollAngles source\r\n */\r\n public setFrom(other: YawPitchRollAngles) {\r\n this.yaw.setFrom(other.yaw);\r\n this.pitch.setFrom(other.pitch);\r\n this.roll.setFrom(other.roll);\r\n }\r\n /**\r\n * Compare angles between `this` and `other`.\r\n * * Comparisons are via `isAlmostEqualAllowPeriodShift`.\r\n * @param other YawPitchRollAngles source\r\n */\r\n public isAlmostEqual(other: YawPitchRollAngles) {\r\n return this.yaw.isAlmostEqualAllowPeriodShift(other.yaw)\r\n && this.pitch.isAlmostEqualAllowPeriodShift(other.pitch)\r\n && this.roll.isAlmostEqualAllowPeriodShift(other.roll);\r\n }\r\n /** Make a copy of this YawPitchRollAngles */\r\n public clone() {\r\n return new YawPitchRollAngles(\r\n this.yaw.clone(),\r\n this.pitch.clone(),\r\n this.roll.clone(),\r\n );\r\n }\r\n /**\r\n * Expand the angles into a (rigid rotation) matrix.\r\n * * The returned matrix is \"rigid\" (i.e., it has unit length rows and columns, and its transpose is its inverse).\r\n * * The rigid matrix is always a right handed coordinate system.\r\n * @param result optional pre-allocated `Matrix3d`\r\n */\r\n public toMatrix3d(result?: Matrix3d) {\r\n const cz = Math.cos(this.yaw.radians);\r\n const sz = Math.sin(this.yaw.radians);\r\n const cy = Math.cos(this.pitch.radians);\r\n const sy = Math.sin(this.pitch.radians);\r\n const cx = Math.cos(this.roll.radians);\r\n const sx = Math.sin(this.roll.radians);\r\n /**\r\n * The axis order is XYZ (i.e., RPY) so the rotation matrix is calculated via rZ*rY*rX where\r\n * rX, rY, and rZ are base rotation matrixes:\r\n *\r\n * const rX = Matrix3d.createRowValues(\r\n * 1, 0, 0,\r\n * 0, Math.cos(x), -Math.sin(x),\r\n * 0, Math.sin(x), Math.cos(x),\r\n * );\r\n * const rY = Matrix3d.createRowValues(\r\n * Math.cos(y), 0, Math.sin(y),\r\n * 0, 1, 0,\r\n * -Math.sin(y), 0, Math.cos(y),\r\n * );\r\n * const rZ = Matrix3d.createRowValues(\r\n * Math.cos(z), -Math.sin(z), 0,\r\n * Math.sin(z), Math.cos(z), 0,\r\n * 0, 0, 1,\r\n * );\r\n *\r\n * Then we replace sin(y) with -sin(y) because y rotation (i.e., pitch) is clockwise (alternatively, you\r\n * can use transpose of rY in the matrix multiplication to get the same result)\r\n */\r\n return Matrix3d.createRowValues(\r\n cz * cy, -(sz * cx + cz * sy * sx), (sz * sx - cz * sy * cx),\r\n sz * cy, (cz * cx - sz * sy * sx), -(cz * sx + sz * sy * cx),\r\n sy, cy * sx, cy * cx,\r\n result,\r\n );\r\n }\r\n /**\r\n * Returns true if this rotation does nothing.\r\n * * If allowPeriodShift is false, any nonzero angle is considered a non-identity\r\n * * If allowPeriodShift is true, all angles are individually allowed to be any multiple of 360 degrees.\r\n */\r\n public isIdentity(allowPeriodShift: boolean = true): boolean {\r\n if (allowPeriodShift)\r\n return Angle.isAlmostEqualRadiansAllowPeriodShift(0.0, this.yaw.radians)\r\n && Angle.isAlmostEqualRadiansAllowPeriodShift(0.0, this.pitch.radians)\r\n && Angle.isAlmostEqualRadiansAllowPeriodShift(0.0, this.roll.radians);\r\n else\r\n return Angle.isAlmostEqualRadiansNoPeriodShift(0.0, this.yaw.radians)\r\n && Angle.isAlmostEqualRadiansNoPeriodShift(0.0, this.pitch.radians)\r\n && Angle.isAlmostEqualRadiansNoPeriodShift(0.0, this.roll.radians);\r\n }\r\n /** Return the largest angle in radians */\r\n public maxAbsRadians(): number {\r\n return Geometry.maxAbsXYZ(this.yaw.radians, this.pitch.radians, this.roll.radians);\r\n }\r\n /** Return the sum of the angles in squared radians */\r\n public sumSquaredRadians(): number {\r\n return Geometry.hypotenuseSquaredXYZ(this.yaw.radians, this.pitch.radians, this.roll.radians);\r\n }\r\n /** Return the largest difference of angles (in radians) between this and other */\r\n public maxDiffRadians(other: YawPitchRollAngles): number {\r\n return Math.max(\r\n this.yaw.radians - other.yaw.radians,\r\n this.pitch.radians - other.pitch.radians,\r\n this.roll.radians - other.roll.radians,\r\n );\r\n }\r\n /** Return the largest angle in degrees. */\r\n public maxAbsDegrees(): number {\r\n return Geometry.maxAbsXYZ(this.yaw.degrees, this.pitch.degrees, this.roll.degrees);\r\n }\r\n /** Return the sum of squared angles in degrees. */\r\n public sumSquaredDegrees(): number {\r\n return Geometry.hypotenuseSquaredXYZ(this.yaw.degrees, this.pitch.degrees, this.roll.degrees);\r\n }\r\n /** Return the largest difference of angles (in degrees) between this and other */\r\n public maxDiffDegrees(other: YawPitchRollAngles): number {\r\n return Math.max(\r\n this.yaw.degrees - other.yaw.degrees,\r\n this.pitch.degrees - other.pitch.degrees,\r\n this.roll.degrees - other.roll.degrees,\r\n );\r\n }\r\n /** Return an object from a Transform as an origin and YawPitchRollAngles. */\r\n public static tryFromTransform(transform: Transform): {\r\n origin: Point3d;\r\n angles: YawPitchRollAngles | undefined;\r\n } {\r\n return {\r\n origin: Point3d.createFrom(transform.origin),\r\n angles: YawPitchRollAngles.createFromMatrix3d(transform.matrix),\r\n };\r\n }\r\n /**\r\n * Attempts to create a YawPitchRollAngles object from a Matrix3d\r\n * * This conversion fails if the matrix is not rigid (unit rows and columns, and transpose is inverse)\r\n * * In the failure case the method's return value is `undefined`.\r\n * * In the failure case, if the optional result was supplied, that result will nonetheless be filled with\r\n * a set of angles.\r\n */\r\n public static createFromMatrix3d(matrix: Matrix3d, result?: YawPitchRollAngles): YawPitchRollAngles | undefined {\r\n /**\r\n * The rotation matrix for is\r\n *\r\n * Matrix3d.createRowValues(\r\n * cz * cy, -(sz * cx + cz * sy * sx), (sz * sx - cz * sy * cx),\r\n * sz * cy, (cz * cx - sz * sy * sx), -(cz * sx + sz * sy * cx),\r\n * sy, cy * sx, cy * cx\r\n * );\r\n *\r\n * where cx = cos(x), sx = sin(x), cy = cos(y), sy = sin(y), cz = cos(z), and sz = sin(z)\r\n */\r\n const sy = matrix.at(2, 0); // sin(y)\r\n const cy = Math.sqrt(matrix.at(2, 1) * matrix.at(2, 1) + matrix.at(2, 2) * matrix.at(2, 2)); // |cos(y)|\r\n const pitchA = Angle.createAtan2(sy, cy); // with positive cosine\r\n const pitchB = Angle.createAtan2(sy, -cy); // with negative cosine\r\n const angles = result ? result : new YawPitchRollAngles();\r\n /**\r\n * If cos(y) = 0 then y = +-90 degrees so we have a gimbal lock.\r\n * This means x and z can be anything as long as their sum x + z is constant.\r\n * so we can pick z = 0 and calculate x (or pick x = 0 and calculate z).\r\n * Math details can be found\r\n * https://en.wikipedia.org/wiki/Gimbal_lock#Loss_of_a_degree_of_freedom_with_Euler_angles\r\n *\r\n * The rotation matrix for y = +-90 degrees and x = 0 becomes\r\n *\r\n * Matrix3d.createRowValues(\r\n * 0, -sz, -+cz,\r\n * 0, cz, -+sz,\r\n * +-1, 0, 0\r\n * );\r\n *\r\n * so z = atan(sz/cz) = atan(-matrix.at(0, 1), matrix.at(1, 1))\r\n */\r\n if (cy < Geometry.smallAngleRadians) {\r\n angles.yaw = Angle.createAtan2(-matrix.at(0, 1), matrix.at(1, 1));\r\n angles.pitch = pitchA; // this is an arbitrary choice. can pick pitchB instead.\r\n angles.roll = Angle.createRadians(0.0);\r\n } else {\r\n /**\r\n * positive cosine\r\n * z = atan(sz/cz) = atan(matrix.at(1, 0), matrix.at(0, 0))\r\n * x = atan(sx/cx) = atan(matrix.at(2, 1), matrix.at(2, 2))\r\n */\r\n const yawA = Angle.createAtan2(matrix.at(1, 0), matrix.at(0, 0));\r\n const rollA = Angle.createAtan2(matrix.at(2, 1), matrix.at(2, 2));\r\n // similar with negative cosine\r\n const yawB = Angle.createAtan2(-matrix.at(1, 0), -matrix.at(0, 0));\r\n const rollB = Angle.createAtan2(-matrix.at(2, 1), -matrix.at(2, 2));\r\n // create YPR\r\n const yprA = new YawPitchRollAngles(yawA, pitchA, rollA);\r\n const yprB = new YawPitchRollAngles(yawB, pitchB, rollB);\r\n // decide to pick yprA or yprB with smallest magnitude angles\r\n const absFactor = 0.95;\r\n const maxRadiansA = yprA.maxAbsRadians();\r\n const maxRadiansB = yprB.maxAbsRadians();\r\n if (maxRadiansA < absFactor * maxRadiansB) {\r\n angles.setFrom(yprA);\r\n } else if (maxRadiansB < absFactor * maxRadiansA) {\r\n angles.setFrom(yprB);\r\n } else {\r\n const sumA = yprA.sumSquaredRadians();\r\n const sumB = yprB.sumSquaredRadians();\r\n if (sumA <= sumB) {\r\n angles.setFrom(yprA);\r\n } else {\r\n angles.setFrom(yprB);\r\n }\r\n }\r\n }\r\n // sanity check\r\n const matrix1 = angles.toMatrix3d();\r\n return matrix.maxDiff(matrix1) < Geometry.smallAngleRadians ? angles : undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"YawPitchRollAngles.js","sourceRoot":"","sources":["../../../src/geometry3d/YawPitchRollAngles.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAmD;AACnD,mCAAgC;AAChC,yCAAsC;AACtC,uDAA4C;AAkB5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,kBAAkB;IAO7B;;;;;OAKG;IACH,YAAY,MAAa,aAAK,CAAC,IAAI,EAAE,EAAE,QAAe,aAAK,CAAC,IAAI,EAAE,EAAE,OAAc,aAAK,CAAC,IAAI,EAAE;QAC5F,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,qCAAqC;IAC9B,MAAM;QACX,IAAI,CAAC,GAAG,CAAC,MAAM,EA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aACF;SACF;QACD,eAAe;QACf,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,mBAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACnF,CAAC;CACF;AAjSD,gDAiSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { AngleProps, Geometry } from \"../Geometry\";\r\nimport { Angle } from \"./Angle\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n// cspell:word Tait\r\n\r\n/**\r\n * Angle properties of a `YawPitchRoll` orientation\r\n * @public\r\n */\r\nexport interface YawPitchRollProps {\r\n /** yaw field */\r\n yaw?: AngleProps;\r\n /** pitch field */\r\n pitch?: AngleProps;\r\n /** roll field */\r\n roll?: AngleProps;\r\n}\r\n\r\n/**\r\n * Three angles that determine the orientation of an object in space, sometimes referred to as [Tait–Bryan angles]\r\n * (https://en.wikipedia.org/wiki/Euler_angles).\r\n * * The matrix construction can be replicated by this logic:\r\n * * xyz coordinates have\r\n * * x forward\r\n * * y to left\r\n * * z up\r\n * * Note that this is a right handed coordinate system.\r\n * * yaw is a rotation of x towards y, i.e. around positive z (counterclockwise):\r\n * * `yawMatrix = Matrix3d.createRotationAroundAxisIndex(2, Angle.createDegrees(yawDegrees));`\r\n * * pitch is a rotation that raises x towards z, i.e. rotation around **negative y** (**clockwise**):\r\n * * `pitchMatrix = Matrix3d.createRotationAroundAxisIndex(1, Angle.createDegrees(-pitchDegrees));`\r\n * * roll is rotation of y towards z, i.e. rotation around positive x (counterclockwise):\r\n * * `rollMatrix = Matrix3d.createRotationAroundAxisIndex(0, Angle.createDegrees(rollDegrees));`\r\n * * The YPR matrix is the product\r\n * * `result = yawMatrix.multiplyMatrixMatrix(pitchMatrix.multiplyMatrixMatrix(rollMatrix));`\r\n * * Note that this is for \"column based\" matrix with vectors multiplying on the right of the matrix.\r\n * Hence a vector is first rotated by roll, then the pitch, finally yaw. So multiplication order in\r\n * the sense of AxisOrder is `RPY` (i.e., XYZ), in contrast to the familiar name `YPR`.\r\n * @public\r\n */\r\nexport class YawPitchRollAngles {\r\n /** The yaw angle: counterclockwise rotation angle around z */\r\n public yaw: Angle;\r\n /** The pitch angle: **clockwise** rotation angle around y */\r\n public pitch: Angle;\r\n /** The roll angle: counterclockwise rotation angle around x */\r\n public roll: Angle;\r\n /**\r\n * Constructor\r\n * @param yaw counterclockwise rotation angle around z\r\n * @param pitch **clockwise** rotation angle around y\r\n * @param roll counterclockwise rotation angle around x\r\n */\r\n constructor(yaw: Angle = Angle.zero(), pitch: Angle = Angle.zero(), roll: Angle = Angle.zero()) {\r\n this.yaw = yaw;\r\n this.pitch = pitch;\r\n this.roll = roll;\r\n }\r\n /** Freeze this YawPitchRollAngles */\r\n public freeze(): Readonly<this> {\r\n this.yaw.freeze();\r\n this.pitch.freeze();\r\n this.roll.freeze();\r\n return Object.freeze(this);\r\n }\r\n /**\r\n * Constructor for YawPitchRollAngles with angles in degrees.\r\n * @param yawDegrees counterclockwise rotation angle (in degrees) around z\r\n * @param pitchDegrees **clockwise** rotation angle (in degrees) around y\r\n * @param rollDegrees counterclockwise rotation angle (in degrees) around x\r\n */\r\n public static createDegrees(yawDegrees: number, pitchDegrees: number, rollDegrees: number): YawPitchRollAngles {\r\n return new YawPitchRollAngles(\r\n Angle.createDegrees(yawDegrees),\r\n Angle.createDegrees(pitchDegrees),\r\n Angle.createDegrees(rollDegrees),\r\n );\r\n }\r\n /**\r\n * Constructor for YawPitchRollAngles with angles in radians.\r\n * @param yawRadians counterclockwise rotation angle (in radians) around z\r\n * @param pitchRadians **clockwise** rotation angle (in radians) around y\r\n * @param rollRadians counterclockwise rotation angle (in radians) around x\r\n */\r\n public static createRadians(yawRadians: number, pitchRadians: number, rollRadians: number): YawPitchRollAngles {\r\n return new YawPitchRollAngles(\r\n Angle.createRadians(yawRadians),\r\n Angle.createRadians(pitchRadians),\r\n Angle.createRadians(rollRadians),\r\n );\r\n }\r\n /** Construct a `YawPitchRoll` object from an object with 3 named angles */\r\n public static fromJSON(json?: YawPitchRollProps): YawPitchRollAngles {\r\n json = json ? json : {};\r\n return new YawPitchRollAngles(\r\n Angle.fromJSON(json.yaw),\r\n Angle.fromJSON(json.pitch),\r\n Angle.fromJSON(json.roll),\r\n );\r\n }\r\n /** Populate yaw, pitch and roll fields using `Angle.fromJSON` */\r\n public setFromJSON(json?: YawPitchRollProps): void {\r\n json = json ? json : {};\r\n this.yaw = Angle.fromJSON(json.yaw);\r\n this.pitch = Angle.fromJSON(json.pitch);\r\n this.roll = Angle.fromJSON(json.roll);\r\n }\r\n /**\r\n * Convert to a JSON object of form { pitch: 20 , roll: 30 , yaw: 10 }. Angles are in degrees.\r\n * Any values that are exactly zero (with tolerance `Geometry.smallAngleRadians`) are omitted.\r\n */\r\n public toJSON(): YawPitchRollProps {\r\n const val: YawPitchRollProps = {};\r\n if (!this.pitch.isAlmostZero)\r\n val.pitch = this.pitch.toJSON();\r\n if (!this.roll.isAlmostZero)\r\n val.roll = this.roll.toJSON();\r\n if (!this.yaw.isAlmostZero)\r\n val.yaw = this.yaw.toJSON();\r\n return val;\r\n }\r\n /**\r\n * Install all rotations from `other` into `this`.\r\n * @param other YawPitchRollAngles source\r\n */\r\n public setFrom(other: YawPitchRollAngles) {\r\n this.yaw.setFrom(other.yaw);\r\n this.pitch.setFrom(other.pitch);\r\n this.roll.setFrom(other.roll);\r\n }\r\n /**\r\n * Compare angles between `this` and `other`.\r\n * * Comparisons are via `isAlmostEqualAllowPeriodShift`.\r\n * @param other YawPitchRollAngles source\r\n */\r\n public isAlmostEqual(other: YawPitchRollAngles) {\r\n return this.yaw.isAlmostEqualAllowPeriodShift(other.yaw)\r\n && this.pitch.isAlmostEqualAllowPeriodShift(other.pitch)\r\n && this.roll.isAlmostEqualAllowPeriodShift(other.roll);\r\n }\r\n /** Make a copy of this YawPitchRollAngles */\r\n public clone() {\r\n return new YawPitchRollAngles(\r\n this.yaw.clone(),\r\n this.pitch.clone(),\r\n this.roll.clone(),\r\n );\r\n }\r\n /**\r\n * Expand the angles into a (rigid rotation) matrix.\r\n * * The returned matrix is \"rigid\" (i.e., it has unit length rows and columns, and its transpose is its inverse).\r\n * * The rigid matrix is always a right handed coordinate system.\r\n * @param result optional pre-allocated `Matrix3d`\r\n */\r\n public toMatrix3d(result?: Matrix3d) {\r\n const cz = Math.cos(this.yaw.radians);\r\n const sz = Math.sin(this.yaw.radians);\r\n const cy = Math.cos(this.pitch.radians);\r\n const sy = Math.sin(this.pitch.radians);\r\n const cx = Math.cos(this.roll.radians);\r\n const sx = Math.sin(this.roll.radians);\r\n /**\r\n * The axis order is XYZ (i.e., RPY) so the rotation matrix is calculated via rZ*rY*rX where\r\n * rX, rY, and rZ are base rotation matrixes:\r\n *\r\n * const rX = Matrix3d.createRowValues(\r\n * 1, 0, 0,\r\n * 0, Math.cos(x), -Math.sin(x),\r\n * 0, Math.sin(x), Math.cos(x),\r\n * );\r\n * const rY = Matrix3d.createRowValues(\r\n * Math.cos(y), 0, Math.sin(y),\r\n * 0, 1, 0,\r\n * -Math.sin(y), 0, Math.cos(y),\r\n * );\r\n * const rZ = Matrix3d.createRowValues(\r\n * Math.cos(z), -Math.sin(z), 0,\r\n * Math.sin(z), Math.cos(z), 0,\r\n * 0, 0, 1,\r\n * );\r\n *\r\n * Then we replace sin(y) with -sin(y) because y rotation (i.e., pitch) is clockwise (alternatively, you\r\n * can use transpose of rY in the matrix multiplication to get the same result)\r\n */\r\n return Matrix3d.createRowValues(\r\n cz * cy, -(sz * cx + cz * sy * sx), (sz * sx - cz * sy * cx),\r\n sz * cy, (cz * cx - sz * sy * sx), -(cz * sx + sz * sy * cx),\r\n sy, cy * sx, cy * cx,\r\n result,\r\n );\r\n }\r\n /**\r\n * Returns true if this rotation does nothing.\r\n * * If allowPeriodShift is false, any nonzero angle is considered a non-identity\r\n * * If allowPeriodShift is true, all angles are individually allowed to be any multiple of 360 degrees.\r\n */\r\n public isIdentity(allowPeriodShift: boolean = true): boolean {\r\n if (allowPeriodShift)\r\n return Angle.isAlmostEqualRadiansAllowPeriodShift(0.0, this.yaw.radians)\r\n && Angle.isAlmostEqualRadiansAllowPeriodShift(0.0, this.pitch.radians)\r\n && Angle.isAlmostEqualRadiansAllowPeriodShift(0.0, this.roll.radians);\r\n else\r\n return Angle.isAlmostEqualRadiansNoPeriodShift(0.0, this.yaw.radians)\r\n && Angle.isAlmostEqualRadiansNoPeriodShift(0.0, this.pitch.radians)\r\n && Angle.isAlmostEqualRadiansNoPeriodShift(0.0, this.roll.radians);\r\n }\r\n /** Return the largest angle in radians */\r\n public maxAbsRadians(): number {\r\n return Geometry.maxAbsXYZ(this.yaw.radians, this.pitch.radians, this.roll.radians);\r\n }\r\n /** Return the sum of the angles in squared radians */\r\n public sumSquaredRadians(): number {\r\n return Geometry.hypotenuseSquaredXYZ(this.yaw.radians, this.pitch.radians, this.roll.radians);\r\n }\r\n /** Return the largest difference of angles (in radians) between this and other */\r\n public maxDiffRadians(other: YawPitchRollAngles): number {\r\n return Math.max(\r\n this.yaw.radians - other.yaw.radians,\r\n this.pitch.radians - other.pitch.radians,\r\n this.roll.radians - other.roll.radians,\r\n );\r\n }\r\n /** Return the largest angle in degrees. */\r\n public maxAbsDegrees(): number {\r\n return Geometry.maxAbsXYZ(this.yaw.degrees, this.pitch.degrees, this.roll.degrees);\r\n }\r\n /** Return the sum of squared angles in degrees. */\r\n public sumSquaredDegrees(): number {\r\n return Geometry.hypotenuseSquaredXYZ(this.yaw.degrees, this.pitch.degrees, this.roll.degrees);\r\n }\r\n /** Return the largest difference of angles (in degrees) between this and other */\r\n public maxDiffDegrees(other: YawPitchRollAngles): number {\r\n return Math.max(\r\n this.yaw.degrees - other.yaw.degrees,\r\n this.pitch.degrees - other.pitch.degrees,\r\n this.roll.degrees - other.roll.degrees,\r\n );\r\n }\r\n /** Return an object from a Transform as an origin and YawPitchRollAngles. */\r\n public static tryFromTransform(transform: Transform): {\r\n origin: Point3d;\r\n angles: YawPitchRollAngles | undefined;\r\n } {\r\n return {\r\n origin: Point3d.createFrom(transform.origin),\r\n angles: YawPitchRollAngles.createFromMatrix3d(transform.matrix),\r\n };\r\n }\r\n /**\r\n * Attempts to create a YawPitchRollAngles object from a Matrix3d\r\n * * This conversion fails if the matrix is not rigid (unit rows and columns, and transpose is inverse)\r\n * * In the failure case the method's return value is `undefined`.\r\n * * In the failure case, if the optional result was supplied, that result will nonetheless be filled with\r\n * a set of angles.\r\n */\r\n public static createFromMatrix3d(matrix: Matrix3d, result?: YawPitchRollAngles): YawPitchRollAngles | undefined {\r\n /**\r\n * The rotation matrix form is\r\n *\r\n * Matrix3d.createRowValues(\r\n * cz * cy, -(sz * cx + cz * sy * sx), (sz * sx - cz * sy * cx),\r\n * sz * cy, (cz * cx - sz * sy * sx), -(cz * sx + sz * sy * cx),\r\n * sy, cy * sx, cy * cx\r\n * );\r\n *\r\n * where cx = cos(x), sx = sin(x), cy = cos(y), sy = sin(y), cz = cos(z), and sz = sin(z)\r\n */\r\n const sy = matrix.at(2, 0); // sin(y)\r\n const cy = Math.sqrt(matrix.at(2, 1) * matrix.at(2, 1) + matrix.at(2, 2) * matrix.at(2, 2)); // |cos(y)|\r\n const pitchA = Angle.createAtan2(sy, cy); // with positive cosine\r\n const pitchB = Angle.createAtan2(sy, -cy); // with negative cosine\r\n const angles = result ? result : new YawPitchRollAngles();\r\n /**\r\n * If cos(y) = 0 then y = +-90 degrees so we have a gimbal lock.\r\n * This means x and z can be anything as long as their sum x + z is constant.\r\n * so we can pick z = 0 and calculate x (or pick x = 0 and calculate z).\r\n * Math details can be found\r\n * https://en.wikipedia.org/wiki/Gimbal_lock#Loss_of_a_degree_of_freedom_with_Euler_angles\r\n *\r\n * The rotation matrix for y = +-90 degrees and x = 0 becomes\r\n *\r\n * Matrix3d.createRowValues(\r\n * 0, -sz, -+cz,\r\n * 0, cz, -+sz,\r\n * +-1, 0, 0\r\n * );\r\n *\r\n * so z = atan(sz/cz) = atan(-matrix.at(0, 1), matrix.at(1, 1))\r\n */\r\n if (cy < Geometry.smallAngleRadians) {\r\n angles.yaw = Angle.createAtan2(-matrix.at(0, 1), matrix.at(1, 1));\r\n angles.pitch = pitchA; // this is an arbitrary choice. can pick pitchB instead.\r\n angles.roll = Angle.createRadians(0.0);\r\n } else {\r\n /**\r\n * positive cosine\r\n * z = atan(sz/cz) = atan(matrix.at(1, 0), matrix.at(0, 0))\r\n * x = atan(sx/cx) = atan(matrix.at(2, 1), matrix.at(2, 2))\r\n */\r\n const yawA = Angle.createAtan2(matrix.at(1, 0), matrix.at(0, 0));\r\n const rollA = Angle.createAtan2(matrix.at(2, 1), matrix.at(2, 2));\r\n // similar with negative cosine\r\n const yawB = Angle.createAtan2(-matrix.at(1, 0), -matrix.at(0, 0));\r\n const rollB = Angle.createAtan2(-matrix.at(2, 1), -matrix.at(2, 2));\r\n // create YPR\r\n const yprA = new YawPitchRollAngles(yawA, pitchA, rollA);\r\n const yprB = new YawPitchRollAngles(yawB, pitchB, rollB);\r\n // decide to pick yprA or yprB with smallest magnitude angles\r\n const absFactor = 0.95;\r\n const maxRadiansA = yprA.maxAbsRadians();\r\n const maxRadiansB = yprB.maxAbsRadians();\r\n if (maxRadiansA < absFactor * maxRadiansB) {\r\n angles.setFrom(yprA);\r\n } else if (maxRadiansB < absFactor * maxRadiansA) {\r\n angles.setFrom(yprB);\r\n } else {\r\n const sumA = yprA.sumSquaredRadians();\r\n const sumB = yprB.sumSquaredRadians();\r\n if (sumA <= sumB) {\r\n angles.setFrom(yprA);\r\n } else {\r\n angles.setFrom(yprB);\r\n }\r\n }\r\n }\r\n // sanity check\r\n const matrix1 = angles.toMatrix3d();\r\n return matrix.maxDiff(matrix1) < Geometry.smallAngleRadians ? angles : undefined;\r\n }\r\n}\r\n"]}
|
|
@@ -274,7 +274,7 @@ export declare class AnalyticRoots {
|
|
|
274
274
|
/**
|
|
275
275
|
* * Solve the simultaneous equations in variables`c` and`s`:
|
|
276
276
|
* * A line: `alpha + beta*c + gamma*s = 0`
|
|
277
|
-
* * The unit circle
|
|
277
|
+
* * The unit circle `c*c + s*s = 1`
|
|
278
278
|
* * Solution values are returned as 0, 1, or 2(c, s) pairs
|
|
279
279
|
* * Return value indicates one of these solution states:
|
|
280
280
|
* * -2 -- all coefficients identically 0. The entire c, s plane-- and therefore the entire unit circle-- is a solution.
|
|
@@ -297,7 +297,7 @@ export declare class AnalyticRoots {
|
|
|
297
297
|
static appendImplicitLineUnitCircleIntersections(alpha: number, beta: number, gamma: number, cosValues: OptionalGrowableFloat64Array, sinValues: OptionalGrowableFloat64Array, radiansValues: OptionalGrowableFloat64Array, relTol?: number): number;
|
|
298
298
|
}
|
|
299
299
|
/**
|
|
300
|
-
*
|
|
300
|
+
* Manipulations of polynomials with where `coff[i]` multiplies x^i
|
|
301
301
|
* @internal
|
|
302
302
|
*/
|
|
303
303
|
export declare class PowerPolynomial {
|