@itwin/core-geometry 4.1.0-dev.68 → 4.1.0-dev.69
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/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.d.ts +1 -1
- package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.js +2 -2
- package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.js +1 -1
- package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
- package/lib/cjs/bspline/BezierCurveBase.d.ts +1 -1
- package/lib/cjs/bspline/BezierCurveBase.d.ts.map +1 -1
- package/lib/cjs/bspline/BezierCurveBase.js +2 -2
- package/lib/cjs/bspline/BezierCurveBase.js.map +1 -1
- package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/core-geometry.d.ts +3 -2
- package/lib/cjs/core-geometry.d.ts.map +1 -1
- package/lib/cjs/core-geometry.js +4 -5
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts +1 -1
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +2 -2
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +2 -2
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +2 -2
- package/lib/cjs/curve/CurveCollection.js +2 -2
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveCurve.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurveOps.d.ts +77 -0
- package/lib/cjs/curve/CurveOps.d.ts.map +1 -0
- package/lib/cjs/curve/CurveOps.js +160 -0
- package/lib/cjs/curve/CurveOps.js.map +1 -0
- package/lib/cjs/curve/CurvePrimitive.d.ts +13 -13
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/GeometryQuery.d.ts +2 -2
- package/lib/cjs/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/cjs/curve/GeometryQuery.js +2 -2
- package/lib/cjs/curve/GeometryQuery.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +2 -2
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +1 -1
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +2 -2
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/Loop.js.map +1 -1
- package/lib/cjs/curve/OffsetOptions.d.ts +97 -0
- package/lib/cjs/curve/OffsetOptions.d.ts.map +1 -0
- package/lib/cjs/curve/OffsetOptions.js +166 -0
- package/lib/cjs/curve/OffsetOptions.js.map +1 -0
- package/lib/cjs/curve/ProxyCurve.d.ts +1 -1
- package/lib/cjs/curve/ProxyCurve.d.ts.map +1 -1
- package/lib/cjs/curve/ProxyCurve.js.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountMap.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +10 -13
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +16 -17
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +2 -2
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/StrokeOptions.js.map +1 -1
- package/lib/cjs/curve/{ChainCollectorContext.d.ts → internalContexts/ChainCollectorContext.d.ts} +4 -4
- package/lib/cjs/curve/internalContexts/ChainCollectorContext.d.ts.map +1 -0
- package/lib/cjs/curve/{ChainCollectorContext.js → internalContexts/ChainCollectorContext.js} +4 -4
- package/lib/cjs/curve/internalContexts/ChainCollectorContext.js.map +1 -0
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +59 -74
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js +130 -223
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts +6 -100
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js +12 -167
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.js +2 -2
- package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/XYCurveEvaluator.js +1 -1
- package/lib/cjs/curve/spiral/XYCurveEvaluator.js.map +1 -1
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
- package/lib/cjs/geometry3d/BilinearPatch.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableBlockedArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableBlockedArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.js +1 -1
- package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +5 -5
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3d.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts +8 -9
- package/lib/cjs/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point2dVector2d.js +9 -10
- package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +4 -4
- package/lib/cjs/geometry3d/Point3dVector3d.js +5 -5
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +5 -5
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +1 -2
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +2 -3
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/Range.js.map +1 -1
- package/lib/cjs/geometry3d/Ray2d.d.ts +69 -0
- package/lib/cjs/geometry3d/Ray2d.d.ts.map +1 -0
- package/lib/cjs/geometry3d/Ray2d.js +146 -0
- package/lib/cjs/geometry3d/Ray2d.js.map +1 -0
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +3 -3
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/cjs/numerics/ConvexPolygon2d.d.ts +7 -49
- package/lib/cjs/numerics/ConvexPolygon2d.d.ts.map +1 -1
- package/lib/cjs/numerics/ConvexPolygon2d.js +16 -107
- package/lib/cjs/numerics/ConvexPolygon2d.js.map +1 -1
- package/lib/cjs/numerics/Newton.js.map +1 -1
- package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/Polynomials.js +0 -2
- package/lib/cjs/numerics/Polynomials.js.map +1 -1
- package/lib/cjs/numerics/Quadrature.js +5 -5
- package/lib/cjs/numerics/Quadrature.js.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.js +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +2 -2
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +10 -7
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +13 -12
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/polyface/TaggedNumericData.js +1 -1
- package/lib/cjs/polyface/TaggedNumericData.js.map +1 -1
- package/lib/cjs/polyface/multiclip/BuildAverageNormalsContext.js +2 -2
- package/lib/cjs/polyface/multiclip/BuildAverageNormalsContext.js.map +1 -1
- package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -1
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +2 -7
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +2 -7
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/topology/ChainMerge.js +1 -1
- package/lib/cjs/topology/ChainMerge.js.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSearch.js +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSpineContext.js +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSpineContext.js.map +1 -1
- package/lib/cjs/topology/HalfEdgePriorityQueue.d.ts.map +1 -1
- package/lib/cjs/topology/HalfEdgePriorityQueue.js +1 -1
- package/lib/cjs/topology/HalfEdgePriorityQueue.js.map +1 -1
- package/lib/cjs/topology/RegularizeFace.js +3 -3
- package/lib/cjs/topology/RegularizeFace.js.map +1 -1
- package/lib/cjs/topology/Triangulation.js +1 -1
- package/lib/cjs/topology/Triangulation.js.map +1 -1
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/bspline/BSplineCurve.d.ts +1 -1
- package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurve.js +1 -1
- package/lib/esm/bspline/BSplineCurve.js.map +1 -1
- package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineSurface.js +1 -1
- package/lib/esm/bspline/BSplineSurface.js.map +1 -1
- package/lib/esm/bspline/BezierCurveBase.d.ts +1 -1
- package/lib/esm/bspline/BezierCurveBase.d.ts.map +1 -1
- package/lib/esm/bspline/BezierCurveBase.js +1 -1
- package/lib/esm/bspline/BezierCurveBase.js.map +1 -1
- package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/core-geometry.d.ts +3 -2
- package/lib/esm/core-geometry.d.ts.map +1 -1
- package/lib/esm/core-geometry.js +3 -3
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +1 -1
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +1 -1
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +2 -2
- package/lib/esm/curve/CurveCollection.js +2 -2
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveCurve.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurveOps.d.ts +77 -0
- package/lib/esm/curve/CurveOps.d.ts.map +1 -0
- package/lib/esm/curve/CurveOps.js +156 -0
- package/lib/esm/curve/CurveOps.js.map +1 -0
- package/lib/esm/curve/CurvePrimitive.d.ts +13 -13
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/GeometryQuery.d.ts +2 -2
- package/lib/esm/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/esm/curve/GeometryQuery.js +2 -2
- package/lib/esm/curve/GeometryQuery.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +1 -1
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +1 -1
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +1 -1
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/Loop.js.map +1 -1
- package/lib/esm/curve/OffsetOptions.d.ts +97 -0
- package/lib/esm/curve/OffsetOptions.d.ts.map +1 -0
- package/lib/esm/curve/OffsetOptions.js +161 -0
- package/lib/esm/curve/OffsetOptions.js.map +1 -0
- package/lib/esm/curve/ProxyCurve.d.ts +1 -1
- package/lib/esm/curve/ProxyCurve.d.ts.map +1 -1
- package/lib/esm/curve/ProxyCurve.js.map +1 -1
- package/lib/esm/curve/Query/StrokeCountMap.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +10 -13
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +17 -18
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +2 -2
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/StrokeOptions.js.map +1 -1
- package/lib/esm/curve/{ChainCollectorContext.d.ts → internalContexts/ChainCollectorContext.d.ts} +4 -4
- package/lib/esm/curve/internalContexts/ChainCollectorContext.d.ts.map +1 -0
- package/lib/esm/curve/{ChainCollectorContext.js → internalContexts/ChainCollectorContext.js} +4 -4
- package/lib/esm/curve/internalContexts/ChainCollectorContext.js.map +1 -0
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +59 -74
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js +129 -221
- package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts +6 -100
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.js +9 -162
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.js +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/XYCurveEvaluator.js +1 -1
- package/lib/esm/curve/spiral/XYCurveEvaluator.js.map +1 -1
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
- package/lib/esm/geometry3d/BilinearPatch.js.map +1 -1
- package/lib/esm/geometry3d/GrowableBlockedArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableBlockedArray.js +1 -1
- package/lib/esm/geometry3d/GrowableBlockedArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.js +1 -1
- package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +5 -5
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
- package/lib/esm/geometry3d/Plane3d.js.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.d.ts +8 -9
- package/lib/esm/geometry3d/Point2dVector2d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point2dVector2d.js +9 -10
- package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +4 -4
- package/lib/esm/geometry3d/Point3dVector3d.js +5 -5
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +5 -5
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +1 -2
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +2 -3
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/Range.js.map +1 -1
- package/lib/esm/geometry3d/Ray2d.d.ts +69 -0
- package/lib/esm/geometry3d/Ray2d.d.ts.map +1 -0
- package/lib/esm/geometry3d/Ray2d.js +142 -0
- package/lib/esm/geometry3d/Ray2d.js.map +1 -0
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.js +3 -3
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/esm/numerics/ConvexPolygon2d.d.ts +7 -49
- package/lib/esm/numerics/ConvexPolygon2d.d.ts.map +1 -1
- package/lib/esm/numerics/ConvexPolygon2d.js +14 -104
- package/lib/esm/numerics/ConvexPolygon2d.js.map +1 -1
- package/lib/esm/numerics/Newton.js.map +1 -1
- package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
- package/lib/esm/numerics/Polynomials.js +0 -2
- package/lib/esm/numerics/Polynomials.js.map +1 -1
- package/lib/esm/numerics/Quadrature.js +5 -5
- package/lib/esm/numerics/Quadrature.js.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.js +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +2 -2
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +10 -7
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +14 -13
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/polyface/TaggedNumericData.js +1 -1
- package/lib/esm/polyface/TaggedNumericData.js.map +1 -1
- package/lib/esm/polyface/multiclip/BuildAverageNormalsContext.js +2 -2
- package/lib/esm/polyface/multiclip/BuildAverageNormalsContext.js.map +1 -1
- package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -1
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
- package/lib/esm/serialization/BGFBWriter.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +2 -7
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +2 -7
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/topology/ChainMerge.js +1 -1
- package/lib/esm/topology/ChainMerge.js.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphSearch.js +1 -1
- package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphSpineContext.js +1 -1
- package/lib/esm/topology/HalfEdgeGraphSpineContext.js.map +1 -1
- package/lib/esm/topology/HalfEdgePriorityQueue.d.ts.map +1 -1
- package/lib/esm/topology/HalfEdgePriorityQueue.js +1 -1
- package/lib/esm/topology/HalfEdgePriorityQueue.js.map +1 -1
- package/lib/esm/topology/RegularizeFace.js +3 -3
- package/lib/esm/topology/RegularizeFace.js.map +1 -1
- package/lib/esm/topology/Triangulation.js +1 -1
- package/lib/esm/topology/Triangulation.js.map +1 -1
- package/package.json +5 -16
- package/lib/cjs/curve/ChainCollectorContext.d.ts.map +0 -1
- package/lib/cjs/curve/ChainCollectorContext.js.map +0 -1
- package/lib/esm/curve/ChainCollectorContext.d.ts.map +0 -1
- package/lib/esm/curve/ChainCollectorContext.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarycentricTriangle.js","sourceRoot":"","sources":["../../../src/geometry3d/BarycentricTriangle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAE7C,0CAAwD;AACxD,yCAAsC;AACtC,uDAAsD;AACtD,mCAAgC;AAGhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,sBAAsB;IAiBjC;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IACD,4DAA4D;IACrD,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,MAA+B;QAClD,IAAI,SAAS,KAAK,MAAM;YACtB,MAAM,GAAG,IAAI,sBAAsB,EAAE,CAAC;;YAEtC,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;OAGG;IACI,gBAAg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K,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;IACD,4DAA4D;IACrD,aAAa,CAAC,KAA0B,EAAE,GAAY;QAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eACpD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eAClD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF;AA/hBD,kDA+hBC","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/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\n\r\nimport { Geometry, PolygonLocation } from \"../Geometry\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n/**\r\n * Carries data about a location in the plane of a triangle.\r\n * * Each instance carries both world and barycentric coordinates for the point, and provides query\r\n * services on the latter.\r\n * * No tolerance is used when querying barycentric coordinates (e.g., `isInsideOrOn`, `classify`). Use\r\n * [[BarycentricTriangle.snapLocationToEdge]] to adjust the barycentric coordinates to a triangle edge\r\n * if they lie within a distance or parametric tolerance.\r\n *\r\n * Properties of the barycentric coordinates `(b0, b1, b2)` of a point `p` in the plane of a triangle\r\n * `T` with vertices `v0, v1, v2`:\r\n * * `1 = b0 + b1 + b2`\r\n * * `p = b0 * v0 + b1 * v1 + b2 * v2`\r\n * * If T is spanned by the vectors `U = v1 - v0` and `V = v2 - v0`, then the vector `P = p - v0` can\r\n * be written `P = b1 * U + b2 * V`.\r\n * * The coordinates are all nonnegative if and only if `p` is inside or on `T`.\r\n * * Exactly one coordinate is zero if and only if `p` lies on an (infinitely extended) edge of `T`.\r\n * * Exactly two coordinates are zero if and only if `p` coincides with a vertex of `T`.\r\n * * Note that if `p` can be written as a linear combination of the vertices of `T` using scales that do\r\n * NOT sum to 1, then `p` is not coplanar with `T`\r\n * @public\r\n */\r\nexport class TriangleLocationDetail {\r\n /** The Cartesian coordinates of the point p. */\r\n public world: Point3d;\r\n /** The barycentric coordinates of p with respect to the triangle. Assumed to sum to one. */\r\n public local: Point3d;\r\n /** Application-specific number */\r\n public a: number;\r\n /** Index of the triangle vertex at the start of the closest edge to p. */\r\n public closestEdgeIndex: number;\r\n /**\r\n * The parameter f along the closest edge to p of its projection q.\r\n * * We have q = v_i + f * (v_j - v_i) where i = closestEdgeIndex and j = (i + 1) % 3 are the indices\r\n * of the start vertex v_i and end vertex v_j of the closest edge to p.\r\n * * Note that 0 <= f <= 1.\r\n */\r\n public closestEdgeParam: number;\r\n\r\n private constructor() {\r\n this.world = new Point3d();\r\n this.local = new Point3d();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /** Invalidate this detail (set all attributes to zero) . */\r\n public invalidate() {\r\n this.world.setZero();\r\n this.local.setZero();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /**\r\n * Create an invalid detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(result?: TriangleLocationDetail): TriangleLocationDetail {\r\n if (undefined === result)\r\n result = new TriangleLocationDetail();\r\n else\r\n result.invalidate();\r\n return result;\r\n }\r\n /**\r\n * Set the instance contents from the `other` detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: TriangleLocationDetail) {\r\n this.world.setFrom(other.world);\r\n this.local.setFrom(other.local);\r\n this.a = other.a;\r\n this.closestEdgeIndex = other.closestEdgeIndex;\r\n this.closestEdgeParam = other.closestEdgeParam;\r\n }\r\n /** Whether this detail is invalid. */\r\n public get isValid(): boolean {\r\n return !this.local.isZero;\r\n }\r\n /**\r\n * Queries the barycentric coordinates to determine whether this instance specifies a location inside or\r\n * on the triangle.\r\n * @see classify\r\n */\r\n public get isInsideOrOn(): boolean {\r\n return this.isValid && this.local.x >= 0.0 && this.local.y >= 0.0 && this.local.z >= 0.0;\r\n }\r\n /**\r\n * Queries this detail to classify the location of this instance with respect to the triangle.\r\n * @returns location code\r\n * @see isInsideOrOn\r\n */\r\n public get classify(): PolygonLocation {\r\n if (!this.isValid)\r\n return PolygonLocation.Unknown;\r\n if (this.isInsideOrOn) {\r\n let numZero = 0;\r\n if (Math.abs(this.local.x) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.y) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.z) === 0.0)\r\n ++numZero;\r\n if (2 === numZero)\r\n return PolygonLocation.OnPolygonVertex;\r\n if (1 === numZero)\r\n return PolygonLocation.OnPolygonEdgeInterior;\r\n return PolygonLocation.InsidePolygonProjectsToEdgeInterior;\r\n }\r\n return (this.closestEdgeParam === 0.0) ?\r\n PolygonLocation.OutsidePolygonProjectsToVertex :\r\n PolygonLocation.OutsidePolygonProjectsToEdgeInterior;\r\n }\r\n}\r\n\r\n/**\r\n * 3 points defining a triangle to be evaluated with barycentric coordinates.\r\n * @public\r\n */\r\nexport class BarycentricTriangle {\r\n /** Array of 3 point coordinates for the triangle. */\r\n public points: Point3d[];\r\n /** Edge length squared cache, indexed by opposite vertex index */\r\n protected edgeLength2: number[];\r\n // private attributes\r\n private static _workPoint?: Point3d;\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workRay?: Ray3d;\r\n private static _workMatrix?: Matrix3d;\r\n /**\r\n * Constructor.\r\n * * Point references are CAPTURED\r\n */\r\n protected constructor(point0: Point3d, point1: Point3d, point2: Point3d) {\r\n this.points = [];\r\n this.points.push(point0);\r\n this.points.push(point1);\r\n this.points.push(point2);\r\n this.edgeLength2 = [];\r\n this.edgeLength2.push(point1.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point1));\r\n }\r\n /**\r\n * Copy contents of (not pointers to) the given points. A vertex is zeroed if its corresponding input point\r\n * is undefined.\r\n */\r\n public set(point0: Point3d | undefined, point1: Point3d | undefined, point2: Point3d | undefined) {\r\n this.points[0].setFromPoint3d(point0);\r\n this.points[1].setFromPoint3d(point1);\r\n this.points[2].setFromPoint3d(point2);\r\n this.edgeLength2[0] = this.points[1].distanceSquared(this.points[2]);\r\n this.edgeLength2[1] = this.points[0].distanceSquared(this.points[2]);\r\n this.edgeLength2[2] = this.points[0].distanceSquared(this.points[1]);\r\n }\r\n /** Copy all values from `other` */\r\n public setFrom(other: BarycentricTriangle) {\r\n for (let i = 0; i < 3; ++i) {\r\n this.points[i].setFromPoint3d(other.points[i]);\r\n this.edgeLength2[i] = other.edgeLength2[i];\r\n }\r\n }\r\n /**\r\n * Create a `BarycentricTriangle` with coordinates given by enumerated x,y,z of the 3 points.\r\n * @param result optional pre-allocated triangle.\r\n */\r\n public static createXYZXYZXYZ(\r\n x0: number, y0: number, z0: number,\r\n x1: number, y1: number, z1: number,\r\n x2: number, y2: number, z2: number,\r\n result?: BarycentricTriangle\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(Point3d.create(x0, y0, z0), Point3d.create(x1, y1, z1), Point3d.create(x2, y2, z2));\r\n result.points[0].set(x0, y0, z0);\r\n result.points[1].set(x1, y1, z1);\r\n result.points[2].set(x2, y2, z2);\r\n return result;\r\n }\r\n /** Create a triangle with coordinates cloned from given points. */\r\n public static create(\r\n point0: Point3d, point1: Point3d, point2: Point3d, result?: BarycentricTriangle\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(point0.clone(), point1.clone(), point2.clone());\r\n result.set(point0, point1, point2);\r\n return result;\r\n }\r\n /** Return a new `BarycentricTriangle` with the same coordinates. */\r\n public clone(result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(this.points[0], this.points[1], this.points[2], result);\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(\r\n transform.multiplyPoint3d(this.points[0], result?.points[0]),\r\n transform.multiplyPoint3d(this.points[1], result?.points[1]),\r\n transform.multiplyPoint3d(this.points[2], result?.points[2]),\r\n result\r\n );\r\n }\r\n /** Return the area of the triangle. */\r\n public get area(): number {\r\n // The magnitude of the cross product A × B is the area of the parallelogram spanned by A and B.\r\n return 0.5 * this.points[0].crossProductToPointsMagnitude(this.points[1], this.points[2]);\r\n }\r\n /**\r\n * Compute squared length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLengthSquared(oppositeVertexIndex: number): number {\r\n return this.edgeLength2[Geometry.cyclic3dAxis(oppositeVertexIndex)];\r\n }\r\n /**\r\n * Compute length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLength(oppositeVertexIndex: number): number {\r\n return Math.sqrt(this.edgeLengthSquared(oppositeVertexIndex));\r\n }\r\n /** Return area divided by sum of squared lengths. */\r\n public get aspectRatio(): number {\r\n return Geometry.safeDivideFraction(\r\n this.area, this.edgeLengthSquared(0) + this.edgeLengthSquared(1) + this.edgeLengthSquared(2), 0\r\n );\r\n }\r\n /** Return the perimeter of the triangle. */\r\n public get perimeter(): number {\r\n return this.edgeLength(0) + this.edgeLength(1) + this.edgeLength(2);\r\n }\r\n /**\r\n * Return the unit normal of the triangle.\r\n * @param result optional pre-allocated vector to fill and return.\r\n * @returns unit normal, or undefined if cross product length is too small.\r\n */\r\n public normal(result?: Vector3d): Vector3d | undefined {\r\n const cross = this.points[0].crossProductToPoints(this.points[1], this.points[2], result);\r\n if (cross.tryNormalizeInPlace())\r\n return cross;\r\n return undefined;\r\n }\r\n /**\r\n * Sum the triangle points with given scales.\r\n * * If the scales sum to 1, they are barycentric coordinates, and hence the result point is in the plane of\r\n * the triangle. If all coordinates are non-negative then the result point is inside the triangle.\r\n * * If the scales do not sum to 1, the point is inside the triangle scaled (by the scale sum) from the origin.\r\n * @param b0 scale to apply to vertex 0\r\n * @param b1 scale to apply to vertex 1\r\n * @param b2 scale to apply to vertex 2\r\n * @param result optional pre-allocated point to fill and return\r\n * @return linear combination of the vertices of this triangle\r\n * @see [[pointToFraction]]\r\n */\r\n public fractionToPoint(b0: number, b1: number, b2: number, result?: Point3d): Point3d {\r\n // p = b0 * v0 + b1 * v1 + b2 * v2\r\n return Point3d.createAdd3Scaled(this.points[0], b0, this.points[1], b1, this.points[2], b2, result);\r\n }\r\n /**\r\n * Compute the projection of the given `point` onto the plane of this triangle.\r\n * @param point point p to project\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the projection point `P = d.world`:\r\n * * `d.isValid` returns true if and only if `this.normal()` is defined.\r\n * * `d.classify` can be used to determine where P lies with respect to the triangle.\r\n * * `d.a` is the signed projection distance: `P = p + a * this.normal()`.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BarycentricTriangle\r\n * @see [[fractionToPoint]]\r\n */\r\n public pointToFraction(point: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n const normal = BarycentricTriangle._workVector0 = this.normal(BarycentricTriangle._workVector0);\r\n if (undefined === normal)\r\n return TriangleLocationDetail.create(result);\r\n const ray = BarycentricTriangle._workRay = Ray3d.create(point, normal, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(ray, result); // intersectRay3d is free to use workVector0\r\n }\r\n /** Convert from opposite-vertex to start-vertex edge indexing. */\r\n public static edgeOppositeVertexIndexToStartVertexIndex(edgeIndex: number): number {\r\n return Geometry.cyclic3dAxis(edgeIndex + 1);\r\n }\r\n /** Convert from start-vertex to opposite-vertex edge indexing. */\r\n public static edgeStartVertexIndexToOppositeVertexIndex(startVertexIndex: number): number {\r\n return Geometry.cyclic3dAxis(startVertexIndex - 1);\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle but not on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is strictly inside the triangle.\r\n */\r\n public static isInsideTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 > 0 && b1 > 0 && b2 > 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle or on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is inside or on the triangle.\r\n */\r\n public static isInsideOrOnTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 >= 0 && b1 >= 0 && b2 >= 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside an edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i < 0 and b_j >= 0, and b_k >= 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondEdge(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives smaller regions)\r\n if (b0 < 0 && b1 >= 0 && b2 >= 0)\r\n return 0;\r\n if (b0 >= 0 && b1 < 0 && b2 >= 0)\r\n return 1;\r\n if (b0 >= 0 && b1 >= 0 && b2 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_j < 0 and b_k < 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondVertex(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives larger regions)\r\n if (b1 < 0 && b2 < 0)\r\n return 0;\r\n if (b0 < 0 && b2 < 0)\r\n return 1;\r\n if (b0 < 0 && b1 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_i = 1 and b_j = b_k = 0. Otherwise, returns -1.\r\n */\r\n private static isOnVertex(b0: number, b1: number, b2: number): number {\r\n if (b0 === 1 && b1 === 0 && b2 === 0)\r\n return 0;\r\n if (b0 === 0 && b1 === 1 && b2 === 0)\r\n return 1;\r\n if (b0 === 0 && b1 === 0 && b2 === 1)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a bounded edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i = 0, b_j > 0, and b_k > 0. Otherwise, returns -1.\r\n */\r\n private static isOnBoundedEdge(b0: number, b1: number, b2: number): number {\r\n if (b0 === 0 && b1 > 0 && b2 > 0)\r\n return 0;\r\n if (b0 > 0 && b1 === 0 && b2 > 0)\r\n return 1;\r\n if (b0 > 0 && b1 > 0 && b2 === 0)\r\n return 2;\r\n return -1;\r\n }\r\n /** @returns edge/vertex index (0,1,2) for which the function has a minimum value */\r\n private static indexOfMinimum(fn: (index: number) => number): number {\r\n let i = 0;\r\n let min = fn(0);\r\n const val = fn(1);\r\n if (min > val) {\r\n i = 1;\r\n min = val;\r\n }\r\n if (min > fn(2))\r\n i = 2;\r\n return i;\r\n }\r\n /**\r\n * Compute the squared distance between two points given by their barycentric coordinates.\r\n * * It is assumed that a0 + a1 + a2 = b0 + b1 + b2 = 1.\r\n */\r\n public distanceSquared(a0: number, a1: number, a2: number, b0: number, b1: number, b2: number): number {\r\n // The barycentric displacement vector distance formula\r\n // More details can be found at https://web.evanchen.cc/handouts/bary/bary-full.pdf\r\n return -this.edgeLengthSquared(0) * (b1 - a1) * (b2 - a2)\r\n - this.edgeLengthSquared(1) * (b2 - a2) * (b0 - a0)\r\n - this.edgeLengthSquared(2) * (b0 - a0) * (b1 - a1);\r\n }\r\n /** Return the index of the closest triangle vertex to the point given by its barycentric coordinates. */\r\n public closestVertexIndex(b0: number, b1: number, b2: number): number {\r\n return BarycentricTriangle.indexOfMinimum((i: number) => {\r\n const a = BarycentricTriangle._workPoint = Point3d.createZero(BarycentricTriangle._workPoint);\r\n a.setAt(i, 1.0); // \"a\" is (1,0,0) or (0,1,0) or (0,0,1) so \"a\" represents vertex i\r\n return this.distanceSquared(a.x, a.y, a.z, b0, b1, b2); // distance between the point and vertex i\r\n });\r\n }\r\n /** Compute dot product of the edge vectors based at the vertex with the given index. */\r\n public dotProductOfEdgeVectorsAtVertex(baseVertexIndex: number): number {\r\n const i = Geometry.cyclic3dAxis(baseVertexIndex);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n const k = Geometry.cyclic3dAxis(j + 1);\r\n return Geometry.dotProductXYZXYZ(\r\n this.points[j].x - this.points[i].x, this.points[j].y - this.points[i].y, this.points[j].z - this.points[i].z,\r\n this.points[k].x - this.points[i].x, this.points[k].y - this.points[i].y, this.points[k].z - this.points[i].z\r\n );\r\n }\r\n /**\r\n * Compute the projection of barycentric point p onto the (unbounded) edge e_k(v_i,v_j) of the triangle T(v_i,v_j,v_k).\r\n * @param k vertex v_k is opposite the edge e_k\r\n * @param b barycentric coordinates of point to project\r\n * @returns parameter f along e_k, such that:\r\n * * the projection point is q = v_i + f * (v_j - v_i)\r\n * * the barycentric coords of the projection are q_ijk = (1 - f, f, 0)\r\n */\r\n private computeProjectionToEdge(k: number, b: number[]): number {\r\n /**\r\n * We know p = (b_i*v_i) + (b_j*v_j) + (b_k*v_k) and 1 = b_i + b_j + b_k.\r\n * Let U = v_j - v_i and V = v_k - v_i and P = p - v_i.\r\n * First we prove P = b_jU + b_kV.\r\n * P = (b_i * v_i) + (b_j * v_j) + (b_k * v_k) - v_i\r\n * = (b_i * v_i) + (b_j * (v_j-v_i)) + (b_j * v_i) + (b_k * (v_k-v_i)) + (b_k * v_i) - v_i\r\n * = (b_i * v_i) + (b_j * U) + (b_j * v_i) + (b_k * V) + (b_k * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + ((b_i + b_j + b_k) * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + v_i - v_i\r\n * = (b_j * U) + (b_k * V)\r\n * So we know p - v_i = b_jU + b_kV and q - v_i = fU\r\n * Therefore, 0 = (p - q).(v_j - v_i)\r\n * = ((p-v_i) - (q-v_i)).(v_j - v_i)\r\n * = (b_jU + b_kV - fU).U\r\n * = b_jU.U + b_kU.V - fU.U\r\n * Thus f = b_j + b_k(U.V/U.U)\r\n */\r\n k = Geometry.cyclic3dAxis(k);\r\n const i = Geometry.cyclic3dAxis(k + 1);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n return b[j] + b[k] * this.dotProductOfEdgeVectorsAtVertex(i) / this.edgeLengthSquared(k);\r\n }\r\n /**\r\n * Compute the projection of a barycentric point p to the triangle T(v_0,v_1,v_2).\r\n * @param b0 barycentric coordinate of p corresponding to v_0\r\n * @param b1 barycentric coordinate of p corresponding to v_1\r\n * @param b2 barycentric coordinate of p corresponding to v_2\r\n * @returns closest edge start vertex index i and projection parameter f such that the projection\r\n * q = v_i + f * (v_j - v_i).\r\n */\r\n public closestPoint(b0: number, b1: number, b2: number): { closestEdgeIndex: number, closestEdgeParam: number } {\r\n const b: number[] = [b0, b1, b2];\r\n let edgeIndex = -1; // opposite-vertex index\r\n let edgeParam = 0.0;\r\n if (BarycentricTriangle.isInsideTriangle(b0, b1, b2)) { // projects to any edge\r\n edgeIndex = BarycentricTriangle.indexOfMinimum((i: number) => {\r\n // We want smallest projection distance d_i of p to e_i.\r\n // Since b_i=d_i|e_i|/2A we can compare quantities b_i/|e_i|.\r\n return b[i] * b[i] / this.edgeLengthSquared(i); // avoid sqrt\r\n });\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondVertex(b0, b1, b2)) >= 0) { // projects to other edges, or any vertex\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(this.closestVertexIndex(b0, b1, b2));\r\n }\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondEdge(b0, b1, b2)) >= 0) { // projects to the edge or its vertices\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0) {\r\n edgeParam = 0.0; // start of this edge\r\n } else if (edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1); // end of this edge = start of next edge\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isOnBoundedEdge(b0, b1, b2)) >= 0) {\r\n edgeParam = 1 - b[BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex)];\r\n } else if ((edgeIndex = BarycentricTriangle.isOnVertex(b0, b1, b2)) >= 0) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(edgeIndex);\r\n }\r\n // invalid edgeIndex shouldn't happen, but propagate it anyway\r\n assert(edgeIndex === 0 || edgeIndex === 1 || edgeIndex === 2);\r\n return {\r\n closestEdgeIndex: (edgeIndex < 0) ? -1 : BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex),\r\n closestEdgeParam: edgeParam,\r\n };\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a ray) with the plane of this triangle.\r\n * @param ray infinite line to intersect, as a ray\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.a` is the intersection parameter along the ray.\r\n * * The line intersects the plane of the triangle if and only if `d.isValid` returns true.\r\n * * The ray intersects the plane of the triangle if and only if `d.isValid` returns true and `d.a` >= 0.\r\n * * The ray intersects the triangle if and only if `d.isValid` returns true, `d.a` >= 0, and `d.isInsideOrOn`\r\n * returns true.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/RayTriangleIntersection\r\n * @see [[pointToFraction]]\r\n */\r\n public intersectRay3d(ray: Ray3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n result = TriangleLocationDetail.create(result);\r\n /**\r\n * Let r0 = ray.origin and d = ray.direction. Write intersection point p two ways for unknown scalars s,b0,b1,b2:\r\n * r0 + s*d = p = b0*v0 + b1*v1 + b2*v2\r\n * Subtract v0 from both ends, let u=v1-v0, v=v2-v0, c=r0-v0, and enforce b0+b1+b2=1:\r\n * b1*u + b2*v - s*d = c\r\n * This is a linear system Mx = c where M has columns u,v,d and solution x=(b1,b2,-s).\r\n */\r\n const r0 = ray.origin;\r\n const d = ray.direction;\r\n const u = BarycentricTriangle._workVector0 = Vector3d.createStartEnd(\r\n this.points[0], this.points[1], BarycentricTriangle._workVector0\r\n );\r\n const v = BarycentricTriangle._workVector1 = Vector3d.createStartEnd(\r\n this.points[0], this.points[2], BarycentricTriangle._workVector1\r\n );\r\n const M = BarycentricTriangle._workMatrix = Matrix3d.createColumns(u, v, d, BarycentricTriangle._workMatrix);\r\n const c = Vector3d.createStartEnd(this.points[0], r0, BarycentricTriangle._workVector0); // reuse workVector0\r\n const solution = BarycentricTriangle._workVector1; // reuse workVector1\r\n if (undefined === M.multiplyInverse(c, solution))\r\n return result; // invalid\r\n result.a = -solution.z; // = -(-s) = s\r\n ray.fractionToPoint(result.a, result.world);\r\n result.local.set(1.0 - solution.x - solution.y, solution.x, solution.y); // = (1 - b1 - b2, b1, b2) = (b0 , b1, b2)\r\n const proj = this.closestPoint(result.local.x, result.local.y, result.local.z);\r\n result.closestEdgeIndex = proj.closestEdgeIndex;\r\n result.closestEdgeParam = proj.closestEdgeParam;\r\n return result;\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a line segment) with the plane of this triangle.\r\n * @param point0 start point of segment on line to intersect\r\n * @param point1 end point of segment on line to intersect\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.isValid` returns true if and only if the line intersects the plane.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * `d.a` is the intersection parameter. If `d.a` is in [0,1], the segment intersects the plane of the triangle.\r\n * @see [[intersectRay3d]]\r\n */\r\n public intersectSegment(point0: Point3d, point1: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n BarycentricTriangle._workRay = Ray3d.createStartEnd(point0, point1, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(BarycentricTriangle._workRay, result);\r\n }\r\n /**\r\n * Adjust the location to the closest edge of the triangle if within either given tolerance.\r\n * @param location details of a point in the plane of the triangle (note that `location.local` and\r\n * `location.world` possibly updated to lie on the triangle closest edge)\r\n * @param distanceTolerance absolute distance tolerance (or zero to ignore)\r\n * @param parameterTolerance barycentric coordinate fractional tolerance (or zero to ignore)\r\n * @return whether the location was adjusted\r\n */\r\n public snapLocationToEdge(\r\n location: TriangleLocationDetail,\r\n distanceTolerance: number = Geometry.smallMetricDistance,\r\n parameterTolerance: number = Geometry.smallFloatingPoint\r\n ): boolean {\r\n if (!location.isValid)\r\n return false;\r\n // first try parametric tol to zero barycentric coordinate (no vertices or world distances used!)\r\n if (parameterTolerance > 0.0) {\r\n let numSnapped = 0;\r\n let newSum = 0.0;\r\n for (let i = 0; i < 3; i++) {\r\n const barycentricDist = Math.abs(location.local.at(i));\r\n if (barycentricDist > 0.0 && barycentricDist < parameterTolerance) {\r\n location.local.setAt(i, 0.0);\r\n numSnapped++;\r\n }\r\n newSum += location.local.at(i);\r\n }\r\n if (numSnapped > 0 && newSum > 0.0) {\r\n location.local.scaleInPlace(1.0 / newSum);\r\n if (1 === numSnapped) {\r\n location.closestEdgeIndex = BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(\r\n BarycentricTriangle.isOnBoundedEdge(location.local.x, location.local.y, location.local.z)\r\n );\r\n location.closestEdgeParam = 1.0 - location.local.at(location.closestEdgeIndex);\r\n } else { // 2 snapped, at vertex\r\n location.closestEdgeIndex = BarycentricTriangle.isOnVertex(\r\n location.local.x, location.local.y, location.local.z\r\n );\r\n location.closestEdgeParam = 0.0;\r\n }\r\n this.fractionToPoint(location.local.x, location.local.y, location.local.z, location.world);\r\n return true;\r\n }\r\n }\r\n // failing that, try distance tol to closest edge projection\r\n if (distanceTolerance > 0.0) {\r\n const i = location.closestEdgeIndex;\r\n const j = (i + 1) % 3;\r\n const k = (j + 1) % 3;\r\n const edgeProjection = BarycentricTriangle._workPoint = this.points[i].interpolate(\r\n location.closestEdgeParam, this.points[j], BarycentricTriangle._workPoint\r\n );\r\n const dist = location.world.distance(edgeProjection);\r\n if (dist > 0.0 && dist < distanceTolerance) {\r\n location.local.setAt(i, 1.0 - location.closestEdgeParam);\r\n location.local.setAt(j, location.closestEdgeParam);\r\n location.local.setAt(k, 0.0);\r\n location.world.setFrom(edgeProjection);\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return the dot product of the scaled normals of the two triangles.\r\n * * The sign of the return value is useful for determining the triangles' relative orientation:\r\n * positive (negative) means the normals point into the same (opposite) half-space determined by\r\n * one of the triangles' planes; zero means the triangles are perpendicular.\r\n */\r\n public dotProductOfCrossProductsFromOrigin(other: BarycentricTriangle): number {\r\n BarycentricTriangle._workVector0 = this.points[0].crossProductToPoints(\r\n this.points[1], this.points[2], BarycentricTriangle._workVector0\r\n );\r\n BarycentricTriangle._workVector1 = other.points[0].crossProductToPoints(\r\n other.points[1], other.points[2], BarycentricTriangle._workVector1\r\n );\r\n return BarycentricTriangle._workVector0.dotProduct(BarycentricTriangle._workVector1);\r\n }\r\n /** Return the centroid of the 3 points. */\r\n public centroid(result?: Point3d): Point3d {\r\n // Do the scale as true division (rather than multiply by precomputed 1/3). This might protect one bit of result.\r\n return Point3d.create(\r\n (this.points[0].x + this.points[1].x + this.points[2].x) / 3.0,\r\n (this.points[0].y + this.points[1].y + this.points[2].y) / 3.0,\r\n (this.points[0].z + this.points[1].z + this.points[2].z) / 3.0,\r\n result\r\n );\r\n }\r\n /** Return the incenter of the triangle. */\r\n public incenter(result?: Point3d): Point3d {\r\n const a = this.edgeLength(0);\r\n const b = this.edgeLength(1);\r\n const c = this.edgeLength(2);\r\n const scale = Geometry.safeDivideFraction(1.0, a + b + c, 0.0);\r\n return this.fractionToPoint(scale * a, scale * b, scale * c, result);\r\n }\r\n /** Return the circumcenter of the triangle. */\r\n public circumcenter(result?: Point3d): Point3d {\r\n const a2 = this.edgeLengthSquared(0);\r\n const b2 = this.edgeLengthSquared(1);\r\n const c2 = this.edgeLengthSquared(2);\r\n const x = a2 * (b2 + c2 - a2);\r\n const y = b2 * (c2 + a2 - b2);\r\n const z = c2 * (a2 + b2 - c2);\r\n const scale = Geometry.safeDivideFraction(1.0, x + y + z, 0.0);\r\n return this.fractionToPoint(scale * x, scale * y, scale * z, result);\r\n }\r\n /** Test for point-by-point `isAlmostEqual` relationship. */\r\n public isAlmostEqual(other: BarycentricTriangle, tol?: number): boolean {\r\n return this.points[0].isAlmostEqual(other.points[0], tol)\r\n && this.points[1].isAlmostEqual(other.points[1], tol)\r\n && this.points[2].isAlmostEqual(other.points[2], tol);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BarycentricTriangle.js","sourceRoot":"","sources":["../../../src/geometry3d/BarycentricTriangle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAE7C,0CAAwD;AACxD,yCAAsC;AACtC,uDAAsD;AACtD,mCAAgC;AAGhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,sBAAsB;IAiBjC;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IACD,4DAA4D;IACrD,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC;IAC9B,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,MAA+B;QAClD,IAAI,SAAS,KAAK,MAAM;YACtB,MAAM,GAAG,IAAI,sBAAsB,EAAE,CAAC;;YAEtC,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;OAGG;IACI,gBAAgB,CAAC,KAA6B;QACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CA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4D;IACrD,aAAa,CAAC,KAA0B,EAAE,GAAY;QAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eACpD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;eAClD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF;AA/hBD,kDA+hBC","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/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\n\r\nimport { Geometry, PolygonLocation } from \"../Geometry\";\r\nimport { Matrix3d } from \"./Matrix3d\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n/**\r\n * Carries data about a location in the plane of a triangle.\r\n * * Each instance carries both world and barycentric coordinates for the point, and provides query\r\n * services on the latter.\r\n * * No tolerance is used when querying barycentric coordinates (e.g., `isInsideOrOn`, `classify`). Use\r\n * [[BarycentricTriangle.snapLocationToEdge]] to adjust the barycentric coordinates to a triangle edge\r\n * if they lie within a distance or parametric tolerance.\r\n *\r\n * Properties of the barycentric coordinates `(b0, b1, b2)` of a point `p` in the plane of a triangle\r\n * `T` with vertices `v0, v1, v2`:\r\n * * `1 = b0 + b1 + b2`\r\n * * `p = b0 * v0 + b1 * v1 + b2 * v2`\r\n * * If T is spanned by the vectors `U = v1 - v0` and `V = v2 - v0`, then the vector `P = p - v0` can\r\n * be written `P = b1 * U + b2 * V`.\r\n * * The coordinates are all nonnegative if and only if `p` is inside or on `T`.\r\n * * Exactly one coordinate is zero if and only if `p` lies on an (infinitely extended) edge of `T`.\r\n * * Exactly two coordinates are zero if and only if `p` coincides with a vertex of `T`.\r\n * * Note that if `p` can be written as a linear combination of the vertices of `T` using scales that do\r\n * NOT sum to 1, then `p` is not coplanar with `T`\r\n * @public\r\n */\r\nexport class TriangleLocationDetail {\r\n /** The Cartesian coordinates of the point p. */\r\n public world: Point3d;\r\n /** The barycentric coordinates of p with respect to the triangle. Assumed to sum to one. */\r\n public local: Point3d;\r\n /** Application-specific number */\r\n public a: number;\r\n /** Index of the triangle vertex at the start of the closest edge to p. */\r\n public closestEdgeIndex: number;\r\n /**\r\n * The parameter f along the closest edge to p of its projection q.\r\n * * We have q = v_i + f * (v_j - v_i) where i = closestEdgeIndex and j = (i + 1) % 3 are the indices\r\n * of the start vertex v_i and end vertex v_j of the closest edge to p.\r\n * * Note that 0 <= f <= 1.\r\n */\r\n public closestEdgeParam: number;\r\n\r\n private constructor() {\r\n this.world = new Point3d();\r\n this.local = new Point3d();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /** Invalidate this detail (set all attributes to zero) . */\r\n public invalidate() {\r\n this.world.setZero();\r\n this.local.setZero();\r\n this.a = 0.0;\r\n this.closestEdgeIndex = 0;\r\n this.closestEdgeParam = 0.0;\r\n }\r\n /**\r\n * Create an invalid detail.\r\n * @param result optional pre-allocated object to fill and return\r\n */\r\n public static create(result?: TriangleLocationDetail): TriangleLocationDetail {\r\n if (undefined === result)\r\n result = new TriangleLocationDetail();\r\n else\r\n result.invalidate();\r\n return result;\r\n }\r\n /**\r\n * Set the instance contents from the `other` detail.\r\n * @param other detail to clone\r\n */\r\n public copyContentsFrom(other: TriangleLocationDetail) {\r\n this.world.setFrom(other.world);\r\n this.local.setFrom(other.local);\r\n this.a = other.a;\r\n this.closestEdgeIndex = other.closestEdgeIndex;\r\n this.closestEdgeParam = other.closestEdgeParam;\r\n }\r\n /** Whether this detail is invalid. */\r\n public get isValid(): boolean {\r\n return !this.local.isZero;\r\n }\r\n /**\r\n * Queries the barycentric coordinates to determine whether this instance specifies a location inside or\r\n * on the triangle.\r\n * @see classify\r\n */\r\n public get isInsideOrOn(): boolean {\r\n return this.isValid && this.local.x >= 0.0 && this.local.y >= 0.0 && this.local.z >= 0.0;\r\n }\r\n /**\r\n * Queries this detail to classify the location of this instance with respect to the triangle.\r\n * @returns location code\r\n * @see isInsideOrOn\r\n */\r\n public get classify(): PolygonLocation {\r\n if (!this.isValid)\r\n return PolygonLocation.Unknown;\r\n if (this.isInsideOrOn) {\r\n let numZero = 0;\r\n if (Math.abs(this.local.x) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.y) === 0.0)\r\n ++numZero;\r\n if (Math.abs(this.local.z) === 0.0)\r\n ++numZero;\r\n if (2 === numZero)\r\n return PolygonLocation.OnPolygonVertex;\r\n if (1 === numZero)\r\n return PolygonLocation.OnPolygonEdgeInterior;\r\n return PolygonLocation.InsidePolygonProjectsToEdgeInterior;\r\n }\r\n return (this.closestEdgeParam === 0.0) ?\r\n PolygonLocation.OutsidePolygonProjectsToVertex :\r\n PolygonLocation.OutsidePolygonProjectsToEdgeInterior;\r\n }\r\n}\r\n\r\n/**\r\n * 3 points defining a triangle to be evaluated with barycentric coordinates.\r\n * @public\r\n */\r\nexport class BarycentricTriangle {\r\n /** Array of 3 point coordinates for the triangle. */\r\n public points: Point3d[];\r\n /** Edge length squared cache, indexed by opposite vertex index */\r\n protected edgeLength2: number[];\r\n // private attributes\r\n private static _workPoint?: Point3d;\r\n private static _workVector0?: Vector3d;\r\n private static _workVector1?: Vector3d;\r\n private static _workRay?: Ray3d;\r\n private static _workMatrix?: Matrix3d;\r\n /**\r\n * Constructor.\r\n * * Point references are CAPTURED\r\n */\r\n protected constructor(point0: Point3d, point1: Point3d, point2: Point3d) {\r\n this.points = [];\r\n this.points.push(point0);\r\n this.points.push(point1);\r\n this.points.push(point2);\r\n this.edgeLength2 = [];\r\n this.edgeLength2.push(point1.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point2));\r\n this.edgeLength2.push(point0.distanceSquared(point1));\r\n }\r\n /**\r\n * Copy contents of (not pointers to) the given points. A vertex is zeroed if its corresponding input point\r\n * is undefined.\r\n */\r\n public set(point0: Point3d | undefined, point1: Point3d | undefined, point2: Point3d | undefined) {\r\n this.points[0].setFromPoint3d(point0);\r\n this.points[1].setFromPoint3d(point1);\r\n this.points[2].setFromPoint3d(point2);\r\n this.edgeLength2[0] = this.points[1].distanceSquared(this.points[2]);\r\n this.edgeLength2[1] = this.points[0].distanceSquared(this.points[2]);\r\n this.edgeLength2[2] = this.points[0].distanceSquared(this.points[1]);\r\n }\r\n /** Copy all values from `other` */\r\n public setFrom(other: BarycentricTriangle) {\r\n for (let i = 0; i < 3; ++i) {\r\n this.points[i].setFromPoint3d(other.points[i]);\r\n this.edgeLength2[i] = other.edgeLength2[i];\r\n }\r\n }\r\n /**\r\n * Create a `BarycentricTriangle` with coordinates given by enumerated x,y,z of the 3 points.\r\n * @param result optional pre-allocated triangle.\r\n */\r\n public static createXYZXYZXYZ(\r\n x0: number, y0: number, z0: number,\r\n x1: number, y1: number, z1: number,\r\n x2: number, y2: number, z2: number,\r\n result?: BarycentricTriangle,\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(Point3d.create(x0, y0, z0), Point3d.create(x1, y1, z1), Point3d.create(x2, y2, z2));\r\n result.points[0].set(x0, y0, z0);\r\n result.points[1].set(x1, y1, z1);\r\n result.points[2].set(x2, y2, z2);\r\n return result;\r\n }\r\n /** Create a triangle with coordinates cloned from given points. */\r\n public static create(\r\n point0: Point3d, point1: Point3d, point2: Point3d, result?: BarycentricTriangle,\r\n ): BarycentricTriangle {\r\n if (!result)\r\n return new this(point0.clone(), point1.clone(), point2.clone());\r\n result.set(point0, point1, point2);\r\n return result;\r\n }\r\n /** Return a new `BarycentricTriangle` with the same coordinates. */\r\n public clone(result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(this.points[0], this.points[1], this.points[2], result);\r\n }\r\n /** Return a clone of the transformed instance */\r\n public cloneTransformed(transform: Transform, result?: BarycentricTriangle): BarycentricTriangle {\r\n return BarycentricTriangle.create(\r\n transform.multiplyPoint3d(this.points[0], result?.points[0]),\r\n transform.multiplyPoint3d(this.points[1], result?.points[1]),\r\n transform.multiplyPoint3d(this.points[2], result?.points[2]),\r\n result,\r\n );\r\n }\r\n /** Return the area of the triangle. */\r\n public get area(): number {\r\n // The magnitude of the cross product A × B is the area of the parallelogram spanned by A and B.\r\n return 0.5 * this.points[0].crossProductToPointsMagnitude(this.points[1], this.points[2]);\r\n }\r\n /**\r\n * Compute squared length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLengthSquared(oppositeVertexIndex: number): number {\r\n return this.edgeLength2[Geometry.cyclic3dAxis(oppositeVertexIndex)];\r\n }\r\n /**\r\n * Compute length of the triangle edge opposite the vertex with the given index.\r\n * @see [[edgeStartVertexIndexToOppositeVertexIndex]]\r\n */\r\n public edgeLength(oppositeVertexIndex: number): number {\r\n return Math.sqrt(this.edgeLengthSquared(oppositeVertexIndex));\r\n }\r\n /** Return area divided by sum of squared lengths. */\r\n public get aspectRatio(): number {\r\n return Geometry.safeDivideFraction(\r\n this.area, this.edgeLengthSquared(0) + this.edgeLengthSquared(1) + this.edgeLengthSquared(2), 0,\r\n );\r\n }\r\n /** Return the perimeter of the triangle. */\r\n public get perimeter(): number {\r\n return this.edgeLength(0) + this.edgeLength(1) + this.edgeLength(2);\r\n }\r\n /**\r\n * Return the unit normal of the triangle.\r\n * @param result optional pre-allocated vector to fill and return.\r\n * @returns unit normal, or undefined if cross product length is too small.\r\n */\r\n public normal(result?: Vector3d): Vector3d | undefined {\r\n const cross = this.points[0].crossProductToPoints(this.points[1], this.points[2], result);\r\n if (cross.tryNormalizeInPlace())\r\n return cross;\r\n return undefined;\r\n }\r\n /**\r\n * Sum the triangle points with given scales.\r\n * * If the scales sum to 1, they are barycentric coordinates, and hence the result point is in the plane of\r\n * the triangle. If all coordinates are non-negative then the result point is inside the triangle.\r\n * * If the scales do not sum to 1, the point is inside the triangle scaled (by the scale sum) from the origin.\r\n * @param b0 scale to apply to vertex 0\r\n * @param b1 scale to apply to vertex 1\r\n * @param b2 scale to apply to vertex 2\r\n * @param result optional pre-allocated point to fill and return\r\n * @return linear combination of the vertices of this triangle\r\n * @see [[pointToFraction]]\r\n */\r\n public fractionToPoint(b0: number, b1: number, b2: number, result?: Point3d): Point3d {\r\n // p = b0 * v0 + b1 * v1 + b2 * v2\r\n return Point3d.createAdd3Scaled(this.points[0], b0, this.points[1], b1, this.points[2], b2, result);\r\n }\r\n /**\r\n * Compute the projection of the given `point` onto the plane of this triangle.\r\n * @param point point p to project\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the projection point `P = d.world`:\r\n * * `d.isValid` returns true if and only if `this.normal()` is defined.\r\n * * `d.classify` can be used to determine where P lies with respect to the triangle.\r\n * * `d.a` is the signed projection distance: `P = p + a * this.normal()`.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BarycentricTriangle\r\n * @see [[fractionToPoint]]\r\n */\r\n public pointToFraction(point: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n const normal = BarycentricTriangle._workVector0 = this.normal(BarycentricTriangle._workVector0);\r\n if (undefined === normal)\r\n return TriangleLocationDetail.create(result);\r\n const ray = BarycentricTriangle._workRay = Ray3d.create(point, normal, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(ray, result); // intersectRay3d is free to use workVector0\r\n }\r\n /** Convert from opposite-vertex to start-vertex edge indexing. */\r\n public static edgeOppositeVertexIndexToStartVertexIndex(edgeIndex: number): number {\r\n return Geometry.cyclic3dAxis(edgeIndex + 1);\r\n }\r\n /** Convert from start-vertex to opposite-vertex edge indexing. */\r\n public static edgeStartVertexIndexToOppositeVertexIndex(startVertexIndex: number): number {\r\n return Geometry.cyclic3dAxis(startVertexIndex - 1);\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle but not on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is strictly inside the triangle.\r\n */\r\n public static isInsideTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 > 0 && b1 > 0 && b2 > 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies inside the triangle or on an edge/vertex.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns whether the point with barycentric coordinates is inside or on the triangle.\r\n */\r\n public static isInsideOrOnTriangle(b0: number, b1: number, b2: number): boolean {\r\n return b0 >= 0 && b1 >= 0 && b2 >= 0;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside an edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i < 0 and b_j >= 0, and b_k >= 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondEdge(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives smaller regions)\r\n if (b0 < 0 && b1 >= 0 && b2 >= 0)\r\n return 0;\r\n if (b0 >= 0 && b1 < 0 && b2 >= 0)\r\n return 1;\r\n if (b0 >= 0 && b1 >= 0 && b2 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies outside a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_j < 0 and b_k < 0. Otherwise, returns -1.\r\n */\r\n private static isInRegionBeyondVertex(b0: number, b1: number, b2: number): number {\r\n // Note: the 3 regions (specified by the following if statements) are defined by extending the triangle\r\n // edges to infinity and not by perpendicular lines to the edges (which gives larger regions)\r\n if (b1 < 0 && b2 < 0)\r\n return 0;\r\n if (b0 < 0 && b2 < 0)\r\n return 1;\r\n if (b0 < 0 && b1 < 0)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a vertex of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns index of vertex i for which b_i = 1 and b_j = b_k = 0. Otherwise, returns -1.\r\n */\r\n private static isOnVertex(b0: number, b1: number, b2: number): number {\r\n if (b0 === 1 && b1 === 0 && b2 === 0)\r\n return 0;\r\n if (b0 === 0 && b1 === 1 && b2 === 0)\r\n return 1;\r\n if (b0 === 0 && b1 === 0 && b2 === 1)\r\n return 2;\r\n return -1;\r\n }\r\n /**\r\n * Examine a point's barycentric coordinates to determine if it lies on a bounded edge of the triangle.\r\n * * No parametric tolerance is used.\r\n * * It is assumed b0 + b1 + b2 = 1.\r\n * @returns edge index i (opposite vertex i) for which b_i = 0, b_j > 0, and b_k > 0. Otherwise, returns -1.\r\n */\r\n private static isOnBoundedEdge(b0: number, b1: number, b2: number): number {\r\n if (b0 === 0 && b1 > 0 && b2 > 0)\r\n return 0;\r\n if (b0 > 0 && b1 === 0 && b2 > 0)\r\n return 1;\r\n if (b0 > 0 && b1 > 0 && b2 === 0)\r\n return 2;\r\n return -1;\r\n }\r\n /** @returns edge/vertex index (0,1,2) for which the function has a minimum value */\r\n private static indexOfMinimum(fn: (index: number) => number): number {\r\n let i = 0;\r\n let min = fn(0);\r\n const val = fn(1);\r\n if (min > val) {\r\n i = 1;\r\n min = val;\r\n }\r\n if (min > fn(2))\r\n i = 2;\r\n return i;\r\n }\r\n /**\r\n * Compute the squared distance between two points given by their barycentric coordinates.\r\n * * It is assumed that a0 + a1 + a2 = b0 + b1 + b2 = 1.\r\n */\r\n public distanceSquared(a0: number, a1: number, a2: number, b0: number, b1: number, b2: number): number {\r\n // The barycentric displacement vector distance formula\r\n // More details can be found at https://web.evanchen.cc/handouts/bary/bary-full.pdf\r\n return -this.edgeLengthSquared(0) * (b1 - a1) * (b2 - a2)\r\n - this.edgeLengthSquared(1) * (b2 - a2) * (b0 - a0)\r\n - this.edgeLengthSquared(2) * (b0 - a0) * (b1 - a1);\r\n }\r\n /** Return the index of the closest triangle vertex to the point given by its barycentric coordinates. */\r\n public closestVertexIndex(b0: number, b1: number, b2: number): number {\r\n return BarycentricTriangle.indexOfMinimum((i: number) => {\r\n const a = BarycentricTriangle._workPoint = Point3d.createZero(BarycentricTriangle._workPoint);\r\n a.setAt(i, 1.0); // \"a\" is (1,0,0) or (0,1,0) or (0,0,1) so \"a\" represents vertex i\r\n return this.distanceSquared(a.x, a.y, a.z, b0, b1, b2); // distance between the point and vertex i\r\n });\r\n }\r\n /** Compute dot product of the edge vectors based at the vertex with the given index. */\r\n public dotProductOfEdgeVectorsAtVertex(baseVertexIndex: number): number {\r\n const i = Geometry.cyclic3dAxis(baseVertexIndex);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n const k = Geometry.cyclic3dAxis(j + 1);\r\n return Geometry.dotProductXYZXYZ(\r\n this.points[j].x - this.points[i].x, this.points[j].y - this.points[i].y, this.points[j].z - this.points[i].z,\r\n this.points[k].x - this.points[i].x, this.points[k].y - this.points[i].y, this.points[k].z - this.points[i].z,\r\n );\r\n }\r\n /**\r\n * Compute the projection of barycentric point p onto the (unbounded) edge e_k(v_i,v_j) of the triangle T(v_i,v_j,v_k).\r\n * @param k vertex v_k is opposite the edge e_k\r\n * @param b barycentric coordinates of point to project\r\n * @returns parameter f along e_k, such that:\r\n * * the projection point is q = v_i + f * (v_j - v_i)\r\n * * the barycentric coords of the projection are q_ijk = (1 - f, f, 0)\r\n */\r\n private computeProjectionToEdge(k: number, b: number[]): number {\r\n /**\r\n * We know p = (b_i*v_i) + (b_j*v_j) + (b_k*v_k) and 1 = b_i + b_j + b_k.\r\n * Let U = v_j - v_i and V = v_k - v_i and P = p - v_i.\r\n * First we prove P = b_jU + b_kV.\r\n * P = (b_i * v_i) + (b_j * v_j) + (b_k * v_k) - v_i\r\n * = (b_i * v_i) + (b_j * (v_j-v_i)) + (b_j * v_i) + (b_k * (v_k-v_i)) + (b_k * v_i) - v_i\r\n * = (b_i * v_i) + (b_j * U) + (b_j * v_i) + (b_k * V) + (b_k * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + ((b_i + b_j + b_k) * v_i) - v_i\r\n * = (b_j * U) + (b_k * V) + v_i - v_i\r\n * = (b_j * U) + (b_k * V)\r\n * So we know p - v_i = b_jU + b_kV and q - v_i = fU\r\n * Therefore, 0 = (p - q).(v_j - v_i)\r\n * = ((p-v_i) - (q-v_i)).(v_j - v_i)\r\n * = (b_jU + b_kV - fU).U\r\n * = b_jU.U + b_kU.V - fU.U\r\n * Thus f = b_j + b_k(U.V/U.U)\r\n */\r\n k = Geometry.cyclic3dAxis(k);\r\n const i = Geometry.cyclic3dAxis(k + 1);\r\n const j = Geometry.cyclic3dAxis(i + 1);\r\n return b[j] + b[k] * this.dotProductOfEdgeVectorsAtVertex(i) / this.edgeLengthSquared(k);\r\n }\r\n /**\r\n * Compute the projection of a barycentric point p to the triangle T(v_0,v_1,v_2).\r\n * @param b0 barycentric coordinate of p corresponding to v_0\r\n * @param b1 barycentric coordinate of p corresponding to v_1\r\n * @param b2 barycentric coordinate of p corresponding to v_2\r\n * @returns closest edge start vertex index i and projection parameter f such that the projection\r\n * q = v_i + f * (v_j - v_i).\r\n */\r\n public closestPoint(b0: number, b1: number, b2: number): { closestEdgeIndex: number, closestEdgeParam: number } {\r\n const b: number[] = [b0, b1, b2];\r\n let edgeIndex = -1; // opposite-vertex index\r\n let edgeParam = 0.0;\r\n if (BarycentricTriangle.isInsideTriangle(b0, b1, b2)) { // projects to any edge\r\n edgeIndex = BarycentricTriangle.indexOfMinimum((i: number) => {\r\n // We want smallest projection distance d_i of p to e_i.\r\n // Since b_i=d_i|e_i|/2A we can compare quantities b_i/|e_i|.\r\n return b[i] * b[i] / this.edgeLengthSquared(i); // avoid sqrt\r\n });\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondVertex(b0, b1, b2)) >= 0) { // projects to other edges, or any vertex\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1);\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0 || edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(this.closestVertexIndex(b0, b1, b2));\r\n }\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isInRegionBeyondEdge(b0, b1, b2)) >= 0) { // projects to the edge or its vertices\r\n edgeParam = this.computeProjectionToEdge(edgeIndex, b);\r\n if (edgeParam < 0) {\r\n edgeParam = 0.0; // start of this edge\r\n } else if (edgeParam > 1) {\r\n edgeParam = 0.0;\r\n edgeIndex = Geometry.cyclic3dAxis(edgeIndex + 1); // end of this edge = start of next edge\r\n }\r\n } else if ((edgeIndex = BarycentricTriangle.isOnBoundedEdge(b0, b1, b2)) >= 0) {\r\n edgeParam = 1 - b[BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex)];\r\n } else if ((edgeIndex = BarycentricTriangle.isOnVertex(b0, b1, b2)) >= 0) {\r\n edgeParam = 0.0;\r\n edgeIndex = BarycentricTriangle.edgeStartVertexIndexToOppositeVertexIndex(edgeIndex);\r\n }\r\n // invalid edgeIndex shouldn't happen, but propagate it anyway\r\n assert(edgeIndex === 0 || edgeIndex === 1 || edgeIndex === 2);\r\n return {\r\n closestEdgeIndex: (edgeIndex < 0) ? -1 : BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(edgeIndex),\r\n closestEdgeParam: edgeParam,\r\n };\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a ray) with the plane of this triangle.\r\n * @param ray infinite line to intersect, as a ray\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.a` is the intersection parameter along the ray.\r\n * * The line intersects the plane of the triangle if and only if `d.isValid` returns true.\r\n * * The ray intersects the plane of the triangle if and only if `d.isValid` returns true and `d.a` >= 0.\r\n * * The ray intersects the triangle if and only if `d.isValid` returns true, `d.a` >= 0, and `d.isInsideOrOn`\r\n * returns true.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/RayTriangleIntersection\r\n * @see [[pointToFraction]]\r\n */\r\n public intersectRay3d(ray: Ray3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n result = TriangleLocationDetail.create(result);\r\n /**\r\n * Let r0 = ray.origin and d = ray.direction. Write intersection point p two ways for unknown scalars s,b0,b1,b2:\r\n * r0 + s*d = p = b0*v0 + b1*v1 + b2*v2\r\n * Subtract v0 from both ends, let u=v1-v0, v=v2-v0, c=r0-v0, and enforce b0+b1+b2=1:\r\n * b1*u + b2*v - s*d = c\r\n * This is a linear system Mx = c where M has columns u,v,d and solution x=(b1,b2,-s).\r\n */\r\n const r0 = ray.origin;\r\n const d = ray.direction;\r\n const u = BarycentricTriangle._workVector0 = Vector3d.createStartEnd(\r\n this.points[0], this.points[1], BarycentricTriangle._workVector0,\r\n );\r\n const v = BarycentricTriangle._workVector1 = Vector3d.createStartEnd(\r\n this.points[0], this.points[2], BarycentricTriangle._workVector1,\r\n );\r\n const M = BarycentricTriangle._workMatrix = Matrix3d.createColumns(u, v, d, BarycentricTriangle._workMatrix);\r\n const c = Vector3d.createStartEnd(this.points[0], r0, BarycentricTriangle._workVector0); // reuse workVector0\r\n const solution = BarycentricTriangle._workVector1; // reuse workVector1\r\n if (undefined === M.multiplyInverse(c, solution))\r\n return result; // invalid\r\n result.a = -solution.z; // = -(-s) = s\r\n ray.fractionToPoint(result.a, result.world);\r\n result.local.set(1.0 - solution.x - solution.y, solution.x, solution.y); // = (1 - b1 - b2, b1, b2) = (b0 , b1, b2)\r\n const proj = this.closestPoint(result.local.x, result.local.y, result.local.z);\r\n result.closestEdgeIndex = proj.closestEdgeIndex;\r\n result.closestEdgeParam = proj.closestEdgeParam;\r\n return result;\r\n }\r\n /**\r\n * Compute the intersection of a line (parameterized as a line segment) with the plane of this triangle.\r\n * @param point0 start point of segment on line to intersect\r\n * @param point1 end point of segment on line to intersect\r\n * @param result optional pre-allocated object to fill and return\r\n * @returns details d of the line-plane intersection point `d.world`:\r\n * * `d.isValid` returns true if and only if the line intersects the plane.\r\n * * `d.classify` can be used to determine where the intersection lies with respect to the triangle.\r\n * * `d.a` is the intersection parameter. If `d.a` is in [0,1], the segment intersects the plane of the triangle.\r\n * @see [[intersectRay3d]]\r\n */\r\n public intersectSegment(point0: Point3d, point1: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail {\r\n BarycentricTriangle._workRay = Ray3d.createStartEnd(point0, point1, BarycentricTriangle._workRay);\r\n return this.intersectRay3d(BarycentricTriangle._workRay, result);\r\n }\r\n /**\r\n * Adjust the location to the closest edge of the triangle if within either given tolerance.\r\n * @param location details of a point in the plane of the triangle (note that `location.local` and\r\n * `location.world` possibly updated to lie on the triangle closest edge)\r\n * @param distanceTolerance absolute distance tolerance (or zero to ignore)\r\n * @param parameterTolerance barycentric coordinate fractional tolerance (or zero to ignore)\r\n * @return whether the location was adjusted\r\n */\r\n public snapLocationToEdge(\r\n location: TriangleLocationDetail,\r\n distanceTolerance: number = Geometry.smallMetricDistance,\r\n parameterTolerance: number = Geometry.smallFloatingPoint,\r\n ): boolean {\r\n if (!location.isValid)\r\n return false;\r\n // first try parametric tol to zero barycentric coordinate (no vertices or world distances used!)\r\n if (parameterTolerance > 0.0) {\r\n let numSnapped = 0;\r\n let newSum = 0.0;\r\n for (let i = 0; i < 3; i++) {\r\n const barycentricDist = Math.abs(location.local.at(i));\r\n if (barycentricDist > 0.0 && barycentricDist < parameterTolerance) {\r\n location.local.setAt(i, 0.0);\r\n numSnapped++;\r\n }\r\n newSum += location.local.at(i);\r\n }\r\n if (numSnapped > 0 && newSum > 0.0) {\r\n location.local.scaleInPlace(1.0 / newSum);\r\n if (1 === numSnapped) {\r\n location.closestEdgeIndex = BarycentricTriangle.edgeOppositeVertexIndexToStartVertexIndex(\r\n BarycentricTriangle.isOnBoundedEdge(location.local.x, location.local.y, location.local.z),\r\n );\r\n location.closestEdgeParam = 1.0 - location.local.at(location.closestEdgeIndex);\r\n } else { // 2 snapped, at vertex\r\n location.closestEdgeIndex = BarycentricTriangle.isOnVertex(\r\n location.local.x, location.local.y, location.local.z,\r\n );\r\n location.closestEdgeParam = 0.0;\r\n }\r\n this.fractionToPoint(location.local.x, location.local.y, location.local.z, location.world);\r\n return true;\r\n }\r\n }\r\n // failing that, try distance tol to closest edge projection\r\n if (distanceTolerance > 0.0) {\r\n const i = location.closestEdgeIndex;\r\n const j = (i + 1) % 3;\r\n const k = (j + 1) % 3;\r\n const edgeProjection = BarycentricTriangle._workPoint = this.points[i].interpolate(\r\n location.closestEdgeParam, this.points[j], BarycentricTriangle._workPoint,\r\n );\r\n const dist = location.world.distance(edgeProjection);\r\n if (dist > 0.0 && dist < distanceTolerance) {\r\n location.local.setAt(i, 1.0 - location.closestEdgeParam);\r\n location.local.setAt(j, location.closestEdgeParam);\r\n location.local.setAt(k, 0.0);\r\n location.world.setFrom(edgeProjection);\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return the dot product of the scaled normals of the two triangles.\r\n * * The sign of the return value is useful for determining the triangles' relative orientation:\r\n * positive (negative) means the normals point into the same (opposite) half-space determined by\r\n * one of the triangles' planes; zero means the triangles are perpendicular.\r\n */\r\n public dotProductOfCrossProductsFromOrigin(other: BarycentricTriangle): number {\r\n BarycentricTriangle._workVector0 = this.points[0].crossProductToPoints(\r\n this.points[1], this.points[2], BarycentricTriangle._workVector0,\r\n );\r\n BarycentricTriangle._workVector1 = other.points[0].crossProductToPoints(\r\n other.points[1], other.points[2], BarycentricTriangle._workVector1,\r\n );\r\n return BarycentricTriangle._workVector0.dotProduct(BarycentricTriangle._workVector1);\r\n }\r\n /** Return the centroid of the 3 points. */\r\n public centroid(result?: Point3d): Point3d {\r\n // Do the scale as true division (rather than multiply by precomputed 1/3). This might protect one bit of result.\r\n return Point3d.create(\r\n (this.points[0].x + this.points[1].x + this.points[2].x) / 3.0,\r\n (this.points[0].y + this.points[1].y + this.points[2].y) / 3.0,\r\n (this.points[0].z + this.points[1].z + this.points[2].z) / 3.0,\r\n result,\r\n );\r\n }\r\n /** Return the incenter of the triangle. */\r\n public incenter(result?: Point3d): Point3d {\r\n const a = this.edgeLength(0);\r\n const b = this.edgeLength(1);\r\n const c = this.edgeLength(2);\r\n const scale = Geometry.safeDivideFraction(1.0, a + b + c, 0.0);\r\n return this.fractionToPoint(scale * a, scale * b, scale * c, result);\r\n }\r\n /** Return the circumcenter of the triangle. */\r\n public circumcenter(result?: Point3d): Point3d {\r\n const a2 = this.edgeLengthSquared(0);\r\n const b2 = this.edgeLengthSquared(1);\r\n const c2 = this.edgeLengthSquared(2);\r\n const x = a2 * (b2 + c2 - a2);\r\n const y = b2 * (c2 + a2 - b2);\r\n const z = c2 * (a2 + b2 - c2);\r\n const scale = Geometry.safeDivideFraction(1.0, x + y + z, 0.0);\r\n return this.fractionToPoint(scale * x, scale * y, scale * z, result);\r\n }\r\n /** Test for point-by-point `isAlmostEqual` relationship. */\r\n public isAlmostEqual(other: BarycentricTriangle, tol?: number): boolean {\r\n return this.points[0].isAlmostEqual(other.points[0], tol)\r\n && this.points[1].isAlmostEqual(other.points[1], tol)\r\n && this.points[2].isAlmostEqual(other.points[2], tol);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BilinearPatch.js","sourceRoot":"","sources":["../../../src/geometry3d/BilinearPatch.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,4EAA0G;AAC1G,sEAAmE;AACnE,0CAAuC;AACvC,yDAAsD;AAEtD,2EAAwE;AACxE,uDAA4C;AAK5C,kCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,aAAa;IASxB;;;;;;OAMG;IACH,YAAmB,OAAgB,EAAE,OAAgB,EAAE,OAAgB,EAAE,OAAgB;QACvF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,OAAgB,EAAE,OAAgB,EAAE,OAAgB,EAAE,OAAgB;QACzF,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/F,CAAC;IACD,uDAAuD;IAChD,MAAM,CAAC,SAAS,CACrB,GAAW,EAAE,GAAW,EAAE,GAAW,EACrC,GAAW,EAAE,GAAW,EAAE,GAAW,EACrC,GAAW,EAAE,GAAW,EAAE,GAAW,EACrC,GAAW,EAAE,GAAW,EAAE,GAAW;QAErC,OAAO,IAAI,aAAa,CACtB,yBAAO,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC7B,yBAAO,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GA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,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,CAAC;IACD,yEAAyE;IAClE,cAAc;QACnB,OAAO,mBAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,CAAC;CACF;AAlMD,sCAkMC","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 Solid\r\n */\r\n\r\nimport { CurveAndSurfaceLocationDetail, UVSurfaceLocationDetail } from \"../bspline/SurfaceLocationDetail\";\r\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { UVSurface } from \"./GeometryHandler\";\r\nimport { Plane3dByOriginAndVectors } from \"./Plane3dByOriginAndVectors\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n// cspell:word uparrow, rightarrow\r\n\r\n/**\r\n * A bilinear patch is a surface defined by its 4 corner points.\r\n * * The corner points do not have to be coplanar, but if they are, the quadrilateral should be convex to avoid a self-intersecting surface.\r\n * ```\r\n * equation\r\n * \\begin{matrix}\r\n * v\\text{-direction}\\\\\r\n * \\uparrow\\\\\r\n * \\text{point01} &\\cdots &\\text{A1} &\\cdots &\\text{point11}\\\\\r\n * \\vdots &&\\vdots &&\\vdots\\\\\r\n * \\text{B0} &\\cdots &\\text{X} &\\cdots &\\text{B1}\\\\\r\n * \\vdots &&\\vdots &&\\vdots\\\\\r\n * \\text{point00} &\\cdots &\\text{A0} &\\cdots &\\text{point10} &\\rightarrow~u\\text{-direction}\r\n * \\end{matrix}\r\n * ```\r\n * * To evaluate the point at (u,v), the following are equivalent:\r\n * * interpolate first with u then with v:\r\n * * A0 = interpolate between point00 and point10 at fraction u\r\n * * A1 = interpolate between point01 and point11 at fraction u\r\n * * X = interpolate between A0 and A1 at fraction v\r\n * * interpolate first with v then with u:\r\n * * B0 = interpolate between point00 and point01 at fraction v\r\n * * B1 = interpolate between point10 and point11 at fraction v\r\n * * X = interpolate between B0 and B1 at fraction u\r\n * * sum all at once:\r\n * * X = (1-u)(1-v)point00 + (1-u)(v)point01 + (u)(1-v)point10 + (u)(v)point11\r\n * @public\r\n */\r\nexport class BilinearPatch implements UVSurface {\r\n /** corner at parametric coordinate (0,0) */\r\n public point00: Point3d;\r\n /** corner at parametric coordinate (1,0) */\r\n public point10: Point3d;\r\n /** corner at parametric coordinate (0,1) */\r\n public point01: Point3d;\r\n /** corner at parametric coordinate (1,1) */\r\n public point11: Point3d;\r\n /**\r\n * Capture (not clone) corners to create a new BilinearPatch.\r\n * @param point00 Point at uv=0,0\r\n * @param point10 Point at uv=1,0\r\n * @param point10 Point at uv=0,1\r\n * @param point11 Point at uv=1,1\r\n */\r\n public constructor(point00: Point3d, point10: Point3d, point01: Point3d, point11: Point3d) {\r\n this.point00 = point00;\r\n this.point10 = point10;\r\n this.point01 = point01;\r\n this.point11 = point11;\r\n }\r\n /**\r\n * Clone (not capture) corners to create a new BilinearPatch.\r\n * @param point00 Point at uv=0,0\r\n * @param point10 Point at uv=1,0\r\n * @param point10 Point at uv=0,1\r\n * @param point11 Point at uv=1,1\r\n */\r\n public static create(point00: Point3d, point10: Point3d, point01: Point3d, point11: Point3d) {\r\n return new BilinearPatch(point00.clone(), point10.clone(), point01.clone(), point11.clone());\r\n }\r\n /** Create a patch from xyz values of the 4 corners. */\r\n public static createXYZ(\r\n x00: number, y00: number, z00: number,\r\n x10: number, y10: number, z10: number,\r\n x01: number, y01: number, z01: number,\r\n x11: number, y11: number, z11: number\r\n ) {\r\n return new BilinearPatch(\r\n Point3d.create(x00, y00, z00),\r\n Point3d.create(x10, y10, z10),\r\n Point3d.create(x01, y01, z01),\r\n Point3d.create(x11, y11, z11)\r\n );\r\n }\r\n /** Return a cloned patch. */\r\n public clone(): BilinearPatch {\r\n return new BilinearPatch(\r\n this.point00.clone(),\r\n this.point10.clone(),\r\n this.point01.clone(),\r\n this.point11.clone()\r\n );\r\n }\r\n /** Test equality of the 4 points. */\r\n public isAlmostEqual(other: BilinearPatch): boolean {\r\n return this.point00.isAlmostEqual(other.point00)\r\n && this.point10.isAlmostEqual(other.point10)\r\n && this.point01.isAlmostEqual(other.point01)\r\n && this.point11.isAlmostEqual(other.point11);\r\n }\r\n /** Apply the transform to each point. */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n transform.multiplyPoint3d(this.point00, this.point00);\r\n transform.multiplyPoint3d(this.point10, this.point10);\r\n transform.multiplyPoint3d(this.point01, this.point01);\r\n transform.multiplyPoint3d(this.point11, this.point11);\r\n return true;\r\n }\r\n /** Return a cloned and transformed patch. */\r\n public cloneTransformed(transform: Transform): BilinearPatch | undefined {\r\n const result = this.clone();\r\n result.tryTransformInPlace(transform);\r\n return result;\r\n }\r\n /** Extend a range by the range of the (optionally transformed) patch. */\r\n public extendRange(range: Range3d, transform?: Transform) {\r\n if (transform) {\r\n range.extendTransformedPoint(transform, this.point00);\r\n range.extendTransformedPoint(transform, this.point10);\r\n range.extendTransformedPoint(transform, this.point01);\r\n range.extendTransformedPoint(transform, this.point11);\r\n } else {\r\n range.extendPoint(this.point00);\r\n range.extendPoint(this.point10);\r\n range.extendPoint(this.point01);\r\n range.extendPoint(this.point11);\r\n }\r\n }\r\n /**\r\n * Convert fractional u and v coordinates to surface point\r\n * @param u fractional coordinate in u direction\r\n * @param v fractional coordinate in v direction\r\n * @param result optional pre-allocated point\r\n */\r\n public uvFractionToPoint(u: number, v: number, result?: Point3d): Point3d {\r\n const f00 = (1.0 - u) * (1.0 - v);\r\n const f10 = u * (1.0 - v);\r\n const f01 = (1.0 - u) * v;\r\n const f11 = u * v;\r\n return Point3d.create(\r\n f00 * this.point00.x + f10 * this.point10.x + f01 * this.point01.x + f11 * this.point11.x,\r\n f00 * this.point00.y + f10 * this.point10.y + f01 * this.point01.y + f11 * this.point11.y,\r\n f00 * this.point00.z + f10 * this.point10.z + f01 * this.point01.z + f11 * this.point11.z,\r\n result\r\n );\r\n }\r\n /** Evaluate as a uv surface, returning point and two derivative vectors.\r\n * @param u fractional coordinate in u direction\r\n * @param v fractional coordinate in v direction\r\n * @param result optional pre-allocated carrier for point and vectors\r\n */\r\n public uvFractionToPointAndTangents(u: number, v: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const u0 = 1.0 - u;\r\n const v0 = 1.0 - v;\r\n const f00 = u0 * v0;\r\n const f10 = u * v0;\r\n const f01 = u0 * v;\r\n const f11 = u * v;\r\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(\r\n f00 * this.point00.x + f10 * this.point10.x + f01 * this.point01.x + f11 * this.point11.x,\r\n f00 * this.point00.y + f10 * this.point10.y + f01 * this.point01.y + f11 * this.point11.y,\r\n f00 * this.point00.z + f10 * this.point10.z + f01 * this.point01.z + f11 * this.point11.z,\r\n // u derivative ..\r\n v0 * (this.point10.x - this.point00.x) + v * (this.point11.x - this.point01.x),\r\n v0 * (this.point10.y - this.point00.y) + v * (this.point11.y - this.point01.y),\r\n v0 * (this.point10.z - this.point00.z) + v * (this.point11.z - this.point01.z),\r\n // v derivative ..\r\n u0 * (this.point01.x - this.point00.x) + u * (this.point11.x - this.point10.x),\r\n u0 * (this.point01.y - this.point00.y) + u * (this.point11.y - this.point10.y),\r\n u0 * (this.point01.z - this.point00.z) + u * (this.point11.z - this.point10.z),\r\n result\r\n );\r\n }\r\n /** If data[iB][pivotColumn] is larger in absolute value than data[iA][pivotColumn], then swap rows iA and iB. */\r\n private static conditionalPivot(pivotColumn: number, data: Float64Array[], iA: number, iB: number) {\r\n if (Math.abs(data[iB][pivotColumn]) > Math.abs(data[iA][pivotColumn])) {\r\n const q = data[iA];\r\n data[iA] = data[iB];\r\n data[iB] = q;\r\n }\r\n }\r\n /**\r\n * Compute the points of intersection with a ray.\r\n * @param ray ray in space\r\n * @returns 1 or 2 points if there are intersections, undefined if no intersections\r\n */\r\n public intersectRay(ray: Ray3d): CurveAndSurfaceLocationDetail[] | undefined {\r\n const vectorU = this.point10.minus(this.point00);\r\n const vectorV = this.point01.minus(this.point00);\r\n const vectorW = this.point11.minus(this.point10);\r\n vectorW.subtractInPlace(vectorV);\r\n // We seek t, u, v such that:\r\n // `ray.origin + t*ray.direction = point00 + u*vectorU + v*vectorV + u*v*vectorW`\r\n // For typical direction as x, the scalar equation with coefficient order for arrays is:\r\n // `0 = -t*ray.direction.x + (point00.x - ray.origin.x) + u*vectorU.x + v*vectorV.x + u*v*vectorW.x`\r\n // and this particular equation is invoked to compute t when u and v are known.\r\n const coffs = [\r\n new Float64Array([-ray.direction.x, this.point00.x - ray.origin.x, vectorU.x, vectorV.x, vectorW.x]),\r\n new Float64Array([-ray.direction.y, this.point00.y - ray.origin.y, vectorU.y, vectorV.y, vectorW.y]),\r\n new Float64Array([-ray.direction.z, this.point00.z - ray.origin.z, vectorU.z, vectorV.z, vectorW.z]),\r\n ];\r\n // swap rows so that the equation with largest ray.direction coefficient is first.\r\n BilinearPatch.conditionalPivot(0, coffs, 0, 1);\r\n BilinearPatch.conditionalPivot(0, coffs, 0, 2);\r\n SmallSystem.eliminateFromPivot(coffs[0], 0, coffs[1], -1.0);\r\n SmallSystem.eliminateFromPivot(coffs[0], 0, coffs[2], -1.0);\r\n const uvArray = SmallSystem.solveBilinearPair(\r\n coffs[1][1], coffs[1][2], coffs[1][3], coffs[1][4],\r\n coffs[2][1], coffs[2][2], coffs[2][3], coffs[2][4]\r\n );\r\n if (uvArray) {\r\n const result: CurveAndSurfaceLocationDetail[] = [];\r\n for (const uv of uvArray) {\r\n const t = -(coffs[0][1] + coffs[0][2] * uv.x + (coffs[0][3] + coffs[0][4] * uv.x) * uv.y) / coffs[0][0];\r\n const point = ray.fractionToPoint(t);\r\n result.push(new CurveAndSurfaceLocationDetail(\r\n CurveLocationDetail.createRayFractionPoint(ray, t, point),\r\n UVSurfaceLocationDetail.createSurfaceUVPoint(this, uv, point))\r\n );\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /** Returns the larger of the u-direction edge lengths at v=0 and v=1. */\r\n public maxUEdgeLength(): number {\r\n return Geometry.maxXY(this.point00.distance(this.point10), this.point01.distance(this.point11));\r\n }\r\n /** Returns the larger of the v-direction edge lengths at u=0 and u=1. */\r\n public maxVEdgeLength(): number {\r\n return Geometry.maxXY(this.point00.distance(this.point01), this.point10.distance(this.point11));\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BilinearPatch.js","sourceRoot":"","sources":["../../../src/geometry3d/BilinearPatch.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,4EAA0G;AAC1G,sEAAmE;AACnE,0CAAuC;AACvC,yDAAsD;AAEtD,2EAAwE;AACxE,uDAA4C;AAK5C,kCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,aAAa;IASxB;;;;;;OAMG;IACH,YAAmB,OAAgB,EAAE,OAAgB,EAAE,OAAgB,EAAE,OAAgB;QACvF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,OAAgB,EAAE,OAAgB,EAAE,OAAgB,EAAE,OAAgB;QACzF,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,O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AC;gBACrC,MAAM,CAAC,IAAI,CAAC,IAAI,qDAA6B,CAC3C,yCAAmB,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EACzD,+CAAuB,CAAC,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAC/D,CAAC;aACH;YACD,OAAO,MAAM,CAAC;SACf;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,yEAAyE;IAClE,cAAc;QACnB,OAAO,mBAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,CAAC;IACD,yEAAyE;IAClE,cAAc;QACnB,OAAO,mBAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,CAAC;CACF;AAlMD,sCAkMC","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 Solid\r\n */\r\n\r\nimport { CurveAndSurfaceLocationDetail, UVSurfaceLocationDetail } from \"../bspline/SurfaceLocationDetail\";\r\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { SmallSystem } from \"../numerics/Polynomials\";\r\nimport { UVSurface } from \"./GeometryHandler\";\r\nimport { Plane3dByOriginAndVectors } from \"./Plane3dByOriginAndVectors\";\r\nimport { Point3d } from \"./Point3dVector3d\";\r\nimport { Range3d } from \"./Range\";\r\nimport { Ray3d } from \"./Ray3d\";\r\nimport { Transform } from \"./Transform\";\r\n\r\n// cspell:word uparrow, rightarrow\r\n\r\n/**\r\n * A bilinear patch is a surface defined by its 4 corner points.\r\n * * The corner points do not have to be coplanar, but if they are, the quadrilateral should be convex to avoid a self-intersecting surface.\r\n * ```\r\n * equation\r\n * \\begin{matrix}\r\n * v\\text{-direction}\\\\\r\n * \\uparrow\\\\\r\n * \\text{point01} &\\cdots &\\text{A1} &\\cdots &\\text{point11}\\\\\r\n * \\vdots &&\\vdots &&\\vdots\\\\\r\n * \\text{B0} &\\cdots &\\text{X} &\\cdots &\\text{B1}\\\\\r\n * \\vdots &&\\vdots &&\\vdots\\\\\r\n * \\text{point00} &\\cdots &\\text{A0} &\\cdots &\\text{point10} &\\rightarrow~u\\text{-direction}\r\n * \\end{matrix}\r\n * ```\r\n * * To evaluate the point at (u,v), the following are equivalent:\r\n * * interpolate first with u then with v:\r\n * * A0 = interpolate between point00 and point10 at fraction u\r\n * * A1 = interpolate between point01 and point11 at fraction u\r\n * * X = interpolate between A0 and A1 at fraction v\r\n * * interpolate first with v then with u:\r\n * * B0 = interpolate between point00 and point01 at fraction v\r\n * * B1 = interpolate between point10 and point11 at fraction v\r\n * * X = interpolate between B0 and B1 at fraction u\r\n * * sum all at once:\r\n * * X = (1-u)(1-v)point00 + (1-u)(v)point01 + (u)(1-v)point10 + (u)(v)point11\r\n * @public\r\n */\r\nexport class BilinearPatch implements UVSurface {\r\n /** corner at parametric coordinate (0,0) */\r\n public point00: Point3d;\r\n /** corner at parametric coordinate (1,0) */\r\n public point10: Point3d;\r\n /** corner at parametric coordinate (0,1) */\r\n public point01: Point3d;\r\n /** corner at parametric coordinate (1,1) */\r\n public point11: Point3d;\r\n /**\r\n * Capture (not clone) corners to create a new BilinearPatch.\r\n * @param point00 Point at uv=0,0\r\n * @param point10 Point at uv=1,0\r\n * @param point10 Point at uv=0,1\r\n * @param point11 Point at uv=1,1\r\n */\r\n public constructor(point00: Point3d, point10: Point3d, point01: Point3d, point11: Point3d) {\r\n this.point00 = point00;\r\n this.point10 = point10;\r\n this.point01 = point01;\r\n this.point11 = point11;\r\n }\r\n /**\r\n * Clone (not capture) corners to create a new BilinearPatch.\r\n * @param point00 Point at uv=0,0\r\n * @param point10 Point at uv=1,0\r\n * @param point10 Point at uv=0,1\r\n * @param point11 Point at uv=1,1\r\n */\r\n public static create(point00: Point3d, point10: Point3d, point01: Point3d, point11: Point3d) {\r\n return new BilinearPatch(point00.clone(), point10.clone(), point01.clone(), point11.clone());\r\n }\r\n /** Create a patch from xyz values of the 4 corners. */\r\n public static createXYZ(\r\n x00: number, y00: number, z00: number,\r\n x10: number, y10: number, z10: number,\r\n x01: number, y01: number, z01: number,\r\n x11: number, y11: number, z11: number,\r\n ) {\r\n return new BilinearPatch(\r\n Point3d.create(x00, y00, z00),\r\n Point3d.create(x10, y10, z10),\r\n Point3d.create(x01, y01, z01),\r\n Point3d.create(x11, y11, z11),\r\n );\r\n }\r\n /** Return a cloned patch. */\r\n public clone(): BilinearPatch {\r\n return new BilinearPatch(\r\n this.point00.clone(),\r\n this.point10.clone(),\r\n this.point01.clone(),\r\n this.point11.clone(),\r\n );\r\n }\r\n /** Test equality of the 4 points. */\r\n public isAlmostEqual(other: BilinearPatch): boolean {\r\n return this.point00.isAlmostEqual(other.point00)\r\n && this.point10.isAlmostEqual(other.point10)\r\n && this.point01.isAlmostEqual(other.point01)\r\n && this.point11.isAlmostEqual(other.point11);\r\n }\r\n /** Apply the transform to each point. */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n transform.multiplyPoint3d(this.point00, this.point00);\r\n transform.multiplyPoint3d(this.point10, this.point10);\r\n transform.multiplyPoint3d(this.point01, this.point01);\r\n transform.multiplyPoint3d(this.point11, this.point11);\r\n return true;\r\n }\r\n /** Return a cloned and transformed patch. */\r\n public cloneTransformed(transform: Transform): BilinearPatch | undefined {\r\n const result = this.clone();\r\n result.tryTransformInPlace(transform);\r\n return result;\r\n }\r\n /** Extend a range by the range of the (optionally transformed) patch. */\r\n public extendRange(range: Range3d, transform?: Transform) {\r\n if (transform) {\r\n range.extendTransformedPoint(transform, this.point00);\r\n range.extendTransformedPoint(transform, this.point10);\r\n range.extendTransformedPoint(transform, this.point01);\r\n range.extendTransformedPoint(transform, this.point11);\r\n } else {\r\n range.extendPoint(this.point00);\r\n range.extendPoint(this.point10);\r\n range.extendPoint(this.point01);\r\n range.extendPoint(this.point11);\r\n }\r\n }\r\n /**\r\n * Convert fractional u and v coordinates to surface point\r\n * @param u fractional coordinate in u direction\r\n * @param v fractional coordinate in v direction\r\n * @param result optional pre-allocated point\r\n */\r\n public uvFractionToPoint(u: number, v: number, result?: Point3d): Point3d {\r\n const f00 = (1.0 - u) * (1.0 - v);\r\n const f10 = u * (1.0 - v);\r\n const f01 = (1.0 - u) * v;\r\n const f11 = u * v;\r\n return Point3d.create(\r\n f00 * this.point00.x + f10 * this.point10.x + f01 * this.point01.x + f11 * this.point11.x,\r\n f00 * this.point00.y + f10 * this.point10.y + f01 * this.point01.y + f11 * this.point11.y,\r\n f00 * this.point00.z + f10 * this.point10.z + f01 * this.point01.z + f11 * this.point11.z,\r\n result,\r\n );\r\n }\r\n /** Evaluate as a uv surface, returning point and two derivative vectors.\r\n * @param u fractional coordinate in u direction\r\n * @param v fractional coordinate in v direction\r\n * @param result optional pre-allocated carrier for point and vectors\r\n */\r\n public uvFractionToPointAndTangents(u: number, v: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const u0 = 1.0 - u;\r\n const v0 = 1.0 - v;\r\n const f00 = u0 * v0;\r\n const f10 = u * v0;\r\n const f01 = u0 * v;\r\n const f11 = u * v;\r\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(\r\n f00 * this.point00.x + f10 * this.point10.x + f01 * this.point01.x + f11 * this.point11.x,\r\n f00 * this.point00.y + f10 * this.point10.y + f01 * this.point01.y + f11 * this.point11.y,\r\n f00 * this.point00.z + f10 * this.point10.z + f01 * this.point01.z + f11 * this.point11.z,\r\n // u derivative ..\r\n v0 * (this.point10.x - this.point00.x) + v * (this.point11.x - this.point01.x),\r\n v0 * (this.point10.y - this.point00.y) + v * (this.point11.y - this.point01.y),\r\n v0 * (this.point10.z - this.point00.z) + v * (this.point11.z - this.point01.z),\r\n // v derivative ..\r\n u0 * (this.point01.x - this.point00.x) + u * (this.point11.x - this.point10.x),\r\n u0 * (this.point01.y - this.point00.y) + u * (this.point11.y - this.point10.y),\r\n u0 * (this.point01.z - this.point00.z) + u * (this.point11.z - this.point10.z),\r\n result,\r\n );\r\n }\r\n /** If data[iB][pivotColumn] is larger in absolute value than data[iA][pivotColumn], then swap rows iA and iB. */\r\n private static conditionalPivot(pivotColumn: number, data: Float64Array[], iA: number, iB: number) {\r\n if (Math.abs(data[iB][pivotColumn]) > Math.abs(data[iA][pivotColumn])) {\r\n const q = data[iA];\r\n data[iA] = data[iB];\r\n data[iB] = q;\r\n }\r\n }\r\n /**\r\n * Compute the points of intersection with a ray.\r\n * @param ray ray in space\r\n * @returns 1 or 2 points if there are intersections, undefined if no intersections\r\n */\r\n public intersectRay(ray: Ray3d): CurveAndSurfaceLocationDetail[] | undefined {\r\n const vectorU = this.point10.minus(this.point00);\r\n const vectorV = this.point01.minus(this.point00);\r\n const vectorW = this.point11.minus(this.point10);\r\n vectorW.subtractInPlace(vectorV);\r\n // We seek t, u, v such that:\r\n // `ray.origin + t*ray.direction = point00 + u*vectorU + v*vectorV + u*v*vectorW`\r\n // For typical direction as x, the scalar equation with coefficient order for arrays is:\r\n // `0 = -t*ray.direction.x + (point00.x - ray.origin.x) + u*vectorU.x + v*vectorV.x + u*v*vectorW.x`\r\n // and this particular equation is invoked to compute t when u and v are known.\r\n const coffs = [\r\n new Float64Array([-ray.direction.x, this.point00.x - ray.origin.x, vectorU.x, vectorV.x, vectorW.x]),\r\n new Float64Array([-ray.direction.y, this.point00.y - ray.origin.y, vectorU.y, vectorV.y, vectorW.y]),\r\n new Float64Array([-ray.direction.z, this.point00.z - ray.origin.z, vectorU.z, vectorV.z, vectorW.z]),\r\n ];\r\n // swap rows so that the equation with largest ray.direction coefficient is first.\r\n BilinearPatch.conditionalPivot(0, coffs, 0, 1);\r\n BilinearPatch.conditionalPivot(0, coffs, 0, 2);\r\n SmallSystem.eliminateFromPivot(coffs[0], 0, coffs[1], -1.0);\r\n SmallSystem.eliminateFromPivot(coffs[0], 0, coffs[2], -1.0);\r\n const uvArray = SmallSystem.solveBilinearPair(\r\n coffs[1][1], coffs[1][2], coffs[1][3], coffs[1][4],\r\n coffs[2][1], coffs[2][2], coffs[2][3], coffs[2][4],\r\n );\r\n if (uvArray) {\r\n const result: CurveAndSurfaceLocationDetail[] = [];\r\n for (const uv of uvArray) {\r\n const t = -(coffs[0][1] + coffs[0][2] * uv.x + (coffs[0][3] + coffs[0][4] * uv.x) * uv.y) / coffs[0][0];\r\n const point = ray.fractionToPoint(t);\r\n result.push(new CurveAndSurfaceLocationDetail(\r\n CurveLocationDetail.createRayFractionPoint(ray, t, point),\r\n UVSurfaceLocationDetail.createSurfaceUVPoint(this, uv, point)),\r\n );\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /** Returns the larger of the u-direction edge lengths at v=0 and v=1. */\r\n public maxUEdgeLength(): number {\r\n return Geometry.maxXY(this.point00.distance(this.point10), this.point01.distance(this.point11));\r\n }\r\n /** Returns the larger of the v-direction edge lengths at u=0 and u=1. */\r\n public maxVEdgeLength(): number {\r\n return Geometry.maxXY(this.point00.distance(this.point01), this.point10.distance(this.point11));\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GrowableBlockedArray.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/GrowableBlockedArray.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,oBAAoB;IAC/B,+CAA+C;IAC/C,SAAS,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,CAA4B;IAC5D;;;;OAIG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM;IAG3E,uEAAuE;IAChE,KAAK;IACZ,kDAAkD;IAC3C,aAAa;IAGpB,+CAA+C;IACxC,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,iBAAiB,GAAE,OAAc;IASnF;;;OAGG;IACI,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE;IAQjC;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IASjC,qCAAqC;IAC9B,QAAQ;IAIf,gFAAgF;IAChF,SAAS,CAAC,uBAAuB,CAAC,UAAU,EAAE,MAAM;IACpD,wHAAwH;IACjH,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKvF,oFAAoF;IAC7E,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAGpE;;;;;OAKG;WACW,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM;IAWxG,+EAA+E;IACxE,kBAAkB,CAAC,aAAa,GAAE,uBAAwH,GAAG,WAAW;IAe/K,qFAAqF;IAC9E,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;IAa9E,2HAA2H;IACpH,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAYhH"}
|
|
@@ -165,7 +165,7 @@ class GrowableBlockedArray {
|
|
|
165
165
|
return ia - ib; // so original order is maintained among duplicates !!!!
|
|
166
166
|
}
|
|
167
167
|
/** Return an array of block indices sorted per compareLexicalBlock function */
|
|
168
|
-
sortIndicesLexical(compareBlocks = GrowableBlockedArray.compareLexicalBlock) {
|
|
168
|
+
sortIndicesLexical(compareBlocks = (dataArray, size, iA, iB) => GrowableBlockedArray.compareLexicalBlock(dataArray, size, iA, iB)) {
|
|
169
169
|
const n = this._inUse;
|
|
170
170
|
// let numCompare = 0;
|
|
171
171
|
const result = new Uint32Array(n);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GrowableBlockedArray.js","sourceRoot":"","sources":["../../../src/geometry3d/GrowableBlockedArray.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;;;GAIG;AACH,MAAa,oBAAoB;IAc/B;;;;;;;OAOG;IACH,YAAmB,SAAiB,EAAE,gBAAwB,CAAC,EAAE,YAAqB;QACpF,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,GAAG,CAAC,SAAS,KAAK,YAAY,IAAI,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAChG,CAAC;IAED;;;;;OAKG;IACO,QAAQ,CAAC,MAA+B,EAAE,WAAoB,EAAE,UAAmB;QAC3F,qDAAqD;QACrD,IAAI,QAAQ,GAAG,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9E,IAAI,QAAQ,GAAG,CAAC;YACd,QAAQ,GAAG,CAAC,CAAC;QACf,IAAI,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM;YAC/B,OAAO,EAAC,KAAK,EAAE,CAAC,EAAE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CAAC;QACrD,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAClC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAChC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;SACb;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;CACF;AAhND,oDAgNC","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/** @packageDocumentation\r\n * @module ArraysAndInterfaces\r\n */\r\n\r\nimport { BlockComparisonFunction } from \"./GrowableFloat64Array\";\r\n\r\n/**\r\n * Array of contiguous doubles, indexed by block number and index within block.\r\n * * This is essentially a rectangular matrix (two dimensional array), with each block being a row of the matrix.\r\n * @public\r\n */\r\nexport class GrowableBlockedArray {\r\n /** underlying contiguous, oversized buffer. */\r\n protected _data: Float64Array;\r\n /** Number of blocks (matrix rows) in use. */\r\n protected _inUse: number;\r\n /** number of numbers per block in the array.\r\n * * If viewing the array as a two dimensional array, this is the row size.\r\n */\r\n protected _blockSize: number; // positive integer !!!\r\n /**\r\n * multiplier used by ensureBlockCapacity to expand requested reallocation size\r\n */\r\n protected _growthFactor: number;\r\n\r\n /**\r\n * Construct an array whose contents are in blocked (row-major) order, possibly with extra capacity.\r\n * * Total capacity is `this._data.length`\r\n * * Actual in-use count is `this._inUse * this._blockSize`\r\n * @param blockSize number of entries in each block, i.e., row size\r\n * @param initialBlocks initial capacity in blocks (default 8)\r\n * @param growthFactor used by ensureBlockCapacity to expand requested reallocation size (default 1.5)\r\n */\r\n public constructor(blockSize: number, initialBlocks: number = 8, growthFactor?: number) {\r\n this._data = new Float64Array(initialBlocks * blockSize);\r\n this._inUse = 0;\r\n this._blockSize = blockSize > 0 ? blockSize : 1;\r\n this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;\r\n }\r\n\r\n /** Copy data from source array. Does not reallocate or change active block count.\r\n * @param source array to copy from\r\n * @param sourceCount copy the first sourceCount blocks; all blocks if undefined\r\n * @param destOffset copy to instance array starting at this block index; zero if undefined\r\n * @return count and offset of blocks copied\r\n */\r\n protected copyData(source: Float64Array | number[], sourceCount?: number, destOffset?: number): {count: number, offset: number} {\r\n // validate inputs and convert from blocks to entries\r\n let myOffset = (undefined !== destOffset) ? destOffset * this.numPerBlock : 0;\r\n if (myOffset < 0)\r\n myOffset = 0;\r\n if (myOffset >= this._data.length)\r\n return {count: 0, offset: 0};\r\n let myCount = (undefined !== sourceCount) ? sourceCount * this.numPerBlock : source.length;\r\n if (myCount > 0) {\r\n if (myCount > source.length)\r\n myCount = source.length;\r\n if (myOffset + myCount > this._data.length)\r\n myCount = this._data.length - myOffset;\r\n if (myCount % this.numPerBlock !== 0)\r\n myCount -= myCount % this.numPerBlock;\r\n }\r\n if (myCount <= 0)\r\n return {count: 0, offset: 0};\r\n if (myCount === source.length)\r\n this._data.set(source, myOffset);\r\n else if (source instanceof Float64Array)\r\n this._data.set(source.subarray(0, myCount), myOffset);\r\n else\r\n this._data.set(source.slice(0, myCount), myOffset);\r\n return {count: myCount / this.numPerBlock, offset: myOffset / this.numPerBlock};\r\n }\r\n\r\n /**\r\n * Make a copy of the (active) blocks in this array.\r\n * (The clone does NOT get excess capacity)\r\n */\r\n public clone(): GrowableBlockedArray {\r\n const newBlocks = new GrowableBlockedArray(this.numPerBlock, this.numBlocks, this._growthFactor);\r\n newBlocks.copyData(this._data, this.numBlocks);\r\n newBlocks._inUse = this.numBlocks;\r\n return newBlocks;\r\n }\r\n\r\n /** computed property: length (in blocks, not doubles) */\r\n public get length(): number { return this._inUse; }\r\n /** computed property: length (in blocks, not doubles) */\r\n public get numBlocks(): number { return this._inUse; }\r\n /** property: number of data values per block */\r\n public get numPerBlock(): number { return this._blockSize; }\r\n /**\r\n * Return a single value indexed within a block. Indices are unchecked.\r\n * @param blockIndex index of block to read\r\n * @param indexInBlock offset within the block\r\n */\r\n public getWithinBlock(blockIndex: number, indexWithinBlock: number): number {\r\n return this._data[blockIndex * this._blockSize + indexWithinBlock];\r\n }\r\n /** clear the block count to zero, but maintain the allocated memory */\r\n public clear() { this._inUse = 0; }\r\n /** Return the capacity in blocks (not doubles) */\r\n public blockCapacity() {\r\n return this._data.length / this._blockSize;\r\n }\r\n /** ensure capacity (in blocks, not doubles) */\r\n public ensureBlockCapacity(blockCapacity: number, applyGrowthFactor: boolean = true) {\r\n if (blockCapacity > this.blockCapacity()) {\r\n if (applyGrowthFactor)\r\n blockCapacity *= this._growthFactor;\r\n const prevData = this._data;\r\n this._data = new Float64Array(blockCapacity * this._blockSize);\r\n this.copyData(prevData, this._inUse);\r\n }\r\n }\r\n /** Add a new block of data.\r\n * * If newData has fewer than numPerBlock entries, the remaining part of the new block is zeros.\r\n * * If newData has more entries, only the first numPerBlock are taken.\r\n */\r\n public addBlock(newData: number[]) {\r\n const k0 = this.newBlockIndex();\r\n let numValue = newData.length;\r\n if (numValue > this._blockSize)\r\n numValue = this._blockSize;\r\n for (let i = 0; i < numValue; i++)\r\n this._data[k0 + i] = newData[i];\r\n }\r\n /**\r\n * Return the starting index of a block of (zero-initialized) doubles at the end.\r\n *\r\n * * this.data is reallocated if needed to include the new block.\r\n * * The inUse count is incremented to include the new block.\r\n * * The returned block is an index to the Float64Array (not a block index)\r\n */\r\n protected newBlockIndex(): number {\r\n const index = this._blockSize * this._inUse;\r\n if ((index + 1) > this._data.length)\r\n this.ensureBlockCapacity(1 + this._inUse);\r\n this._inUse++;\r\n for (let i = index; i < index + this._blockSize; i++)\r\n this._data[i] = 0.0;\r\n return index;\r\n }\r\n /** reduce the block count by one. */\r\n public popBlock() {\r\n if (this._inUse > 0)\r\n this._inUse--;\r\n }\r\n /** convert a block index to the simple index to the underlying Float64Array. */\r\n protected blockIndexToDoubleIndex(blockIndex: number) { return this._blockSize * blockIndex; }\r\n /** Access a single double at offset within a block, with index checking and return undefined if indexing is invalid. */\r\n public checkedComponent(blockIndex: number, componentIndex: number): number | undefined {\r\n if (blockIndex >= this._inUse || blockIndex < 0 || componentIndex < 0 || componentIndex >= this._blockSize)\r\n return undefined;\r\n return this._data[this._blockSize * blockIndex + componentIndex];\r\n }\r\n /** Access a single double at offset within a block. This has no index checking. */\r\n public component(blockIndex: number, componentIndex: number): number {\r\n return this._data[this._blockSize * blockIndex + componentIndex];\r\n }\r\n /** compare two blocks in simple lexical order.\r\n * @param data data array\r\n * @param blockSize number of items to compare\r\n * @param ia raw index (not block index) of first block\r\n * @param ib raw index (not block index) of second block\r\n */\r\n public static compareLexicalBlock(data: Float64Array, blockSize: number, ia: number, ib: number): number {\r\n let ax = 0;\r\n let bx = 0;\r\n for (let i = 0; i < blockSize; i++) {\r\n ax = data[ia + i];\r\n bx = data[ib + i];\r\n if (ax > bx) return 1;\r\n if (ax < bx) return -1;\r\n }\r\n return ia - ib; // so original order is maintained among duplicates !!!!\r\n }\r\n /** Return an array of block indices sorted per compareLexicalBlock function */\r\n public sortIndicesLexical(compareBlocks: BlockComparisonFunction = GrowableBlockedArray.compareLexicalBlock): Uint32Array {\r\n const n = this._inUse;\r\n // let numCompare = 0;\r\n const result = new Uint32Array(n);\r\n const data = this._data;\r\n const blockSize = this._blockSize;\r\n for (let i = 0; i < n; i++)result[i] = i;\r\n result.sort(\r\n (blockIndexA: number, blockIndexB: number) => {\r\n // numCompare++;\r\n return compareBlocks(data, blockSize, blockIndexA * blockSize, blockIndexB * blockSize);\r\n });\r\n // console.log (n, numCompare);\r\n return result;\r\n }\r\n /** Return the distance (hypotenuse=sqrt(summed squares)) between indicated blocks */\r\n public distanceBetweenBlocks(blockIndexA: number, blockIndexB: number): number {\r\n let dd = 0.0;\r\n let iA = this.blockIndexToDoubleIndex(blockIndexA);\r\n let iB = this.blockIndexToDoubleIndex(blockIndexB);\r\n let a = 0;\r\n const data = this._data;\r\n for (let i = 0; i < this._blockSize; i++) {\r\n a = data[iA++] - data[iB++];\r\n dd += a * a;\r\n }\r\n return Math.sqrt(dd);\r\n }\r\n\r\n /** Return the distance (hypotenuse=sqrt(summed squares)) between block entries `iBegin <= i < iEnd` of indicated blocks */\r\n public distanceBetweenSubBlocks(blockIndexA: number, blockIndexB: number, iBegin: number, iEnd: number): number {\r\n let dd = 0.0;\r\n const iA = this.blockIndexToDoubleIndex(blockIndexA);\r\n const iB = this.blockIndexToDoubleIndex(blockIndexB);\r\n let a = 0;\r\n const data = this._data;\r\n for (let i = iBegin; i < iEnd; i++) {\r\n a = data[iA + i] - data[iB + i];\r\n dd += a * a;\r\n }\r\n return Math.sqrt(dd);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GrowableBlockedArray.js","sourceRoot":"","sources":["../../../src/geometry3d/GrowableBlockedArray.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;;;GAIG;AACH,MAAa,oBAAoB;IAc/B;;;;;;;OAOG;IACH,YAAmB,SAAiB,EAAE,gBAAwB,CAAC,EAAE,YAAqB;QACpF,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,GAAG,CAAC,SAAS,KAAK,YAAY,IAAI,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAChG,CAAC;IAED;;;;;OAK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CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;YACxC,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5B,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;SACb;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;IAED,2HAA2H;IACpH,wBAAwB,CAAC,WAAmB,EAAE,WAAmB,EAAE,MAAc,EAAE,IAAY;QACpG,IAAI,EAAE,GAAG,GAAG,CAAC;QACb,MAAM,EAAE,GAAG,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACrD,MAAM,EAAE,GAAG,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAClC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAChC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;SACb;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;CACF;AAhND,oDAgNC","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/** @packageDocumentation\r\n * @module ArraysAndInterfaces\r\n */\r\n\r\nimport { BlockComparisonFunction } from \"./GrowableFloat64Array\";\r\n\r\n/**\r\n * Array of contiguous doubles, indexed by block number and index within block.\r\n * * This is essentially a rectangular matrix (two dimensional array), with each block being a row of the matrix.\r\n * @public\r\n */\r\nexport class GrowableBlockedArray {\r\n /** underlying contiguous, oversized buffer. */\r\n protected _data: Float64Array;\r\n /** Number of blocks (matrix rows) in use. */\r\n protected _inUse: number;\r\n /** number of numbers per block in the array.\r\n * * If viewing the array as a two dimensional array, this is the row size.\r\n */\r\n protected _blockSize: number; // positive integer !!!\r\n /**\r\n * multiplier used by ensureBlockCapacity to expand requested reallocation size\r\n */\r\n protected _growthFactor: number;\r\n\r\n /**\r\n * Construct an array whose contents are in blocked (row-major) order, possibly with extra capacity.\r\n * * Total capacity is `this._data.length`\r\n * * Actual in-use count is `this._inUse * this._blockSize`\r\n * @param blockSize number of entries in each block, i.e., row size\r\n * @param initialBlocks initial capacity in blocks (default 8)\r\n * @param growthFactor used by ensureBlockCapacity to expand requested reallocation size (default 1.5)\r\n */\r\n public constructor(blockSize: number, initialBlocks: number = 8, growthFactor?: number) {\r\n this._data = new Float64Array(initialBlocks * blockSize);\r\n this._inUse = 0;\r\n this._blockSize = blockSize > 0 ? blockSize : 1;\r\n this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;\r\n }\r\n\r\n /** Copy data from source array. Does not reallocate or change active block count.\r\n * @param source array to copy from\r\n * @param sourceCount copy the first sourceCount blocks; all blocks if undefined\r\n * @param destOffset copy to instance array starting at this block index; zero if undefined\r\n * @return count and offset of blocks copied\r\n */\r\n protected copyData(source: Float64Array | number[], sourceCount?: number, destOffset?: number): {count: number, offset: number} {\r\n // validate inputs and convert from blocks to entries\r\n let myOffset = (undefined !== destOffset) ? destOffset * this.numPerBlock : 0;\r\n if (myOffset < 0)\r\n myOffset = 0;\r\n if (myOffset >= this._data.length)\r\n return {count: 0, offset: 0};\r\n let myCount = (undefined !== sourceCount) ? sourceCount * this.numPerBlock : source.length;\r\n if (myCount > 0) {\r\n if (myCount > source.length)\r\n myCount = source.length;\r\n if (myOffset + myCount > this._data.length)\r\n myCount = this._data.length - myOffset;\r\n if (myCount % this.numPerBlock !== 0)\r\n myCount -= myCount % this.numPerBlock;\r\n }\r\n if (myCount <= 0)\r\n return {count: 0, offset: 0};\r\n if (myCount === source.length)\r\n this._data.set(source, myOffset);\r\n else if (source instanceof Float64Array)\r\n this._data.set(source.subarray(0, myCount), myOffset);\r\n else\r\n this._data.set(source.slice(0, myCount), myOffset);\r\n return {count: myCount / this.numPerBlock, offset: myOffset / this.numPerBlock};\r\n }\r\n\r\n /**\r\n * Make a copy of the (active) blocks in this array.\r\n * (The clone does NOT get excess capacity)\r\n */\r\n public clone(): GrowableBlockedArray {\r\n const newBlocks = new GrowableBlockedArray(this.numPerBlock, this.numBlocks, this._growthFactor);\r\n newBlocks.copyData(this._data, this.numBlocks);\r\n newBlocks._inUse = this.numBlocks;\r\n return newBlocks;\r\n }\r\n\r\n /** computed property: length (in blocks, not doubles) */\r\n public get length(): number { return this._inUse; }\r\n /** computed property: length (in blocks, not doubles) */\r\n public get numBlocks(): number { return this._inUse; }\r\n /** property: number of data values per block */\r\n public get numPerBlock(): number { return this._blockSize; }\r\n /**\r\n * Return a single value indexed within a block. Indices are unchecked.\r\n * @param blockIndex index of block to read\r\n * @param indexInBlock offset within the block\r\n */\r\n public getWithinBlock(blockIndex: number, indexWithinBlock: number): number {\r\n return this._data[blockIndex * this._blockSize + indexWithinBlock];\r\n }\r\n /** clear the block count to zero, but maintain the allocated memory */\r\n public clear() { this._inUse = 0; }\r\n /** Return the capacity in blocks (not doubles) */\r\n public blockCapacity() {\r\n return this._data.length / this._blockSize;\r\n }\r\n /** ensure capacity (in blocks, not doubles) */\r\n public ensureBlockCapacity(blockCapacity: number, applyGrowthFactor: boolean = true) {\r\n if (blockCapacity > this.blockCapacity()) {\r\n if (applyGrowthFactor)\r\n blockCapacity *= this._growthFactor;\r\n const prevData = this._data;\r\n this._data = new Float64Array(blockCapacity * this._blockSize);\r\n this.copyData(prevData, this._inUse);\r\n }\r\n }\r\n /** Add a new block of data.\r\n * * If newData has fewer than numPerBlock entries, the remaining part of the new block is zeros.\r\n * * If newData has more entries, only the first numPerBlock are taken.\r\n */\r\n public addBlock(newData: number[]) {\r\n const k0 = this.newBlockIndex();\r\n let numValue = newData.length;\r\n if (numValue > this._blockSize)\r\n numValue = this._blockSize;\r\n for (let i = 0; i < numValue; i++)\r\n this._data[k0 + i] = newData[i];\r\n }\r\n /**\r\n * Return the starting index of a block of (zero-initialized) doubles at the end.\r\n *\r\n * * this.data is reallocated if needed to include the new block.\r\n * * The inUse count is incremented to include the new block.\r\n * * The returned block is an index to the Float64Array (not a block index)\r\n */\r\n protected newBlockIndex(): number {\r\n const index = this._blockSize * this._inUse;\r\n if ((index + 1) > this._data.length)\r\n this.ensureBlockCapacity(1 + this._inUse);\r\n this._inUse++;\r\n for (let i = index; i < index + this._blockSize; i++)\r\n this._data[i] = 0.0;\r\n return index;\r\n }\r\n /** reduce the block count by one. */\r\n public popBlock() {\r\n if (this._inUse > 0)\r\n this._inUse--;\r\n }\r\n /** convert a block index to the simple index to the underlying Float64Array. */\r\n protected blockIndexToDoubleIndex(blockIndex: number) { return this._blockSize * blockIndex; }\r\n /** Access a single double at offset within a block, with index checking and return undefined if indexing is invalid. */\r\n public checkedComponent(blockIndex: number, componentIndex: number): number | undefined {\r\n if (blockIndex >= this._inUse || blockIndex < 0 || componentIndex < 0 || componentIndex >= this._blockSize)\r\n return undefined;\r\n return this._data[this._blockSize * blockIndex + componentIndex];\r\n }\r\n /** Access a single double at offset within a block. This has no index checking. */\r\n public component(blockIndex: number, componentIndex: number): number {\r\n return this._data[this._blockSize * blockIndex + componentIndex];\r\n }\r\n /** compare two blocks in simple lexical order.\r\n * @param data data array\r\n * @param blockSize number of items to compare\r\n * @param ia raw index (not block index) of first block\r\n * @param ib raw index (not block index) of second block\r\n */\r\n public static compareLexicalBlock(data: Float64Array, blockSize: number, ia: number, ib: number): number {\r\n let ax = 0;\r\n let bx = 0;\r\n for (let i = 0; i < blockSize; i++) {\r\n ax = data[ia + i];\r\n bx = data[ib + i];\r\n if (ax > bx) return 1;\r\n if (ax < bx) return -1;\r\n }\r\n return ia - ib; // so original order is maintained among duplicates !!!!\r\n }\r\n /** Return an array of block indices sorted per compareLexicalBlock function */\r\n public sortIndicesLexical(compareBlocks: BlockComparisonFunction = (dataArray, size, iA, iB) => GrowableBlockedArray.compareLexicalBlock(dataArray, size, iA, iB)): Uint32Array {\r\n const n = this._inUse;\r\n // let numCompare = 0;\r\n const result = new Uint32Array(n);\r\n const data = this._data;\r\n const blockSize = this._blockSize;\r\n for (let i = 0; i < n; i++)result[i] = i;\r\n result.sort(\r\n (blockIndexA: number, blockIndexB: number) => {\r\n // numCompare++;\r\n return compareBlocks(data, blockSize, blockIndexA * blockSize, blockIndexB * blockSize);\r\n });\r\n // console.log (n, numCompare);\r\n return result;\r\n }\r\n /** Return the distance (hypotenuse=sqrt(summed squares)) between indicated blocks */\r\n public distanceBetweenBlocks(blockIndexA: number, blockIndexB: number): number {\r\n let dd = 0.0;\r\n let iA = this.blockIndexToDoubleIndex(blockIndexA);\r\n let iB = this.blockIndexToDoubleIndex(blockIndexB);\r\n let a = 0;\r\n const data = this._data;\r\n for (let i = 0; i < this._blockSize; i++) {\r\n a = data[iA++] - data[iB++];\r\n dd += a * a;\r\n }\r\n return Math.sqrt(dd);\r\n }\r\n\r\n /** Return the distance (hypotenuse=sqrt(summed squares)) between block entries `iBegin <= i < iEnd` of indicated blocks */\r\n public distanceBetweenSubBlocks(blockIndexA: number, blockIndexB: number, iBegin: number, iEnd: number): number {\r\n let dd = 0.0;\r\n const iA = this.blockIndexToDoubleIndex(blockIndexA);\r\n const iB = this.blockIndexToDoubleIndex(blockIndexB);\r\n let a = 0;\r\n const data = this._data;\r\n for (let i = iBegin; i < iEnd; i++) {\r\n a = data[iA + i] - data[iB + i];\r\n dd += a * a;\r\n }\r\n return Math.sqrt(dd);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GrowableFloat64Array.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/GrowableFloat64Array.ts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AAM;IAG9C,sDAAsD;IAC/C,KAAK;IAGZ,oDAAoD;IAC7C,IAAI;IAGX,2BAA2B;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAI5C;;;;OAIG;IACI,IAAI,CAAC,aAAa,GAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAqD;IAapG;;;;;OAKG;IACI,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAa9C;;;OAGG;IACI,0BAA0B,CAAC,SAAS,GAAE,MAAY;CAmB1D"}
|
|
@@ -215,7 +215,7 @@ class GrowableFloat64Array {
|
|
|
215
215
|
* * Uses insertion sort -- fine for small arrays (less than 30), slow for larger arrays
|
|
216
216
|
* @param compareMethod comparison method
|
|
217
217
|
*/
|
|
218
|
-
sort(compareMethod = GrowableFloat64Array.compare) {
|
|
218
|
+
sort(compareMethod = (a, b) => GrowableFloat64Array.compare(a, b)) {
|
|
219
219
|
for (let i = 0; i < this._inUse; i++) {
|
|
220
220
|
for (let j = i + 1; j < this._inUse; j++) {
|
|
221
221
|
const tempI = this._data[i];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GrowableFloat64Array.js","sourceRoot":"","sources":["../../../src/geometry3d/GrowableFloat64Array.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAgB/F;;;;;;;;GAQG;AACH,MAAa,oBAAoB;IAK/B;;;OAGG;IACH,YAAY,kBAA0B,CAAC,EAAE,YAAqB;QAC5D,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,eAAe,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,aAAa,GAAG,CAAC,SAAS,KAAK,YAAY,IAAI,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAChG,CAAC;IAED;;;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,CAAC,GAAG,CAAC,CAAC;SACzB;QACD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,0BAA0B,CAAC,YAAoB,GAAG;QACvD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC;YACT,OAAO;QAET,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,CAAC;QACN,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACZ,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE;gBAC/B,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;gBACxB,CAAC,GAAG,CAAC,CAAC;aACP;SACF;QACD,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;CAEF;AAzQD,oDAyQC","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 ArraysAndInterfaces\r\n */\r\n\r\n/**\r\n * Type for a OptionalGrowableFloat64Array or undefined.\r\n * @public\r\n */\r\nexport type OptionalGrowableFloat64Array = GrowableFloat64Array | undefined;\r\n/**\r\n * Signature for a function which does lexical comparison of `blockSize` consecutive values as 2 starting indices.\r\n * @public\r\n */\r\nexport type BlockComparisonFunction = (data: Float64Array, blockSize: number, index0: number, index1: number) => number;\r\n/**\r\n * A `GrowableFloat64Array` is Float64Array accompanied by a count of how many of the array's entries are considered in use.\r\n * * In C++ terms, this is like an std::vector\r\n * * As entries are added to the array, the buffer is reallocated as needed to accommodate.\r\n * * The reallocations leave unused space to accept further additional entries without reallocation.\r\n * * The `length` property returns the number of entries in use.\r\n * * the `capacity` property returns the (usually larger) length of the (over-allocated) Float64Array.\r\n * @public\r\n */\r\nexport class GrowableFloat64Array {\r\n private _data: Float64Array;\r\n private _inUse: number;\r\n private _growthFactor: number;\r\n\r\n /** Construct a GrowableFloat64Array.\r\n * @param initialCapacity initial capacity (default 8)\r\n * @param growthFactor used by ensureCapacity to expand requested reallocation size (default 1.5)\r\n */\r\n constructor(initialCapacity: number = 8, growthFactor?: number) {\r\n this._data = new Float64Array(initialCapacity);\r\n this._inUse = 0;\r\n this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;\r\n }\r\n\r\n /** Copy data from source array. Does not reallocate or change active entry count.\r\n * @param source array to copy from\r\n * @param sourceCount copy the first sourceCount entries; all entries if undefined\r\n * @param destOffset copy to instance array starting at this index; zero if undefined\r\n * @return count and offset of entries copied\r\n */\r\n protected copyData(source: Float64Array | number[], sourceCount?: number, destOffset?: number): {count: number, offset: number} {\r\n let myOffset = destOffset ?? 0;\r\n if (myOffset < 0)\r\n myOffset = 0;\r\n if (myOffset >= this._data.length)\r\n return {count: 0, offset: 0};\r\n let myCount = sourceCount ?? source.length;\r\n if (myCount > 0) {\r\n if (myCount > source.length)\r\n myCount = source.length;\r\n if (myOffset + myCount > this._data.length)\r\n myCount = this._data.length - myOffset;\r\n }\r\n if (myCount <= 0)\r\n return {count: 0, offset: 0};\r\n if (myCount === source.length)\r\n this._data.set(source, myOffset);\r\n else if (source instanceof Float64Array)\r\n this._data.set(source.subarray(0, myCount), myOffset);\r\n else\r\n this._data.set(source.slice(0, myCount), myOffset);\r\n return {count: myCount, offset: myOffset};\r\n }\r\n\r\n /**\r\n * Create a GrowableFloat64Array with given contents.\r\n * @param contents data to copy into the array\r\n */\r\n public static create(contents: Float64Array | number[]): GrowableFloat64Array {\r\n const out = new GrowableFloat64Array(contents.length);\r\n out.copyData(contents);\r\n out._inUse = contents.length;\r\n return out;\r\n }\r\n /** sort-compatible comparison.\r\n * * Returns `(a-b)` which is\r\n * * negative if `a<b`\r\n * * zero if `a === b` (with exact equality)\r\n * * positive if `a>b`\r\n */\r\n public static compare(a: any, b: any): number {\r\n return a - b;\r\n }\r\n /** Return a new array with\r\n * * All active entries copied from this instance\r\n * * optionally trimmed capacity to the active length or replicate the capacity and unused space.\r\n */\r\n public clone(maintainExcessCapacity: boolean = false): GrowableFloat64Array {\r\n const out = new GrowableFloat64Array(maintainExcessCapacity ? this.capacity() : this._inUse);\r\n out.copyData(this._data, this._inUse);\r\n out._inUse = this._inUse;\r\n return out;\r\n }\r\n /**\r\n * Returns the number of entries in use.\r\n * * Note that this is typically smaller than the length of the length of the supporting `Float64Array`\r\n */\r\n public get length() {\r\n return this._inUse;\r\n }\r\n /**\r\n * Set the value at specified index.\r\n * @param index index of entry to set\r\n * @param value value to set\r\n */\r\n public setAtUncheckedIndex(index: number, value: number) {\r\n this._data[index] = value;\r\n }\r\n\r\n /**\r\n * Move the value at index i to index j.\r\n * @param i source index\r\n * @param j destination index.\r\n */\r\n public move(i: number, j: number) {\r\n this._data[j] = this._data[i];\r\n }\r\n /**\r\n * swap the values at indices i and j\r\n * @param i first index\r\n * @param j second index\r\n */\r\n public swap(i: number, j: number) {\r\n const a = this._data[i];\r\n this._data[i] = this._data[j];\r\n this._data[j] = a;\r\n }\r\n\r\n /**\r\n * append a single value to the array.\r\n * @param toPush value to append to the active array.\r\n */\r\n public push(toPush: number) {\r\n this.ensureCapacity(this._inUse + 1);\r\n this._data[this._inUse] = toPush;\r\n this._inUse++;\r\n }\r\n /**\r\n * Push each value from an array.\r\n * @param data array of values to push\r\n */\r\n public pushArray(data: Float64Array | number[]) {\r\n this.ensureCapacity(this._inUse + data.length);\r\n this.copyData(data, data.length, this._inUse);\r\n this._inUse += data.length;\r\n }\r\n /** Push `numToCopy` consecutive values starting at `copyFromIndex`. */\r\n public pushBlockCopy(copyFromIndex: number, numToCopy: number) {\r\n if (copyFromIndex >= 0 && copyFromIndex < this._inUse && numToCopy > 0 && copyFromIndex + numToCopy <= this._inUse) {\r\n this.ensureCapacity(this._inUse + numToCopy);\r\n this._data.copyWithin(this._inUse, copyFromIndex, copyFromIndex + numToCopy);\r\n this._inUse += numToCopy;\r\n }\r\n }\r\n /** Clear the array to 0 length. The underlying memory remains allocated for reuse. */\r\n public clear() {\r\n this._inUse = 0;\r\n }\r\n /**\r\n * Returns the number of entries in the supporting Float64Array buffer.\r\n * * This number can be larger than the `length` property.\r\n */\r\n public capacity() {\r\n return this._data.length;\r\n }\r\n /**\r\n * * If the capacity (Float64Array length) is less than or equal to the requested newCapacity, do nothing.\r\n * * If the requested newCapacity is larger than the existing capacity, reallocate to larger capacity, and copy existing values.\r\n * @param newCapacity size of new array\r\n * @param applyGrowthFactor whether to apply the growth factor to newCapacity when reallocating\r\n */\r\n public ensureCapacity(newCapacity: number, applyGrowthFactor: boolean = true) {\r\n if (newCapacity > this.capacity()) {\r\n if (applyGrowthFactor)\r\n newCapacity *= this._growthFactor;\r\n const prevData = this._data;\r\n this._data = new Float64Array(newCapacity);\r\n this.copyData(prevData, this._inUse);\r\n }\r\n }\r\n /**\r\n * * If newLength is less than current length, just reset current length to newLength, effectively trimming active entries but preserving original capacity.\r\n * * If newLength is greater than current length, reallocate to (exactly) newLength, copy existing entries, and pad with padValue up to newLength.\r\n * @param newLength new data count\r\n * @param padValue value to use for padding if the length increases.\r\n */\r\n public resize(newLength: number, padValue: number = 0) {\r\n if (newLength >= 0 && newLength < this._inUse)\r\n this._inUse = newLength;\r\n else if (newLength > this._inUse) {\r\n this.ensureCapacity(newLength, false);\r\n this._data.fill(padValue, this._inUse);\r\n this._inUse = newLength;\r\n }\r\n }\r\n /**\r\n * * Reduce the length by one.\r\n * * Note that there is no method return value -- use `back` to get that value before `pop()`\r\n * * (As with std::vector, separating the `pop` from the value access eliminates error testing from `pop` call)\r\n */\r\n public pop() {\r\n // Could technically access outside of array, if filled and then reduced using pop (similar to C\r\n // and accessing out of bounds), but with adjusted inUse counter, that data will eventually be overwritten\r\n if (this._inUse > 0) {\r\n this._inUse--;\r\n }\r\n }\r\n /** Access by index, without bounds check */\r\n public atUncheckedIndex(index: number): number {\r\n return this._data[index];\r\n }\r\n /** Access the 0-index member, without bounds check */\r\n public front() {\r\n return this._data[0];\r\n }\r\n /** Access the final member, without bounds check */\r\n public back() {\r\n return this._data[this._inUse - 1];\r\n }\r\n /** set a value by index */\r\n public reassign(index: number, value: number) {\r\n this._data[index] = value;\r\n }\r\n\r\n /**\r\n * * Sort the array entries.\r\n * * Uses insertion sort -- fine for small arrays (less than 30), slow for larger arrays\r\n * @param compareMethod comparison method\r\n */\r\n public sort(compareMethod: (a: any, b: any) => number = GrowableFloat64Array.compare) {\r\n for (let i = 0; i < this._inUse; i++) {\r\n for (let j = i + 1; j < this._inUse; j++) {\r\n const tempI = this._data[i];\r\n const tempJ = this._data[j];\r\n if (compareMethod(tempI, tempJ) > 0) {\r\n this._data[i] = tempJ;\r\n this._data[j] = tempI;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * * compress out values not within the [a,b] interval.\r\n * * Note that if a is greater than b all values are rejected.\r\n * @param a low value for accepted interval\r\n * @param b high value for accepted interval\r\n */\r\n public restrictToInterval(a: number, b: number) {\r\n const data = this._data;\r\n const n = data.length;\r\n let numAccept = 0;\r\n let q = 0;\r\n for (let i = 0; i < n; i++) {\r\n q = data[i];\r\n if (q >= a && q <= b)\r\n data[numAccept++] = q;\r\n }\r\n this._inUse = numAccept;\r\n }\r\n\r\n /**\r\n * * compress out multiple copies of values.\r\n * * this is done in the current order of the array.\r\n */\r\n public compressAdjacentDuplicates(tolerance: number = 0.0) {\r\n const data = this._data;\r\n const n = this._inUse;\r\n if (n === 0)\r\n return;\r\n\r\n let numAccepted = 1;\r\n let a = data[0];\r\n let b;\r\n for (let i = 1; i < n; i++) {\r\n b = data[i];\r\n if (Math.abs(b - a) > tolerance) {\r\n data[numAccepted++] = b;\r\n a = b;\r\n }\r\n }\r\n this._inUse = numAccepted;\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GrowableFloat64Array.js","sourceRoot":"","sources":["../../../src/geometry3d/GrowableFloat64Array.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAgB/F;;;;;;;;GAQG;AACH,MAAa,oBAAoB;IAK/B;;;OAGG;IACH,YAAY,kBAA0B,CAAC,EAAE,YAAqB;QAC5D,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,eAAe,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,aAAa,GAAG,CAAC,SAAS,KAAK,YAAY,IAAI,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAChG,CAAC;IAED;;;;;OAKG;IACO,QAAQ,CAAC,MAA+B,EAAE,WAAoB,EAAE,UAAmB;QAC3F,IAAI,QAAQ,GAAG,UAAU,IAAI,CAAC,CAAC;QAC/B,IAAI,QAAQ,GAAG,CAAC;YACd,QAAQ,GAAG,CAAC,CAAC;QACf,IAAI,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM;YAC/B,OAAO,EAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC,CAAC;QAC/B,IAAI,OAAO,GAAG,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC;QAC3C,IAAI,OAAO,GAAG,CAAC,EAAE;YACf,IAAI,OAAO,GAAG,MAAM,CAAC,MAAM;gBACzB,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;YAC1B,IAAI,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM;gBACxC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,M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,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE;gBAC/B,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;gBACxB,CAAC,GAAG,CAAC,CAAC;aACP;SACF;QACD,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;CAEF;AAzQD,oDAyQC","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 ArraysAndInterfaces\r\n */\r\n\r\n/**\r\n * Type for a OptionalGrowableFloat64Array or undefined.\r\n * @public\r\n */\r\nexport type OptionalGrowableFloat64Array = GrowableFloat64Array | undefined;\r\n/**\r\n * Signature for a function which does lexical comparison of `blockSize` consecutive values as 2 starting indices.\r\n * @public\r\n */\r\nexport type BlockComparisonFunction = (data: Float64Array, blockSize: number, index0: number, index1: number) => number;\r\n/**\r\n * A `GrowableFloat64Array` is Float64Array accompanied by a count of how many of the array's entries are considered in use.\r\n * * In C++ terms, this is like an std::vector\r\n * * As entries are added to the array, the buffer is reallocated as needed to accommodate.\r\n * * The reallocations leave unused space to accept further additional entries without reallocation.\r\n * * The `length` property returns the number of entries in use.\r\n * * the `capacity` property returns the (usually larger) length of the (over-allocated) Float64Array.\r\n * @public\r\n */\r\nexport class GrowableFloat64Array {\r\n private _data: Float64Array;\r\n private _inUse: number;\r\n private _growthFactor: number;\r\n\r\n /** Construct a GrowableFloat64Array.\r\n * @param initialCapacity initial capacity (default 8)\r\n * @param growthFactor used by ensureCapacity to expand requested reallocation size (default 1.5)\r\n */\r\n constructor(initialCapacity: number = 8, growthFactor?: number) {\r\n this._data = new Float64Array(initialCapacity);\r\n this._inUse = 0;\r\n this._growthFactor = (undefined !== growthFactor && growthFactor >= 1.0) ? growthFactor : 1.5;\r\n }\r\n\r\n /** Copy data from source array. Does not reallocate or change active entry count.\r\n * @param source array to copy from\r\n * @param sourceCount copy the first sourceCount entries; all entries if undefined\r\n * @param destOffset copy to instance array starting at this index; zero if undefined\r\n * @return count and offset of entries copied\r\n */\r\n protected copyData(source: Float64Array | number[], sourceCount?: number, destOffset?: number): {count: number, offset: number} {\r\n let myOffset = destOffset ?? 0;\r\n if (myOffset < 0)\r\n myOffset = 0;\r\n if (myOffset >= this._data.length)\r\n return {count: 0, offset: 0};\r\n let myCount = sourceCount ?? source.length;\r\n if (myCount > 0) {\r\n if (myCount > source.length)\r\n myCount = source.length;\r\n if (myOffset + myCount > this._data.length)\r\n myCount = this._data.length - myOffset;\r\n }\r\n if (myCount <= 0)\r\n return {count: 0, offset: 0};\r\n if (myCount === source.length)\r\n this._data.set(source, myOffset);\r\n else if (source instanceof Float64Array)\r\n this._data.set(source.subarray(0, myCount), myOffset);\r\n else\r\n this._data.set(source.slice(0, myCount), myOffset);\r\n return {count: myCount, offset: myOffset};\r\n }\r\n\r\n /**\r\n * Create a GrowableFloat64Array with given contents.\r\n * @param contents data to copy into the array\r\n */\r\n public static create(contents: Float64Array | number[]): GrowableFloat64Array {\r\n const out = new GrowableFloat64Array(contents.length);\r\n out.copyData(contents);\r\n out._inUse = contents.length;\r\n return out;\r\n }\r\n /** sort-compatible comparison.\r\n * * Returns `(a-b)` which is\r\n * * negative if `a<b`\r\n * * zero if `a === b` (with exact equality)\r\n * * positive if `a>b`\r\n */\r\n public static compare(a: any, b: any): number {\r\n return a - b;\r\n }\r\n /** Return a new array with\r\n * * All active entries copied from this instance\r\n * * optionally trimmed capacity to the active length or replicate the capacity and unused space.\r\n */\r\n public clone(maintainExcessCapacity: boolean = false): GrowableFloat64Array {\r\n const out = new GrowableFloat64Array(maintainExcessCapacity ? this.capacity() : this._inUse);\r\n out.copyData(this._data, this._inUse);\r\n out._inUse = this._inUse;\r\n return out;\r\n }\r\n /**\r\n * Returns the number of entries in use.\r\n * * Note that this is typically smaller than the length of the length of the supporting `Float64Array`\r\n */\r\n public get length() {\r\n return this._inUse;\r\n }\r\n /**\r\n * Set the value at specified index.\r\n * @param index index of entry to set\r\n * @param value value to set\r\n */\r\n public setAtUncheckedIndex(index: number, value: number) {\r\n this._data[index] = value;\r\n }\r\n\r\n /**\r\n * Move the value at index i to index j.\r\n * @param i source index\r\n * @param j destination index.\r\n */\r\n public move(i: number, j: number) {\r\n this._data[j] = this._data[i];\r\n }\r\n /**\r\n * swap the values at indices i and j\r\n * @param i first index\r\n * @param j second index\r\n */\r\n public swap(i: number, j: number) {\r\n const a = this._data[i];\r\n this._data[i] = this._data[j];\r\n this._data[j] = a;\r\n }\r\n\r\n /**\r\n * append a single value to the array.\r\n * @param toPush value to append to the active array.\r\n */\r\n public push(toPush: number) {\r\n this.ensureCapacity(this._inUse + 1);\r\n this._data[this._inUse] = toPush;\r\n this._inUse++;\r\n }\r\n /**\r\n * Push each value from an array.\r\n * @param data array of values to push\r\n */\r\n public pushArray(data: Float64Array | number[]) {\r\n this.ensureCapacity(this._inUse + data.length);\r\n this.copyData(data, data.length, this._inUse);\r\n this._inUse += data.length;\r\n }\r\n /** Push `numToCopy` consecutive values starting at `copyFromIndex`. */\r\n public pushBlockCopy(copyFromIndex: number, numToCopy: number) {\r\n if (copyFromIndex >= 0 && copyFromIndex < this._inUse && numToCopy > 0 && copyFromIndex + numToCopy <= this._inUse) {\r\n this.ensureCapacity(this._inUse + numToCopy);\r\n this._data.copyWithin(this._inUse, copyFromIndex, copyFromIndex + numToCopy);\r\n this._inUse += numToCopy;\r\n }\r\n }\r\n /** Clear the array to 0 length. The underlying memory remains allocated for reuse. */\r\n public clear() {\r\n this._inUse = 0;\r\n }\r\n /**\r\n * Returns the number of entries in the supporting Float64Array buffer.\r\n * * This number can be larger than the `length` property.\r\n */\r\n public capacity() {\r\n return this._data.length;\r\n }\r\n /**\r\n * * If the capacity (Float64Array length) is less than or equal to the requested newCapacity, do nothing.\r\n * * If the requested newCapacity is larger than the existing capacity, reallocate to larger capacity, and copy existing values.\r\n * @param newCapacity size of new array\r\n * @param applyGrowthFactor whether to apply the growth factor to newCapacity when reallocating\r\n */\r\n public ensureCapacity(newCapacity: number, applyGrowthFactor: boolean = true) {\r\n if (newCapacity > this.capacity()) {\r\n if (applyGrowthFactor)\r\n newCapacity *= this._growthFactor;\r\n const prevData = this._data;\r\n this._data = new Float64Array(newCapacity);\r\n this.copyData(prevData, this._inUse);\r\n }\r\n }\r\n /**\r\n * * If newLength is less than current length, just reset current length to newLength, effectively trimming active entries but preserving original capacity.\r\n * * If newLength is greater than current length, reallocate to (exactly) newLength, copy existing entries, and pad with padValue up to newLength.\r\n * @param newLength new data count\r\n * @param padValue value to use for padding if the length increases.\r\n */\r\n public resize(newLength: number, padValue: number = 0) {\r\n if (newLength >= 0 && newLength < this._inUse)\r\n this._inUse = newLength;\r\n else if (newLength > this._inUse) {\r\n this.ensureCapacity(newLength, false);\r\n this._data.fill(padValue, this._inUse);\r\n this._inUse = newLength;\r\n }\r\n }\r\n /**\r\n * * Reduce the length by one.\r\n * * Note that there is no method return value -- use `back` to get that value before `pop()`\r\n * * (As with std::vector, separating the `pop` from the value access eliminates error testing from `pop` call)\r\n */\r\n public pop() {\r\n // Could technically access outside of array, if filled and then reduced using pop (similar to C\r\n // and accessing out of bounds), but with adjusted inUse counter, that data will eventually be overwritten\r\n if (this._inUse > 0) {\r\n this._inUse--;\r\n }\r\n }\r\n /** Access by index, without bounds check */\r\n public atUncheckedIndex(index: number): number {\r\n return this._data[index];\r\n }\r\n /** Access the 0-index member, without bounds check */\r\n public front() {\r\n return this._data[0];\r\n }\r\n /** Access the final member, without bounds check */\r\n public back() {\r\n return this._data[this._inUse - 1];\r\n }\r\n /** set a value by index */\r\n public reassign(index: number, value: number) {\r\n this._data[index] = value;\r\n }\r\n\r\n /**\r\n * * Sort the array entries.\r\n * * Uses insertion sort -- fine for small arrays (less than 30), slow for larger arrays\r\n * @param compareMethod comparison method\r\n */\r\n public sort(compareMethod: (a: any, b: any) => number = (a, b) => GrowableFloat64Array.compare(a, b)) {\r\n for (let i = 0; i < this._inUse; i++) {\r\n for (let j = i + 1; j < this._inUse; j++) {\r\n const tempI = this._data[i];\r\n const tempJ = this._data[j];\r\n if (compareMethod(tempI, tempJ) > 0) {\r\n this._data[i] = tempJ;\r\n this._data[j] = tempI;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * * compress out values not within the [a,b] interval.\r\n * * Note that if a is greater than b all values are rejected.\r\n * @param a low value for accepted interval\r\n * @param b high value for accepted interval\r\n */\r\n public restrictToInterval(a: number, b: number) {\r\n const data = this._data;\r\n const n = data.length;\r\n let numAccept = 0;\r\n let q = 0;\r\n for (let i = 0; i < n; i++) {\r\n q = data[i];\r\n if (q >= a && q <= b)\r\n data[numAccept++] = q;\r\n }\r\n this._inUse = numAccept;\r\n }\r\n\r\n /**\r\n * * compress out multiple copies of values.\r\n * * this is done in the current order of the array.\r\n */\r\n public compressAdjacentDuplicates(tolerance: number = 0.0) {\r\n const data = this._data;\r\n const n = this._inUse;\r\n if (n === 0)\r\n return;\r\n\r\n let numAccepted = 1;\r\n let a = data[0];\r\n let b;\r\n for (let i = 1; i < n; i++) {\r\n b = data[i];\r\n if (Math.abs(b - a) > tolerance) {\r\n data[numAccepted++] = b;\r\n a = b;\r\n }\r\n }\r\n this._inUse = numAccepted;\r\n }\r\n\r\n}\r\n"]}
|