@itwin/core-geometry 5.0.0-dev.61 → 5.0.0-dev.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. package/lib/cjs/Constant.js.map +1 -1
  2. package/lib/cjs/Geometry.js.map +1 -1
  3. package/lib/cjs/bspline/AkimaCurve3d.js.map +1 -1
  4. package/lib/cjs/bspline/BSpline1dNd.d.ts +90 -54
  5. package/lib/cjs/bspline/BSpline1dNd.d.ts.map +1 -1
  6. package/lib/cjs/bspline/BSpline1dNd.js +134 -99
  7. package/lib/cjs/bspline/BSpline1dNd.js.map +1 -1
  8. package/lib/cjs/bspline/BSplineCurve.d.ts +193 -155
  9. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  10. package/lib/cjs/bspline/BSplineCurve.js +245 -181
  11. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  12. package/lib/cjs/bspline/BSplineCurve3dH.js.map +1 -1
  13. package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
  14. package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
  15. package/lib/cjs/bspline/Bezier1dNd.js.map +1 -1
  16. package/lib/cjs/bspline/BezierCurve3d.d.ts +3 -1
  17. package/lib/cjs/bspline/BezierCurve3d.d.ts.map +1 -1
  18. package/lib/cjs/bspline/BezierCurve3d.js +3 -5
  19. package/lib/cjs/bspline/BezierCurve3d.js.map +1 -1
  20. package/lib/cjs/bspline/BezierCurve3dH.js.map +1 -1
  21. package/lib/cjs/bspline/BezierCurveBase.js.map +1 -1
  22. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  23. package/lib/cjs/bspline/KnotVector.d.ts +74 -54
  24. package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
  25. package/lib/cjs/bspline/KnotVector.js +127 -80
  26. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  27. package/lib/cjs/bspline/SurfaceLocationDetail.js.map +1 -1
  28. package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
  29. package/lib/cjs/clipping/BooleanClipFactory.js.map +1 -1
  30. package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
  31. package/lib/cjs/clipping/ClipPlane.js.map +1 -1
  32. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  33. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  34. package/lib/cjs/clipping/ClipVector.js.map +1 -1
  35. package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
  36. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  37. package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  38. package/lib/cjs/core-geometry.js.map +1 -1
  39. package/lib/cjs/curve/Arc3d.d.ts +2 -0
  40. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  41. package/lib/cjs/curve/Arc3d.js +2 -0
  42. package/lib/cjs/curve/Arc3d.js.map +1 -1
  43. package/lib/cjs/curve/ConstructCurveBetweenCurves.js.map +1 -1
  44. package/lib/cjs/curve/CoordinateXYZ.js.map +1 -1
  45. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  46. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  47. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  48. package/lib/cjs/curve/CurveExtendMode.js.map +1 -1
  49. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  50. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  51. package/lib/cjs/curve/CurveOps.js.map +1 -1
  52. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  53. package/lib/cjs/curve/CurveProcessor.js.map +1 -1
  54. package/lib/cjs/curve/CurveTypes.js.map +1 -1
  55. package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
  56. package/lib/cjs/curve/GeometryQuery.js.map +1 -1
  57. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  58. package/lib/cjs/curve/LineString3d.js.map +1 -1
  59. package/lib/cjs/curve/Loop.js.map +1 -1
  60. package/lib/cjs/curve/OffsetOptions.js.map +1 -1
  61. package/lib/cjs/curve/ParityRegion.js.map +1 -1
  62. package/lib/cjs/curve/Path.js.map +1 -1
  63. package/lib/cjs/curve/PointString3d.js.map +1 -1
  64. package/lib/cjs/curve/ProxyCurve.js.map +1 -1
  65. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  66. package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
  67. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  68. package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
  69. package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
  70. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  71. package/lib/cjs/curve/Query/StrokeCountMap.js.map +1 -1
  72. package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
  73. package/lib/cjs/curve/RegionOps.js.map +1 -1
  74. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  75. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  76. package/lib/cjs/curve/UnionRegion.js.map +1 -1
  77. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -1
  78. package/lib/cjs/curve/internalContexts/ChainCollectorContext.js.map +1 -1
  79. package/lib/cjs/curve/internalContexts/CloneCurvesContext.js.map +1 -1
  80. package/lib/cjs/curve/internalContexts/CloneWithExpandedLineStrings.js.map +1 -1
  81. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  82. package/lib/cjs/curve/internalContexts/CountLinearPartsSearchContext.js.map +1 -1
  83. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  84. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  85. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  86. package/lib/cjs/curve/internalContexts/CurveLengthContext.js.map +1 -1
  87. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  88. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  89. package/lib/cjs/curve/internalContexts/GapSearchContext.js.map +1 -1
  90. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  91. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -1
  92. package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
  93. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  94. package/lib/cjs/curve/internalContexts/SumLengthsContext.js.map +1 -1
  95. package/lib/cjs/curve/internalContexts/TransformInPlaceContext.js.map +1 -1
  96. package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
  97. package/lib/cjs/curve/spiral/ClothoidSeries.js.map +1 -1
  98. package/lib/cjs/curve/spiral/CubicEvaluator.js.map +1 -1
  99. package/lib/cjs/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
  100. package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.js.map +1 -1
  101. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  102. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  103. package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
  104. package/lib/cjs/curve/spiral/NormalizedTransition.js.map +1 -1
  105. package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
  106. package/lib/cjs/curve/spiral/TransitionConditionalProperties.js.map +1 -1
  107. package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
  108. package/lib/cjs/curve/spiral/XYCurveEvaluator.js.map +1 -1
  109. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  110. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  111. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  112. package/lib/cjs/geometry3d/BilinearPatch.js.map +1 -1
  113. package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
  114. package/lib/cjs/geometry3d/Ellipsoid.js.map +1 -1
  115. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  116. package/lib/cjs/geometry3d/FrustumAnimation.js.map +1 -1
  117. package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
  118. package/lib/cjs/geometry3d/GrowableBlockedArray.js.map +1 -1
  119. package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
  120. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  121. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  122. package/lib/cjs/geometry3d/IndexedCollectionInterval.js.map +1 -1
  123. package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
  124. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  125. package/lib/cjs/geometry3d/LongitudeLatitudeAltitude.js.map +1 -1
  126. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  127. package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
  128. package/lib/cjs/geometry3d/Plane3d.js.map +1 -1
  129. package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
  130. package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
  131. package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
  132. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  133. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  134. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  135. package/lib/cjs/geometry3d/PointHelpers.d.ts +3 -3
  136. package/lib/cjs/geometry3d/PointHelpers.js +3 -3
  137. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  138. package/lib/cjs/geometry3d/PointStreaming.js.map +1 -1
  139. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  140. package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
  141. package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
  142. package/lib/cjs/geometry3d/Range.js.map +1 -1
  143. package/lib/cjs/geometry3d/Ray2d.js.map +1 -1
  144. package/lib/cjs/geometry3d/Ray3d.d.ts +2 -2
  145. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  146. package/lib/cjs/geometry3d/Ray3d.js +8 -11
  147. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  148. package/lib/cjs/geometry3d/ReusableObjectCache.js.map +1 -1
  149. package/lib/cjs/geometry3d/Segment1d.js.map +1 -1
  150. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  151. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  152. package/lib/cjs/geometry3d/UVSurfaceOps.js.map +1 -1
  153. package/lib/cjs/geometry3d/XYZProps.js.map +1 -1
  154. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  155. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  156. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  157. package/lib/cjs/geometry4d/MomentData.js.map +1 -1
  158. package/lib/cjs/geometry4d/PlaneByOriginAndVectors4d.js.map +1 -1
  159. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  160. package/lib/cjs/numerics/BandedSystem.js.map +1 -1
  161. package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
  162. package/lib/cjs/numerics/ClusterableArray.js.map +1 -1
  163. package/lib/cjs/numerics/Complex.js.map +1 -1
  164. package/lib/cjs/numerics/ConvexPolygon2d.js.map +1 -1
  165. package/lib/cjs/numerics/Newton.js.map +1 -1
  166. package/lib/cjs/numerics/PascalCoefficients.js.map +1 -1
  167. package/lib/cjs/numerics/PolarData.js.map +1 -1
  168. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  169. package/lib/cjs/numerics/Quadrature.js.map +1 -1
  170. package/lib/cjs/numerics/Range1dArray.js.map +1 -1
  171. package/lib/cjs/numerics/SmallSystem.js.map +1 -1
  172. package/lib/cjs/numerics/TriDiagonalSystem.js.map +1 -1
  173. package/lib/cjs/numerics/UnionFind.js.map +1 -1
  174. package/lib/cjs/numerics/UsageSums.js.map +1 -1
  175. package/lib/cjs/polyface/AuxData.js.map +1 -1
  176. package/lib/cjs/polyface/BoxTopology.js.map +1 -1
  177. package/lib/cjs/polyface/FacetFaceData.js.map +1 -1
  178. package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -1
  179. package/lib/cjs/polyface/FacetOrientation.js.map +1 -1
  180. package/lib/cjs/polyface/GreedyTriangulationBetweenLineStrings.js.map +1 -1
  181. package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
  182. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  183. package/lib/cjs/polyface/IndexedPolyfaceWalker.js.map +1 -1
  184. package/lib/cjs/polyface/Polyface.js.map +1 -1
  185. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  186. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  187. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  188. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  189. package/lib/cjs/polyface/RangeLengthData.js.map +1 -1
  190. package/lib/cjs/polyface/RangeTree/LineString3dRangeTreeContext.js.map +1 -1
  191. package/lib/cjs/polyface/RangeTree/MinimumValueTester.js.map +1 -1
  192. package/lib/cjs/polyface/RangeTree/Point3dArrayRangeTreeContext.js.map +1 -1
  193. package/lib/cjs/polyface/RangeTree/PolyfaceRangeTreeContext.js.map +1 -1
  194. package/lib/cjs/polyface/RangeTree/RangeTreeNode.js.map +1 -1
  195. package/lib/cjs/polyface/RangeTree/RangeTreeSearchHandlers.js.map +1 -1
  196. package/lib/cjs/polyface/TaggedNumericData.js.map +1 -1
  197. package/lib/cjs/polyface/TriangleCandidate.js.map +1 -1
  198. package/lib/cjs/polyface/multiclip/BuildAverageNormalsContext.js.map +1 -1
  199. package/lib/cjs/polyface/multiclip/GriddedRaggedRange2dSet.js.map +1 -1
  200. package/lib/cjs/polyface/multiclip/GriddedRaggedRange2dSetWithOverflow.js.map +1 -1
  201. package/lib/cjs/polyface/multiclip/LinearSearchRange2dArray.js.map +1 -1
  202. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  203. package/lib/cjs/polyface/multiclip/Range2dSearchInterface.js.map +1 -1
  204. package/lib/cjs/polyface/multiclip/RangeSearch.js.map +1 -1
  205. package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
  206. package/lib/cjs/polyface/multiclip/XYPointBuckets.js.map +1 -1
  207. package/lib/cjs/serialization/BGFBAccessors.js.map +1 -1
  208. package/lib/cjs/serialization/BGFBReader.js.map +1 -1
  209. package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
  210. package/lib/cjs/serialization/BentleyGeometryFlatBuffer.js.map +1 -1
  211. package/lib/cjs/serialization/DeepCompare.js.map +1 -1
  212. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  213. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  214. package/lib/cjs/serialization/SerializationHelpers.js.map +1 -1
  215. package/lib/cjs/solid/Box.js.map +1 -1
  216. package/lib/cjs/solid/Cone.js.map +1 -1
  217. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  218. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  219. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  220. package/lib/cjs/solid/SolidPrimitive.js.map +1 -1
  221. package/lib/cjs/solid/Sphere.js.map +1 -1
  222. package/lib/cjs/solid/SweepContour.js.map +1 -1
  223. package/lib/cjs/solid/TorusPipe.js.map +1 -1
  224. package/lib/cjs/topology/ChainMerge.js.map +1 -1
  225. package/lib/cjs/topology/Graph.js.map +1 -1
  226. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.js.map +1 -1
  227. package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
  228. package/lib/cjs/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  229. package/lib/cjs/topology/HalfEdgeGraphValidation.js.map +1 -1
  230. package/lib/cjs/topology/HalfEdgeMarkSet.js.map +1 -1
  231. package/lib/cjs/topology/HalfEdgeNodeXYZUV.js.map +1 -1
  232. package/lib/cjs/topology/HalfEdgePointInGraphSearch.js.map +1 -1
  233. package/lib/cjs/topology/HalfEdgePositionDetail.js.map +1 -1
  234. package/lib/cjs/topology/HalfEdgePriorityQueue.js.map +1 -1
  235. package/lib/cjs/topology/InsertAndRetriangulateContext.js.map +1 -1
  236. package/lib/cjs/topology/MaskManager.js.map +1 -1
  237. package/lib/cjs/topology/Merging.js.map +1 -1
  238. package/lib/cjs/topology/RegularizeFace.js.map +1 -1
  239. package/lib/cjs/topology/SignedDataSummary.js.map +1 -1
  240. package/lib/cjs/topology/SpaceTriangulation.js.map +1 -1
  241. package/lib/cjs/topology/Triangulation.js.map +1 -1
  242. package/lib/cjs/topology/XYParitySearchContext.js.map +1 -1
  243. package/lib/esm/Constant.js.map +1 -1
  244. package/lib/esm/Geometry.js.map +1 -1
  245. package/lib/esm/bspline/AkimaCurve3d.js.map +1 -1
  246. package/lib/esm/bspline/BSpline1dNd.d.ts +90 -54
  247. package/lib/esm/bspline/BSpline1dNd.d.ts.map +1 -1
  248. package/lib/esm/bspline/BSpline1dNd.js +134 -99
  249. package/lib/esm/bspline/BSpline1dNd.js.map +1 -1
  250. package/lib/esm/bspline/BSplineCurve.d.ts +193 -155
  251. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  252. package/lib/esm/bspline/BSplineCurve.js +245 -181
  253. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  254. package/lib/esm/bspline/BSplineCurve3dH.js.map +1 -1
  255. package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
  256. package/lib/esm/bspline/BSplineSurface.js.map +1 -1
  257. package/lib/esm/bspline/Bezier1dNd.js.map +1 -1
  258. package/lib/esm/bspline/BezierCurve3d.d.ts +3 -1
  259. package/lib/esm/bspline/BezierCurve3d.d.ts.map +1 -1
  260. package/lib/esm/bspline/BezierCurve3d.js +3 -5
  261. package/lib/esm/bspline/BezierCurve3d.js.map +1 -1
  262. package/lib/esm/bspline/BezierCurve3dH.js.map +1 -1
  263. package/lib/esm/bspline/BezierCurveBase.js.map +1 -1
  264. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  265. package/lib/esm/bspline/KnotVector.d.ts +74 -54
  266. package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
  267. package/lib/esm/bspline/KnotVector.js +127 -80
  268. package/lib/esm/bspline/KnotVector.js.map +1 -1
  269. package/lib/esm/bspline/SurfaceLocationDetail.js.map +1 -1
  270. package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
  271. package/lib/esm/clipping/BooleanClipFactory.js.map +1 -1
  272. package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
  273. package/lib/esm/clipping/ClipPlane.js.map +1 -1
  274. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  275. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  276. package/lib/esm/clipping/ClipVector.js.map +1 -1
  277. package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
  278. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  279. package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  280. package/lib/esm/core-geometry.js.map +1 -1
  281. package/lib/esm/curve/Arc3d.d.ts +2 -0
  282. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  283. package/lib/esm/curve/Arc3d.js +2 -0
  284. package/lib/esm/curve/Arc3d.js.map +1 -1
  285. package/lib/esm/curve/ConstructCurveBetweenCurves.js.map +1 -1
  286. package/lib/esm/curve/CoordinateXYZ.js.map +1 -1
  287. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  288. package/lib/esm/curve/CurveCollection.js.map +1 -1
  289. package/lib/esm/curve/CurveCurve.js.map +1 -1
  290. package/lib/esm/curve/CurveExtendMode.js.map +1 -1
  291. package/lib/esm/curve/CurveFactory.js.map +1 -1
  292. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  293. package/lib/esm/curve/CurveOps.js.map +1 -1
  294. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  295. package/lib/esm/curve/CurveProcessor.js.map +1 -1
  296. package/lib/esm/curve/CurveTypes.js.map +1 -1
  297. package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
  298. package/lib/esm/curve/GeometryQuery.js.map +1 -1
  299. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  300. package/lib/esm/curve/LineString3d.js.map +1 -1
  301. package/lib/esm/curve/Loop.js.map +1 -1
  302. package/lib/esm/curve/OffsetOptions.js.map +1 -1
  303. package/lib/esm/curve/ParityRegion.js.map +1 -1
  304. package/lib/esm/curve/Path.js.map +1 -1
  305. package/lib/esm/curve/PointString3d.js.map +1 -1
  306. package/lib/esm/curve/ProxyCurve.js.map +1 -1
  307. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  308. package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
  309. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  310. package/lib/esm/curve/Query/InOutTests.js.map +1 -1
  311. package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
  312. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  313. package/lib/esm/curve/Query/StrokeCountMap.js.map +1 -1
  314. package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
  315. package/lib/esm/curve/RegionOps.js.map +1 -1
  316. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  317. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  318. package/lib/esm/curve/UnionRegion.js.map +1 -1
  319. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -1
  320. package/lib/esm/curve/internalContexts/ChainCollectorContext.js.map +1 -1
  321. package/lib/esm/curve/internalContexts/CloneCurvesContext.js.map +1 -1
  322. package/lib/esm/curve/internalContexts/CloneWithExpandedLineStrings.js.map +1 -1
  323. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  324. package/lib/esm/curve/internalContexts/CountLinearPartsSearchContext.js.map +1 -1
  325. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  326. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  327. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  328. package/lib/esm/curve/internalContexts/CurveLengthContext.js.map +1 -1
  329. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  330. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  331. package/lib/esm/curve/internalContexts/GapSearchContext.js.map +1 -1
  332. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  333. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -1
  334. package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
  335. package/lib/esm/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  336. package/lib/esm/curve/internalContexts/SumLengthsContext.js.map +1 -1
  337. package/lib/esm/curve/internalContexts/TransformInPlaceContext.js.map +1 -1
  338. package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
  339. package/lib/esm/curve/spiral/ClothoidSeries.js.map +1 -1
  340. package/lib/esm/curve/spiral/CubicEvaluator.js.map +1 -1
  341. package/lib/esm/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
  342. package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.js.map +1 -1
  343. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  344. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  345. package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
  346. package/lib/esm/curve/spiral/NormalizedTransition.js.map +1 -1
  347. package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
  348. package/lib/esm/curve/spiral/TransitionConditionalProperties.js.map +1 -1
  349. package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
  350. package/lib/esm/curve/spiral/XYCurveEvaluator.js.map +1 -1
  351. package/lib/esm/geometry3d/Angle.js.map +1 -1
  352. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  353. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  354. package/lib/esm/geometry3d/BilinearPatch.js.map +1 -1
  355. package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
  356. package/lib/esm/geometry3d/Ellipsoid.js.map +1 -1
  357. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  358. package/lib/esm/geometry3d/FrustumAnimation.js.map +1 -1
  359. package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
  360. package/lib/esm/geometry3d/GrowableBlockedArray.js.map +1 -1
  361. package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
  362. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  363. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  364. package/lib/esm/geometry3d/IndexedCollectionInterval.js.map +1 -1
  365. package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
  366. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  367. package/lib/esm/geometry3d/LongitudeLatitudeAltitude.js.map +1 -1
  368. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  369. package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
  370. package/lib/esm/geometry3d/Plane3d.js.map +1 -1
  371. package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
  372. package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
  373. package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
  374. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  375. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  376. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  377. package/lib/esm/geometry3d/PointHelpers.d.ts +3 -3
  378. package/lib/esm/geometry3d/PointHelpers.js +3 -3
  379. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  380. package/lib/esm/geometry3d/PointStreaming.js.map +1 -1
  381. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  382. package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
  383. package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
  384. package/lib/esm/geometry3d/Range.js.map +1 -1
  385. package/lib/esm/geometry3d/Ray2d.js.map +1 -1
  386. package/lib/esm/geometry3d/Ray3d.d.ts +2 -2
  387. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  388. package/lib/esm/geometry3d/Ray3d.js +8 -11
  389. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  390. package/lib/esm/geometry3d/ReusableObjectCache.js.map +1 -1
  391. package/lib/esm/geometry3d/Segment1d.js.map +1 -1
  392. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  393. package/lib/esm/geometry3d/Transform.js.map +1 -1
  394. package/lib/esm/geometry3d/UVSurfaceOps.js.map +1 -1
  395. package/lib/esm/geometry3d/XYZProps.js.map +1 -1
  396. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  397. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  398. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  399. package/lib/esm/geometry4d/MomentData.js.map +1 -1
  400. package/lib/esm/geometry4d/PlaneByOriginAndVectors4d.js.map +1 -1
  401. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  402. package/lib/esm/numerics/BandedSystem.js.map +1 -1
  403. package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
  404. package/lib/esm/numerics/ClusterableArray.js.map +1 -1
  405. package/lib/esm/numerics/Complex.js.map +1 -1
  406. package/lib/esm/numerics/ConvexPolygon2d.js.map +1 -1
  407. package/lib/esm/numerics/Newton.js.map +1 -1
  408. package/lib/esm/numerics/PascalCoefficients.js.map +1 -1
  409. package/lib/esm/numerics/PolarData.js.map +1 -1
  410. package/lib/esm/numerics/Polynomials.js.map +1 -1
  411. package/lib/esm/numerics/Quadrature.js.map +1 -1
  412. package/lib/esm/numerics/Range1dArray.js.map +1 -1
  413. package/lib/esm/numerics/SmallSystem.js.map +1 -1
  414. package/lib/esm/numerics/TriDiagonalSystem.js.map +1 -1
  415. package/lib/esm/numerics/UnionFind.js.map +1 -1
  416. package/lib/esm/numerics/UsageSums.js.map +1 -1
  417. package/lib/esm/polyface/AuxData.js.map +1 -1
  418. package/lib/esm/polyface/BoxTopology.js.map +1 -1
  419. package/lib/esm/polyface/FacetFaceData.js.map +1 -1
  420. package/lib/esm/polyface/FacetLocationDetail.js.map +1 -1
  421. package/lib/esm/polyface/FacetOrientation.js.map +1 -1
  422. package/lib/esm/polyface/GreedyTriangulationBetweenLineStrings.js.map +1 -1
  423. package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
  424. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  425. package/lib/esm/polyface/IndexedPolyfaceWalker.js.map +1 -1
  426. package/lib/esm/polyface/Polyface.js.map +1 -1
  427. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  428. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  429. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  430. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  431. package/lib/esm/polyface/RangeLengthData.js.map +1 -1
  432. package/lib/esm/polyface/RangeTree/LineString3dRangeTreeContext.js.map +1 -1
  433. package/lib/esm/polyface/RangeTree/MinimumValueTester.js.map +1 -1
  434. package/lib/esm/polyface/RangeTree/Point3dArrayRangeTreeContext.js.map +1 -1
  435. package/lib/esm/polyface/RangeTree/PolyfaceRangeTreeContext.js.map +1 -1
  436. package/lib/esm/polyface/RangeTree/RangeTreeNode.js.map +1 -1
  437. package/lib/esm/polyface/RangeTree/RangeTreeSearchHandlers.js.map +1 -1
  438. package/lib/esm/polyface/TaggedNumericData.js.map +1 -1
  439. package/lib/esm/polyface/TriangleCandidate.js.map +1 -1
  440. package/lib/esm/polyface/multiclip/BuildAverageNormalsContext.js.map +1 -1
  441. package/lib/esm/polyface/multiclip/GriddedRaggedRange2dSet.js.map +1 -1
  442. package/lib/esm/polyface/multiclip/GriddedRaggedRange2dSetWithOverflow.js.map +1 -1
  443. package/lib/esm/polyface/multiclip/LinearSearchRange2dArray.js.map +1 -1
  444. package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -1
  445. package/lib/esm/polyface/multiclip/Range2dSearchInterface.js.map +1 -1
  446. package/lib/esm/polyface/multiclip/RangeSearch.js.map +1 -1
  447. package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
  448. package/lib/esm/polyface/multiclip/XYPointBuckets.js.map +1 -1
  449. package/lib/esm/serialization/BGFBAccessors.js.map +1 -1
  450. package/lib/esm/serialization/BGFBReader.js.map +1 -1
  451. package/lib/esm/serialization/BGFBWriter.js.map +1 -1
  452. package/lib/esm/serialization/BentleyGeometryFlatBuffer.js.map +1 -1
  453. package/lib/esm/serialization/DeepCompare.js.map +1 -1
  454. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  455. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  456. package/lib/esm/serialization/SerializationHelpers.js.map +1 -1
  457. package/lib/esm/solid/Box.js.map +1 -1
  458. package/lib/esm/solid/Cone.js.map +1 -1
  459. package/lib/esm/solid/LinearSweep.js.map +1 -1
  460. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  461. package/lib/esm/solid/RuledSweep.js.map +1 -1
  462. package/lib/esm/solid/SolidPrimitive.js.map +1 -1
  463. package/lib/esm/solid/Sphere.js.map +1 -1
  464. package/lib/esm/solid/SweepContour.js.map +1 -1
  465. package/lib/esm/solid/TorusPipe.js.map +1 -1
  466. package/lib/esm/topology/ChainMerge.js.map +1 -1
  467. package/lib/esm/topology/Graph.js.map +1 -1
  468. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.js.map +1 -1
  469. package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
  470. package/lib/esm/topology/HalfEdgeGraphSpineContext.js.map +1 -1
  471. package/lib/esm/topology/HalfEdgeGraphValidation.js.map +1 -1
  472. package/lib/esm/topology/HalfEdgeMarkSet.js.map +1 -1
  473. package/lib/esm/topology/HalfEdgeNodeXYZUV.js.map +1 -1
  474. package/lib/esm/topology/HalfEdgePointInGraphSearch.js.map +1 -1
  475. package/lib/esm/topology/HalfEdgePositionDetail.js.map +1 -1
  476. package/lib/esm/topology/HalfEdgePriorityQueue.js.map +1 -1
  477. package/lib/esm/topology/InsertAndRetriangulateContext.js.map +1 -1
  478. package/lib/esm/topology/MaskManager.js.map +1 -1
  479. package/lib/esm/topology/Merging.js.map +1 -1
  480. package/lib/esm/topology/RegularizeFace.js.map +1 -1
  481. package/lib/esm/topology/SignedDataSummary.js.map +1 -1
  482. package/lib/esm/topology/SpaceTriangulation.js.map +1 -1
  483. package/lib/esm/topology/Triangulation.js.map +1 -1
  484. package/lib/esm/topology/XYParitySearchContext.js.map +1 -1
  485. package/package.json +3 -3
@@ -8,6 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.KnotVector = exports.BSplineWrapMode = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
11
12
  const Geometry_1 = require("../Geometry");
12
13
  const PointHelpers_1 = require("../geometry3d/PointHelpers");
13
14
  /**
@@ -19,68 +20,89 @@ var BSplineWrapMode;
19
20
  (function (BSplineWrapMode) {
20
21
  /** No conversion performed. */
21
22
  BSplineWrapMode[BSplineWrapMode["None"] = 0] = "None";
22
- /** The B-spline was opened up by adding degree wrap-around control points to the legacy periodic data.
23
- * * This is typical of B-splines constructed with maximum (degree - 1) continuity.
23
+ /**
24
+ * The legacy periodic B-spline data was opened up by adding `degree` wrap-around poles.
25
+ * * This is typical of B-spline curves and surfaces constructed with maximum `degree - 1` continuity.
24
26
  * * Knots are unaffected by this conversion.
25
27
  */
26
28
  BSplineWrapMode[BSplineWrapMode["OpenByAddingControlPoints"] = 1] = "OpenByAddingControlPoints";
27
- /** The B-spline was opened up by removing degree extreme knots from the legacy periodic data.
29
+ /**
30
+ * The legacy periodic B-spline data was opened up by removing `degree` exterior knots.
28
31
  * * This is typical of rational B-spline curves representing full circles and ellipses.
29
32
  * * Poles are unaffected by this conversion.
30
33
  */
31
34
  BSplineWrapMode[BSplineWrapMode["OpenByRemovingKnots"] = 2] = "OpenByRemovingKnots";
32
35
  })(BSplineWrapMode || (exports.BSplineWrapMode = BSplineWrapMode = {}));
33
36
  /**
34
- * Array of non-decreasing numbers acting as a knot array for B-splines.
37
+ * Array of non-decreasing numbers acting as a knot vector for B-spline curves and surfaces.
35
38
  *
36
39
  * * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1
37
- * * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation and Parasolid)
38
- * demand order knots at each end for clamping. But only order-1 are really needed. This class uses the order-1 convention.
40
+ * * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation
41
+ * and Parasolid) demand order knots at each end for clamping. However, only order-1 are really needed. This class uses the
42
+ * order-1 convention.
39
43
  * * A span is a single interval of the knots.
40
- * * The left knot of span {k} is knot {k+degree-1}.
44
+ * * The left knot of the span with index `k>=0` is the knot with index `k+degree-1`.
45
+ * * A knot vector is clamped when the first `degree` knots are equal and the last `degree` knots are equal.
46
+ * * The "active knot interval" is the subset of the knot vector sans its first and last `degree-1` knots, and serves as
47
+ * the parametric domain of the associated B-spline object.
41
48
  * * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.
42
- * * Core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Callers need to
43
- * know their primary values (global knot, spanFraction).
49
+ * * Callers need to distinguish core computational inputs such as left knot index, knot value, span index, and span fraction.
44
50
  * @public
45
51
  */
46
52
  class KnotVector {
47
53
  /** The simple array of knot values. */
48
54
  knots;
49
- /** Return the degree of basis functions defined in these knots. */
55
+ /** The degree of basis functions defined in these knots. */
50
56
  degree;
57
+ /** The leftmost knot value (of the active interval, ignoring unclamped leading knots). */
51
58
  _knot0;
59
+ /** The rightmost knot value (of the active interval, ignoring unclamped leading knots). */
52
60
  _knot1;
53
61
  _wrapMode;
54
- /** tolerance for considering two knots to be the same. */
62
+ /** Tolerance for considering two knots to be the same. */
55
63
  static knotTolerance = 1.0e-9;
56
- /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/
57
- get leftKnot() { return this._knot0; }
58
- /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots)*/
59
- get rightKnot() { return this._knot1; }
60
- /** Return the index of the leftmost knot of the active interval */
61
- get leftKnotIndex() { return this.degree - 1; }
62
- /** Return the index of the rightmost knot of the active interval */
63
- get rightKnotIndex() { return this.knots.length - this.degree; }
64
- /** Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used is specified by BSplineWrapMode, and is reversed at serialization time. */
65
- get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }
66
- set wrappable(value) { this._wrapMode = value; }
67
- /** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */
68
- get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }
64
+ /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots). */
65
+ get leftKnot() {
66
+ return this._knot0;
67
+ }
68
+ /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots). */
69
+ get rightKnot() {
70
+ return this._knot1;
71
+ }
72
+ /** Return the index of the leftmost knot of the active interval. */
73
+ get leftKnotIndex() {
74
+ return this.degree - 1;
75
+ }
76
+ /** Return the index of the rightmost knot of the active interval. */
77
+ get rightKnotIndex() {
78
+ return this.knots.length - this.degree;
79
+ }
80
+ /**
81
+ * Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used
82
+ * is specified by BSplineWrapMode, and is reversed at serialization time.
83
+ */
84
+ get wrappable() {
85
+ return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode;
86
+ }
87
+ set wrappable(value) {
88
+ this._wrapMode = value;
89
+ }
90
+ /** Return the number of Bezier spans. Note that this includes zero-length spans if there are repeated knots. */
91
+ get numSpans() {
92
+ return this.rightKnotIndex - this.leftKnotIndex;
93
+ }
69
94
  /**
70
- *
71
- * * If knots is a number array or Float64Array, the those values become the local knot array.
72
- * * If knots is a simple number, the local knot array is allocated to that size but left as zeros.
73
- * @param knots
74
- * @param degree
95
+ * Private constructor.
96
+ * * If `knots` is a number array or Float64Array, then its values are copied to the instance array.
97
+ * * If `knots` is a number, the instance array is allocated to this size but left as zeros.
75
98
  */
76
99
  constructor(knots, degree, wrapMode) {
77
100
  this.degree = degree;
78
101
  this._wrapMode = wrapMode;
79
- // default values to satisfy compiler -- real values happen in setupFixedValues, or final else defers to user
102
+ // default values to satisfy compiler; real values happen in setupFixedValues or the final else clause defers to user
80
103
  this._knot0 = 0.0;
81
104
  this._knot1 = 1.0;
82
- // satisfy the initialize checker ..
83
- if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.
105
+ if (Array.isArray(knots)) {
84
106
  this.knots = new Float64Array(knots.length);
85
107
  this.setKnots(knots);
86
108
  this.setupFixedValues();
@@ -89,23 +111,32 @@ class KnotVector {
89
111
  this.knots = knots.slice();
90
112
  this.setupFixedValues();
91
113
  }
92
- else { // caller is responsible for filling array separately ...
93
- this.knots = new Float64Array(knots);
114
+ else { // caller is responsible for filling array separately
115
+ const knotSize = knots;
116
+ this.knots = new Float64Array(knotSize);
94
117
  }
95
118
  }
96
- /** copy degree and knots to a new KnotVector. */
97
- clone() { return new KnotVector(this.knots, this.degree, this.wrappable); }
119
+ /** Copy degree and knots to a new KnotVector. */
120
+ clone() {
121
+ return new KnotVector(this.knots, this.degree, this.wrappable);
122
+ }
98
123
  setupFixedValues() {
99
124
  if (this.degree > 0 && this.knots.length > this.degree) {
100
125
  this._knot0 = this.knots[this.degree - 1];
101
126
  this._knot1 = this.knots[this.knots.length - this.degree];
102
127
  }
103
128
  }
104
- /** Return the total knot distance from beginning to end. */
105
- get knotLength01() { return this._knot1 - this._knot0; }
106
129
  /**
107
- * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified wrap mode.
108
- * @param mode optional test mode. If undefined, use this.wrappable.
130
+ * Return the length of the active knot interval.
131
+ * * This is the size of (one dimension of) the parametric domain for the associated B-spline object.
132
+ */
133
+ get knotLength01() {
134
+ return this._knot1 - this._knot0;
135
+ }
136
+ /**
137
+ * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified
138
+ * wrap mode.
139
+ * @param mode optional test mode. If undefined, use this.wrappable.
109
140
  */
110
141
  testClosable(mode) {
111
142
  if (mode === undefined)
@@ -139,7 +170,7 @@ class KnotVector {
139
170
  }
140
171
  return false;
141
172
  }
142
- /** Test matching degree and knot values */
173
+ /** Test matching degree and knot values. */
143
174
  isAlmostEqual(other) {
144
175
  if (this.degree !== other.degree)
145
176
  return false;
@@ -179,8 +210,9 @@ class KnotVector {
179
210
  }
180
211
  return m;
181
212
  }
182
- /** Transform knots to span [0,1].
183
- * @returns false if and only if this.knotLength01 is trivial
213
+ /**
214
+ * Transform knots such that the active knot range becomes [0,1].
215
+ * @returns false if and only if `this.knotLength01` is trivial.
184
216
  */
185
217
  normalize() {
186
218
  if (this.knotLength01 < KnotVector.knotTolerance)
@@ -198,8 +230,7 @@ class KnotVector {
198
230
  this.setupFixedValues();
199
231
  return true;
200
232
  }
201
- /** install knot values from an array, optionally ignoring first and last.
202
- */
233
+ /** Install knot values from an array, optionally ignoring first and last. */
203
234
  setKnots(knots, skipFirstAndLast) {
204
235
  const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;
205
236
  if (numAllocate !== this.knots.length)
@@ -214,17 +245,17 @@ class KnotVector {
214
245
  }
215
246
  this.setupFixedValues();
216
247
  }
217
- /** Set knots to input array (CAPTURED) */
248
+ /** Set knots to input array (CAPTURED). */
218
249
  setKnotsCapture(knots) {
219
250
  this.knots = knots;
220
251
  this.setupFixedValues();
221
252
  }
222
253
  /**
223
254
  * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.
224
- * @param numPoles Number of poles
225
- * @param degree degree of polynomial
226
- * @param a0 left knot value for active interval
227
- * @param a1 right knot value for active interval
255
+ * @param numPoles number of poles.
256
+ * @param degree degree of polynomial.
257
+ * @param a0 left knot value for active interval.
258
+ * @param a1 right knot value for active interval.
228
259
  */
229
260
  static createUniformClamped(numPoles, degree, a0, a1) {
230
261
  const knots = new KnotVector(numPoles + degree - 1, degree);
@@ -241,24 +272,26 @@ class KnotVector {
241
272
  }
242
273
  /**
243
274
  * Create knot vector with wraparound knots at start and end, and uniform knots between.
244
- * @param numInterval number of intervals in knot space. (NOT POLE COUNT)
245
- * @param degree degree of polynomial
246
- * @param a0 left knot value for active interval
247
- * @param a1 right knot value for active interval
275
+ * @param numInterval the number of intervals into which to uniformly divide the active knot interval `[a0,a1]`,
276
+ * creating `numInterval-1` equally spaced interior knots between `a0` and `a1`.
277
+ * This number is equal to the number of Bezier spans in the associated B-spline object.
278
+ * It is _not_ the pole count.
279
+ * @param degree degree of polynomial.
280
+ * @param a0 left knot value for active interval.
281
+ * @param a1 right knot value for active interval.
248
282
  */
249
283
  static createUniformWrapped(numInterval, degree, a0, a1) {
250
284
  const knots = new KnotVector(numInterval + 2 * degree - 1, degree);
251
285
  const du = 1.0 / numInterval;
252
- for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++) {
286
+ for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++)
253
287
  knots.knots[k] = Geometry_1.Geometry.interpolate(a0, i * du, a1);
254
- }
255
288
  knots.setupFixedValues();
256
289
  return knots;
257
290
  }
258
291
  /**
259
292
  * Create knot vector with given knot values and degree.
260
- * @param knotArray knot values
261
- * @param degree degree of polynomial
293
+ * @param knotArray knot values.
294
+ * @param degree degree of polynomial.
262
295
  * @param skipFirstAndLast true to skip copying the first and last knot values.
263
296
  */
264
297
  static create(knotArray, degree, skipFirstAndLast) {
@@ -269,19 +302,24 @@ class KnotVector {
269
302
  }
270
303
  /**
271
304
  * Return the average of degree consecutive knots beginning at knotIndex.
305
+ * * If `knotIndex` is negative, return `leftKnot`.
306
+ * * If `knotIndex > rightKnotIndex` return `rightKnot`.
272
307
  */
273
308
  grevilleKnot(knotIndex) {
274
309
  if (knotIndex < 0)
275
310
  return this.leftKnot;
276
311
  if (knotIndex > this.rightKnotIndex)
277
312
  return this.rightKnot;
313
+ knotIndex = Math.floor(knotIndex);
278
314
  let sum = 0.0;
279
315
  for (let i = knotIndex; i < knotIndex + this.degree; i++)
280
316
  sum += this.knots[i];
281
317
  return sum / this.degree;
282
318
  }
283
- /** Return an array sized for a set of the basis function values. */
284
- createBasisArray() { return new Float64Array(this.degree + 1); }
319
+ /** Return an array of size `degree + 1`, e.g., to hold the set of relevant basis function values at a parameter. */
320
+ createBasisArray() {
321
+ return new Float64Array(this.degree + 1);
322
+ }
285
323
  /** Convert localFraction within the interval following an indexed knot to a knot value. */
286
324
  baseKnotFractionToKnot(knotIndex0, localFraction) {
287
325
  const knot0 = this.knots[knotIndex0];
@@ -304,32 +342,38 @@ class KnotVector {
304
342
  fraction = Geometry_1.Geometry.clamp(fraction, 0, 1); // B-splines are not extendable
305
343
  return Geometry_1.Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);
306
344
  }
345
+ isKnotInValidSpan(knotIndex0, u) {
346
+ const spanIsValid = knotIndex0 >= this.degree - 1 && knotIndex0 + this.degree < this.knots.length;
347
+ const uIsInSpan = this.knots[knotIndex0] <= u && u <= this.knots[knotIndex0 + 1];
348
+ return spanIsValid && uIsInSpan;
349
+ }
307
350
  /**
308
351
  * Evaluate the B-spline basis functions f[] at a parameter u in a knot span.
309
352
  * * This method implements the Mansfield-Cox-de Boor recurrence relation.
310
353
  * @param knotIndex0 index of the left knot of the span.
311
354
  * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].
312
- * @param f preallocated output array of order basis function values
313
- * @returns true if and only if output array is sufficiently sized
355
+ * @param f preallocated output array of order basis function values.
356
+ * @returns true if and only if output array is sufficiently sized.
314
357
  */
315
358
  evaluateBasisFunctions(knotIndex0, u, f) {
316
359
  if (f.length < this.degree + 1)
317
360
  return false;
361
+ (0, core_bentley_1.assert)(() => this.isKnotInValidSpan(knotIndex0, u), "knot is in a valid span");
318
362
  f[0] = 1.0;
319
363
  if (this.degree < 1)
320
364
  return true;
321
- // direct compute for linear part ...
365
+ // direct compute for linear part
322
366
  const u0 = this.knots[knotIndex0];
323
367
  const u1 = this.knots[knotIndex0 + 1];
324
368
  f[1] = (u - u0) / (u1 - u0);
325
369
  f[0] = 1.0 - f[1];
326
370
  if (this.degree < 2)
327
371
  return true;
328
- // Each iteration of the outer loop evaluates the basis functions of degree depth+1 using
329
- // one or two values of the basis functions of one less degree from the preceding iteration.
372
+ // each iteration of the outer loop evaluates the basis functions of degree depth+1 using
373
+ // one or two values of the basis functions of one less degree from the preceding iteration
330
374
  for (let depth = 1; depth < this.degree; depth++) {
331
375
  let kLeft = knotIndex0 - depth;
332
- let kRight = kLeft + depth + 1;
376
+ let kRight = knotIndex0 + 1;
333
377
  let gCarry = 0.0;
334
378
  for (let step = 0; step <= depth; step++) {
335
379
  const tLeft = this.knots[kLeft++];
@@ -351,10 +395,10 @@ class KnotVector {
351
395
  * in a knot span.
352
396
  * @param knotIndex0 index of the left knot of the span.
353
397
  * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].
354
- * @param f preallocated output array of order basis function values
355
- * @param df preallocated output array of order basis derivative values
356
- * @param ddf optional preallocated output array of order basis second derivative values
357
- * @returns true if and only if output arrays are sufficiently sized
398
+ * @param f preallocated output array of order basis function values.
399
+ * @param df preallocated output array of order basis derivative values.
400
+ * @param ddf optional preallocated output array of order basis second derivative values.
401
+ * @returns true if and only if output arrays are sufficiently sized.
358
402
  */
359
403
  evaluateBasisFunctions1(knotIndex0, u, f, df, ddf) {
360
404
  if (f.length < this.degree + 1)
@@ -363,15 +407,16 @@ class KnotVector {
363
407
  return false;
364
408
  if (ddf && ddf.length < this.degree + 1)
365
409
  return false;
410
+ (0, core_bentley_1.assert)(() => this.isKnotInValidSpan(knotIndex0, u), "knot is in a valid span");
366
411
  f[0] = 1.0;
367
412
  df[0] = 0.0;
368
413
  if (this.degree < 1)
369
414
  return true;
370
- // direct compute for linear part ...
415
+ // direct compute for linear part
371
416
  const u0 = this.knots[knotIndex0];
372
417
  const u1 = this.knots[knotIndex0 + 1];
373
- // ah = 1/(u1-u0) is the derivative of fraction0
374
- // (-ah) is the derivative of fraction1.
418
+ // ah = 1/(u1-u0) is the derivative of fraction0
419
+ // -ah is the derivative of fraction1
375
420
  let ah = 1.0 / (u1 - u0);
376
421
  f[1] = (u - u0) * ah;
377
422
  f[0] = 1.0 - f[1];
@@ -390,7 +435,7 @@ class KnotVector {
390
435
  let dgCarry = 0.0;
391
436
  let ddgCarry = 0.0;
392
437
  // f, df, ddf, are each row vectors with product of `step` linear terms.
393
- // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)
438
+ // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)
394
439
  // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)
395
440
  // Hence fnew = f * V
396
441
  // dfnew = df * V + f * dV
@@ -412,7 +457,7 @@ class KnotVector {
412
457
  df[step] = dgCarry + dg0;
413
458
  gCarry = g1;
414
459
  dgCarry = dg1;
415
- if (ddf) { // do the backward reference to df before rewriting df !!!
460
+ if (ddf) { // do the backward reference to df before rewriting df
416
461
  const ddg1 = ddf[step] * fraction + dfSave;
417
462
  const ddg0 = ddf[step] * fraction1 - dfSave;
418
463
  ddf[step] = ddgCarry + ddg0;
@@ -426,9 +471,10 @@ class KnotVector {
426
471
  }
427
472
  return true;
428
473
  }
429
- /** Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.
474
+ /**
475
+ * Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.
430
476
  * * If u has no such bracket, return the smaller index of the closest nontrivial bracket.
431
- * @param u value to bracket
477
+ * @param u value to bracket.
432
478
  */
433
479
  knotToLeftKnotIndex(u) {
434
480
  for (let i = this.leftKnotIndex; i < this.rightKnotIndex; ++i) {
@@ -444,7 +490,7 @@ class KnotVector {
444
490
  }
445
491
  /**
446
492
  * Given a span index, return the index of the knot at its left.
447
- * @param spanIndex index of span
493
+ * @param spanIndex index of span.
448
494
  */
449
495
  spanIndexToLeftKnotIndex(spanIndex) {
450
496
  const d = this.degree;
@@ -459,7 +505,8 @@ class KnotVector {
459
505
  }
460
506
  /**
461
507
  * Given a span index, test if it is within range and has nonzero length.
462
- * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) followed by more real spans
508
+ * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span)
509
+ * followed by more real spans
463
510
  * @param spanIndex index of span to test.
464
511
  */
465
512
  isIndexOfRealSpan(spanIndex) {
@@ -467,7 +514,7 @@ class KnotVector {
467
514
  return !Geometry_1.Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));
468
515
  return false;
469
516
  }
470
- /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths reverse. */
517
+ /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths are reversed. */
471
518
  reflectKnots() {
472
519
  const a = this.leftKnot;
473
520
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CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,uHAAuH;IAChH,SAAS,CAAC,mBAA4B;QAC3C,MAAM,QAAQ,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3F,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACtF,CAAC;;AA9cH,gCA+cC","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 Bspline\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n\r\n/**\r\n * B-spline curve and surface types in this library are non-periodic. But they can be created from legacy periodic data.\r\n * This enumeration lists the possible ways a B-spline object can have been created from legacy periodic data.\r\n * @public\r\n */\r\nexport enum BSplineWrapMode {\r\n /** No conversion performed. */\r\n None = 0,\r\n /** The B-spline was opened up by adding degree wrap-around control points to the legacy periodic data.\r\n * * This is typical of B-splines constructed with maximum (degree - 1) continuity.\r\n * * Knots are unaffected by this conversion.\r\n */\r\n OpenByAddingControlPoints = 1,\r\n /** The B-spline was opened up by removing degree extreme knots from the legacy periodic data.\r\n * * This is typical of rational B-spline curves representing full circles and ellipses.\r\n * * Poles are unaffected by this conversion.\r\n */\r\n OpenByRemovingKnots = 2,\r\n}\r\n/**\r\n * Array of non-decreasing numbers acting as a knot array for B-splines.\r\n *\r\n * * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1\r\n * * Various B-spline libraries have confusion over how many \"end knots\" are needed. Many libraries (including MicroStation and Parasolid)\r\n * demand order knots at each end for clamping. But only order-1 are really needed. This class uses the order-1 convention.\r\n * * A span is a single interval of the knots.\r\n * * The left knot of span {k} is knot {k+degree-1}.\r\n * * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.\r\n * * Core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Callers need to\r\n * know their primary values (global knot, spanFraction).\r\n * @public\r\n */\r\nexport class KnotVector {\r\n /** The simple array of knot values. */\r\n public knots: Float64Array;\r\n /** Return the degree of basis functions defined in these knots. */\r\n public degree: number;\r\n private _knot0: number;\r\n private _knot1: number;\r\n\r\n private _wrapMode?: BSplineWrapMode;\r\n /** tolerance for considering two knots to be the same. */\r\n public static readonly knotTolerance = 1.0e-9;\r\n /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get leftKnot() { return this._knot0; }\r\n /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get rightKnot() { return this._knot1; }\r\n /** Return the index of the leftmost knot of the active interval */\r\n public get leftKnotIndex() { return this.degree - 1; }\r\n /** Return the index of the rightmost knot of the active interval */\r\n public get rightKnotIndex() { return this.knots.length - this.degree; }\r\n /** Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used is specified by BSplineWrapMode, and is reversed at serialization time. */\r\n public get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }\r\n public set wrappable(value: BSplineWrapMode) { this._wrapMode = value; }\r\n /** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */\r\n public get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }\r\n /**\r\n *\r\n * * If knots is a number array or Float64Array, the those values become the local knot array.\r\n * * If knots is a simple number, the local knot array is allocated to that size but left as zeros.\r\n * @param knots\r\n * @param degree\r\n */\r\n private constructor(knots: number[] | Float64Array | number, degree: number, wrapMode?: BSplineWrapMode) {\r\n this.degree = degree;\r\n this._wrapMode = wrapMode;\r\n // default values to satisfy compiler -- real values happen in setupFixedValues, or final else defers to user\r\n this._knot0 = 0.0;\r\n this._knot1 = 1.0;\r\n // satisfy the initialize checker ..\r\n if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.\r\n this.knots = new Float64Array(knots.length);\r\n this.setKnots(knots);\r\n this.setupFixedValues();\r\n } else if (knots instanceof Float64Array) {\r\n this.knots = knots.slice();\r\n this.setupFixedValues();\r\n } else { // caller is responsible for filling array separately ...\r\n this.knots = new Float64Array(knots);\r\n }\r\n }\r\n /** copy degree and knots to a new KnotVector. */\r\n public clone(): KnotVector { return new KnotVector(this.knots, this.degree, this.wrappable); }\r\n private setupFixedValues() {\r\n if (this.degree > 0 && this.knots.length > this.degree) {\r\n this._knot0 = this.knots[this.degree - 1];\r\n this._knot1 = this.knots[this.knots.length - this.degree];\r\n }\r\n }\r\n /** Return the total knot distance from beginning to end. */\r\n public get knotLength01(): number { return this._knot1 - this._knot0; }\r\n /**\r\n * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified wrap mode.\r\n * @param mode optional test mode. If undefined, use this.wrappable.\r\n */\r\n public testClosable(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.wrappable;\r\n const degree = this.degree;\r\n const leftKnotIndex = this.leftKnotIndex;\r\n const rightKnotIndex = this.rightKnotIndex;\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n // maximum continuity mode: we expect degree periodically extended knots at each end\r\n const period = this.rightKnot - this.leftKnot;\r\n const indexDelta = rightKnotIndex - leftKnotIndex;\r\n for (let k0 = 0; k0 < leftKnotIndex + degree; k0++) {\r\n const k1 = k0 + indexDelta;\r\n if (Math.abs(this.knots[k0] + period - this.knots[k1]) >= KnotVector.knotTolerance)\r\n return false;\r\n }\r\n return true;\r\n }\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // legacy periodic mode: we expect multiplicity degree knots at each end\r\n const numRepeated = degree - 1;\r\n const leftKnot = this.leftKnot;\r\n const rightKnot = this.rightKnot;\r\n for (let i = 0; i < numRepeated; i++) {\r\n if (Math.abs(leftKnot - this.knots[leftKnotIndex - i - 1]) >= KnotVector.knotTolerance)\r\n return false;\r\n if (Math.abs(rightKnot - this.knots[rightKnotIndex + i + 1]) >= KnotVector.knotTolerance)\r\n return false;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** Test matching degree and knot values */\r\n public isAlmostEqual(other: KnotVector): boolean {\r\n if (this.degree !== other.degree) return false;\r\n return NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);\r\n }\r\n\r\n /** Compute the multiplicity of the input knot, or zero if not a knot. */\r\n public getKnotMultiplicity(knot: number): number {\r\n let m = 0;\r\n for (const k of this.knots) {\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m;\r\n else if (knot < k)\r\n break;\r\n }\r\n return m;\r\n }\r\n\r\n /** Compute the multiplicity of the knot at the given index. */\r\n public getKnotMultiplicityAtIndex(knotIndex: number): number {\r\n let m = 0;\r\n if (knotIndex >= 0 && knotIndex < this.knots.length) {\r\n const knot = this.knots[knotIndex];\r\n ++m; // count this knot\r\n for (let i = knotIndex - 1; i >= 0; --i) {\r\n const k = this.knots[i];\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m; // found multiple to left of knot\r\n else if (knot > k)\r\n break;\r\n }\r\n for (let i = knotIndex + 1; i < this.knots.length; ++i) {\r\n const k = this.knots[i];\r\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\r\n ++m; // found multiple to right of knot\r\n else if (knot < k)\r\n break;\r\n }\r\n }\r\n return m;\r\n }\r\n\r\n /** Transform knots to span [0,1].\r\n * @returns false if and only if this.knotLength01 is trivial\r\n */\r\n public normalize(): boolean {\r\n if (this.knotLength01 < KnotVector.knotTolerance)\r\n return false;\r\n const divisor = 1.0 / this.knotLength01;\r\n const leftKnot = this.leftKnot;\r\n for (let i = 0; i < this.knots.length; ++i)\r\n this.knots[i] = (this.knots[i] - leftKnot) * divisor;\r\n // explicitly set rightKnot and its multiples to 1.0 to avoid round-off\r\n for (let i = this.rightKnotIndex - 1; i > this.leftKnotIndex && (this.knots[i] === this.knots[this.rightKnotIndex]); --i) this.knots[i] = 1.0;\r\n for (let i = this.rightKnotIndex + 1; i < this.knots.length && (this.knots[i] === this.knots[this.rightKnotIndex]); ++i) this.knots[i] = 1.0;\r\n this.knots[this.rightKnotIndex] = 1.0;\r\n this.setupFixedValues();\r\n return true;\r\n }\r\n\r\n /** install knot values from an array, optionally ignoring first and last.\r\n */\r\n public setKnots(knots: number[] | Float64Array, skipFirstAndLast?: boolean) {\r\n const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;\r\n if (numAllocate !== this.knots.length)\r\n this.knots = new Float64Array(numAllocate);\r\n if (skipFirstAndLast) {\r\n for (let i = 1; i + 1 < knots.length; i++)\r\n this.knots[i - 1] = knots[i];\r\n\r\n } else {\r\n for (let i = 0; i < knots.length; i++)\r\n this.knots[i] = knots[i];\r\n }\r\n this.setupFixedValues();\r\n }\r\n\r\n /** Set knots to input array (CAPTURED) */\r\n public setKnotsCapture(knots: Float64Array) {\r\n this.knots = knots;\r\n this.setupFixedValues();\r\n }\r\n\r\n /**\r\n * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.\r\n * @param numPoles Number of poles\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numPoles + degree - 1, degree);\r\n let k = 0;\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a0;\r\n const du = 1.0 / (numPoles - degree);\r\n for (let i = 1; i + degree < numPoles; i++)\r\n knots.knots[k++] = a0 + i * du * (a1 - a0);\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a1;\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n /**\r\n * Create knot vector with wraparound knots at start and end, and uniform knots between.\r\n * @param numInterval number of intervals in knot space. (NOT POLE COUNT)\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numInterval + 2 * degree - 1, degree);\r\n const du = 1.0 / numInterval;\r\n for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++) {\r\n knots.knots[k] = Geometry.interpolate(a0, i * du, a1);\r\n }\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n\r\n /**\r\n * Create knot vector with given knot values and degree.\r\n * @param knotArray knot values\r\n * @param degree degree of polynomial\r\n * @param skipFirstAndLast true to skip copying the first and last knot values.\r\n */\r\n public static create(knotArray: number[] | Float64Array, degree: number, skipFirstAndLast?: boolean): KnotVector {\r\n const numAllocate = skipFirstAndLast ? knotArray.length - 2 : knotArray.length;\r\n const knots = new KnotVector(numAllocate, degree);\r\n knots.setKnots(knotArray, skipFirstAndLast);\r\n return knots;\r\n }\r\n\r\n /**\r\n * Return the average of degree consecutive knots beginning at knotIndex.\r\n */\r\n public grevilleKnot(knotIndex: number): number {\r\n if (knotIndex < 0) return this.leftKnot;\r\n if (knotIndex > this.rightKnotIndex) return this.rightKnot;\r\n let sum = 0.0;\r\n for (let i = knotIndex; i < knotIndex + this.degree; i++)\r\n sum += this.knots[i];\r\n return sum / this.degree;\r\n }\r\n /** Return an array sized for a set of the basis function values. */\r\n public createBasisArray(): Float64Array { return new Float64Array(this.degree + 1); }\r\n /** Convert localFraction within the interval following an indexed knot to a knot value. */\r\n public baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number {\r\n const knot0 = this.knots[knotIndex0];\r\n localFraction = Geometry.clamp(localFraction, 0, 1);\r\n return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);\r\n }\r\n /** Convert localFraction within an indexed bezier span to a knot value. */\r\n public spanFractionToKnot(spanIndex: number, localFraction: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n localFraction = Geometry.clamp(localFraction, 0, 1);\r\n return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);\r\n }\r\n /** Convert localFraction within an indexed bezier span to fraction of active knot range. */\r\n public spanFractionToFraction(spanIndex: number, localFraction: number): number {\r\n const knot = this.spanFractionToKnot(spanIndex, localFraction);\r\n return (knot - this.leftKnot) / (this.rightKnot - this.leftKnot);\r\n }\r\n /** Return fraction of active knot range to knot value. */\r\n public fractionToKnot(fraction: number): number {\r\n fraction = Geometry.clamp(fraction, 0, 1); // B-splines are not extendable\r\n return Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);\r\n }\r\n /**\r\n * Evaluate the B-spline basis functions f[] at a parameter u in a knot span.\r\n * * This method implements the Mansfield-Cox-de Boor recurrence relation.\r\n * @param knotIndex0 index of the left knot of the span.\r\n * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].\r\n * @param f preallocated output array of order basis function values\r\n * @returns true if and only if output array is sufficiently sized\r\n */\r\n public evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array): boolean {\r\n if (f.length < this.degree + 1)\r\n return false;\r\n f[0] = 1.0;\r\n if (this.degree < 1)\r\n return true;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n f[1] = (u - u0) / (u1 - u0);\r\n f[0] = 1.0 - f[1];\r\n if (this.degree < 2)\r\n return true;\r\n // Each iteration of the outer loop evaluates the basis functions of degree depth+1 using\r\n // one or two values of the basis functions of one less degree from the preceding iteration.\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n const fraction = (u - tLeft) / (tRight - tLeft);\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * (1.0 - fraction);\r\n f[step] = gCarry + g0;\r\n gCarry = g1;\r\n }\r\n f[depth + 1] = gCarry;\r\n // at this point, the head of f[] contains the depth+2 values at u\r\n // of the basis functions of degree depth+1 with support over [u0,u1)\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at a parameter u\r\n * in a knot span.\r\n * @param knotIndex0 index of the left knot of the span.\r\n * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].\r\n * @param f preallocated output array of order basis function values\r\n * @param df preallocated output array of order basis derivative values\r\n * @param ddf optional preallocated output array of order basis second derivative values\r\n * @returns true if and only if output arrays are sufficiently sized\r\n */\r\n public evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array): boolean {\r\n if (f.length < this.degree + 1)\r\n return false;\r\n if (df.length < this.degree + 1)\r\n return false;\r\n if (ddf && ddf.length < this.degree + 1)\r\n return false;\r\n f[0] = 1.0; df[0] = 0.0;\r\n if (this.degree < 1)\r\n return true;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n // ah = 1/(u1-u0) is the derivative of fraction0\r\n // (-ah) is the derivative of fraction1.\r\n let ah = 1.0 / (u1 - u0);\r\n f[1] = (u - u0) * ah;\r\n f[0] = 1.0 - f[1];\r\n df[0] = -ah; df[1] = ah;\r\n if (ddf) { // first derivative started constant, second derivative started zero.\r\n ddf[0] = 0.0; ddf[1] = 0.0;\r\n }\r\n if (this.degree < 2)\r\n return true;\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n let dgCarry = 0.0;\r\n let ddgCarry = 0.0;\r\n // f, df, ddf, are each row vectors with product of `step` linear terms.\r\n // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)\r\n // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)\r\n // Hence fnew = f * V\r\n // dfnew = df * V + f * dV\r\n // ddfnew = ddf * V + df*dV + df * dV + f * ddV\r\n // but ddV is zero so\r\n // ddfnew = ddf * V + 2 * df * dV\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n ah = 1.0 / (tRight - tLeft);\r\n const fraction = (u - tLeft) * ah;\r\n const fraction1 = 1.0 - fraction;\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * fraction1;\r\n const dg1 = df[step] * fraction + f[step] * ah;\r\n const dg0 = df[step] * fraction1 - f[step] * ah;\r\n const dfSave = 2.0 * df[step] * ah;\r\n f[step] = gCarry + g0;\r\n df[step] = dgCarry + dg0;\r\n gCarry = g1;\r\n dgCarry = dg1;\r\n if (ddf) { // do the backward reference to df before rewriting df !!!\r\n const ddg1 = ddf[step] * fraction + dfSave;\r\n const ddg0 = ddf[step] * fraction1 - dfSave;\r\n ddf[step] = ddgCarry + ddg0;\r\n ddgCarry = ddg1;\r\n }\r\n }\r\n f[depth + 1] = gCarry;\r\n df[depth + 1] = dgCarry;\r\n if (ddf)\r\n ddf[depth + 1] = ddgCarry;\r\n }\r\n return true;\r\n }\r\n /** Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.\r\n * * If u has no such bracket, return the smaller index of the closest nontrivial bracket.\r\n * @param u value to bracket\r\n */\r\n public knotToLeftKnotIndex(u: number): number {\r\n for (let i = this.leftKnotIndex; i < this.rightKnotIndex; ++i) {\r\n if (u < this.knots[i + 1])\r\n return i;\r\n }\r\n // for u >= rightKnot, return left index of last nontrivial span\r\n for (let i = this.rightKnotIndex; i > this.leftKnotIndex; --i) {\r\n if (this.knots[i] - this.knots[i - 1] >= KnotVector.knotTolerance)\r\n return i - 1;\r\n }\r\n return this.rightKnotIndex - 1; // shouldn't get here\r\n }\r\n /**\r\n * Given a span index, return the index of the knot at its left.\r\n * @param spanIndex index of span\r\n */\r\n public spanIndexToLeftKnotIndex(spanIndex: number): number {\r\n const d = this.degree;\r\n if (spanIndex <= 0.0) return d - 1;\r\n return Math.min(spanIndex + d - 1, this.knots.length - d - 1);\r\n }\r\n /** Return the knot interval length of indexed bezier span. */\r\n public spanIndexToSpanLength(spanIndex: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n return this.knots[k + 1] - this.knots[k];\r\n }\r\n /**\r\n * Given a span index, test if it is within range and has nonzero length.\r\n * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) followed by more real spans\r\n * @param spanIndex index of span to test.\r\n */\r\n public isIndexOfRealSpan(spanIndex: number): boolean {\r\n if (spanIndex >= 0 && spanIndex < this.numSpans)\r\n return !Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));\r\n return false;\r\n }\r\n /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths reverse. */\r\n public reflectKnots() {\r\n const a = this.leftKnot;\r\n const b = this.rightKnot;\r\n const numKnots = this.knots.length;\r\n for (let i = 0; i < numKnots; i++)\r\n this.knots[i] = a + (b - this.knots[i]);\r\n this.knots.reverse();\r\n }\r\n\r\n /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */\r\n public static copyKnots(knots: number[] | Float64Array, degree: number, includeExtraEndKnot?: boolean, wrapMode?: BSplineWrapMode): number[] {\r\n const isExtraEndKnotPeriodic = (includeExtraEndKnot && wrapMode === BSplineWrapMode.OpenByAddingControlPoints);\r\n const leftIndex = degree - 1;\r\n const rightIndex = knots.length - degree;\r\n const a0 = knots[leftIndex];\r\n const a1 = knots[rightIndex];\r\n const delta = a1 - a0;\r\n const values: number[] = [];\r\n if (includeExtraEndKnot) {\r\n if (isExtraEndKnotPeriodic)\r\n values.push(knots[rightIndex - degree] - delta);\r\n else\r\n values.push(knots[0]);\r\n }\r\n for (const u of knots) {\r\n values.push(u);\r\n }\r\n if (includeExtraEndKnot) {\r\n if (isExtraEndKnotPeriodic)\r\n values.push(knots[leftIndex + degree] + delta);\r\n else\r\n values.push(knots[knots.length - 1]);\r\n }\r\n return values;\r\n }\r\n\r\n /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */\r\n public copyKnots(includeExtraEndKnot: boolean): number[] {\r\n const wrapMode = (includeExtraEndKnot && this.testClosable()) ? this.wrappable : undefined;\r\n return KnotVector.copyKnots(this.knots, this.degree, includeExtraEndKnot, wrapMode);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"KnotVector.js","sourceRoot":"","sources":["../../../src/bspline/KnotVector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,0CAAuC;AACvC,6DAAyD;AAEzD;;;;GAIG;AACH,IAAY,eAeX;AAfD,WAAY,eAAe;IACzB,+BAA+B;IAC/B,qDAAQ,CAAA;IACR;;;;OAIG;IACH,+FAA6B,CAAA;IAC7B;;;;OAIG;IACH,mFAAuB,CAAA;AACzB,CAAC,EAfW,eAAe,+BAAf,eAAe,QAe1B;AACD;;;;;;;;;;;;;;;GAeG;AACH,MAAa,UAAU;IACrB,uCAAuC;IAChC,KAAK,CAAe;IAC3B,4DAA4D;IACrD,MAAM,CAAS;IACtB,0FAA0F;IAClF,MAAM,CAAS;IACvB,2FAA2F;IACnF,MAAM,CAAS;IACf,SAAS,CAAmB;IACpC,0DAA0D;IACnD,MAAM,CAAU,aAAa,GAAG,MAAM,CAAC;IAC9C,iGAAiG;IACjG,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,kGAAkG;IAClG,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,oEAAoE;IACpE,IAAW,aAAa;QACtB,OAAO,IAAI,CAA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QAAQ,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3F,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACtF,CAAC;;AAxfH,gCAyfC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Bspline\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { Geometry } from \"../Geometry\";\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\n\n/**\n * B-spline curve and surface types in this library are non-periodic. But they can be created from legacy periodic data.\n * This enumeration lists the possible ways a B-spline object can have been created from legacy periodic data.\n * @public\n */\nexport enum BSplineWrapMode {\n /** No conversion performed. */\n None = 0,\n /**\n * The legacy periodic B-spline data was opened up by adding `degree` wrap-around poles.\n * * This is typical of B-spline curves and surfaces constructed with maximum `degree - 1` continuity.\n * * Knots are unaffected by this conversion.\n */\n OpenByAddingControlPoints = 1,\n /**\n * The legacy periodic B-spline data was opened up by removing `degree` exterior knots.\n * * This is typical of rational B-spline curves representing full circles and ellipses.\n * * Poles are unaffected by this conversion.\n */\n OpenByRemovingKnots = 2,\n}\n/**\n * Array of non-decreasing numbers acting as a knot vector for B-spline curves and surfaces.\n *\n * * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1\n * * Various B-spline libraries have confusion over how many \"end knots\" are needed. Many libraries (including MicroStation\n * and Parasolid) demand order knots at each end for clamping. However, only order-1 are really needed. This class uses the\n * order-1 convention.\n * * A span is a single interval of the knots.\n * * The left knot of the span with index `k>=0` is the knot with index `k+degree-1`.\n * * A knot vector is clamped when the first `degree` knots are equal and the last `degree` knots are equal.\n * * The \"active knot interval\" is the subset of the knot vector sans its first and last `degree-1` knots, and serves as\n * the parametric domain of the associated B-spline object.\n * * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.\n * * Callers need to distinguish core computational inputs such as left knot index, knot value, span index, and span fraction.\n * @public\n */\nexport class KnotVector {\n /** The simple array of knot values. */\n public knots: Float64Array;\n /** The degree of basis functions defined in these knots. */\n public degree: number;\n /** The leftmost knot value (of the active interval, ignoring unclamped leading knots). */\n private _knot0: number;\n /** The rightmost knot value (of the active interval, ignoring unclamped leading knots). */\n private _knot1: number;\n private _wrapMode?: BSplineWrapMode;\n /** Tolerance for considering two knots to be the same. */\n public static readonly knotTolerance = 1.0e-9;\n /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots). */\n public get leftKnot() {\n return this._knot0;\n }\n /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots). */\n public get rightKnot() {\n return this._knot1;\n }\n /** Return the index of the leftmost knot of the active interval. */\n public get leftKnotIndex() {\n return this.degree - 1;\n }\n /** Return the index of the rightmost knot of the active interval. */\n public get rightKnotIndex() {\n return this.knots.length - this.degree;\n }\n /**\n * Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used\n * is specified by BSplineWrapMode, and is reversed at serialization time.\n */\n public get wrappable() {\n return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode;\n }\n public set wrappable(value: BSplineWrapMode) {\n this._wrapMode = value;\n }\n /** Return the number of Bezier spans. Note that this includes zero-length spans if there are repeated knots. */\n public get numSpans() {\n return this.rightKnotIndex - this.leftKnotIndex;\n }\n /**\n * Private constructor.\n * * If `knots` is a number array or Float64Array, then its values are copied to the instance array.\n * * If `knots` is a number, the instance array is allocated to this size but left as zeros.\n */\n private constructor(knots: number[] | Float64Array | number, degree: number, wrapMode?: BSplineWrapMode) {\n this.degree = degree;\n this._wrapMode = wrapMode;\n // default values to satisfy compiler; real values happen in setupFixedValues or the final else clause defers to user\n this._knot0 = 0.0;\n this._knot1 = 1.0;\n if (Array.isArray(knots)) {\n this.knots = new Float64Array(knots.length);\n this.setKnots(knots);\n this.setupFixedValues();\n } else if (knots instanceof Float64Array) {\n this.knots = knots.slice();\n this.setupFixedValues();\n } else { // caller is responsible for filling array separately\n const knotSize = knots;\n this.knots = new Float64Array(knotSize);\n }\n }\n /** Copy degree and knots to a new KnotVector. */\n public clone(): KnotVector {\n return new KnotVector(this.knots, this.degree, this.wrappable);\n }\n private setupFixedValues() {\n if (this.degree > 0 && this.knots.length > this.degree) {\n this._knot0 = this.knots[this.degree - 1];\n this._knot1 = this.knots[this.knots.length - this.degree];\n }\n }\n /**\n * Return the length of the active knot interval.\n * * This is the size of (one dimension of) the parametric domain for the associated B-spline object.\n */\n public get knotLength01(): number {\n return this._knot1 - this._knot0;\n }\n /**\n * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified\n * wrap mode.\n * @param mode optional test mode. If undefined, use this.wrappable.\n */\n public testClosable(mode?: BSplineWrapMode): boolean {\n if (mode === undefined)\n mode = this.wrappable;\n const degree = this.degree;\n const leftKnotIndex = this.leftKnotIndex;\n const rightKnotIndex = this.rightKnotIndex;\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\n // maximum continuity mode: we expect degree periodically extended knots at each end\n const period = this.rightKnot - this.leftKnot;\n const indexDelta = rightKnotIndex - leftKnotIndex;\n for (let k0 = 0; k0 < leftKnotIndex + degree; k0++) {\n const k1 = k0 + indexDelta;\n if (Math.abs(this.knots[k0] + period - this.knots[k1]) >= KnotVector.knotTolerance)\n return false;\n }\n return true;\n }\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\n // legacy periodic mode: we expect multiplicity degree knots at each end\n const numRepeated = degree - 1;\n const leftKnot = this.leftKnot;\n const rightKnot = this.rightKnot;\n for (let i = 0; i < numRepeated; i++) {\n if (Math.abs(leftKnot - this.knots[leftKnotIndex - i - 1]) >= KnotVector.knotTolerance)\n return false;\n if (Math.abs(rightKnot - this.knots[rightKnotIndex + i + 1]) >= KnotVector.knotTolerance)\n return false;\n }\n return true;\n }\n return false;\n }\n /** Test matching degree and knot values. */\n public isAlmostEqual(other: KnotVector): boolean {\n if (this.degree !== other.degree)\n return false;\n return NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);\n }\n /** Compute the multiplicity of the input knot, or zero if not a knot. */\n public getKnotMultiplicity(knot: number): number {\n let m = 0;\n for (const k of this.knots) {\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\n ++m;\n else if (knot < k)\n break;\n }\n return m;\n }\n /** Compute the multiplicity of the knot at the given index. */\n public getKnotMultiplicityAtIndex(knotIndex: number): number {\n let m = 0;\n if (knotIndex >= 0 && knotIndex < this.knots.length) {\n const knot = this.knots[knotIndex];\n ++m; // count this knot\n for (let i = knotIndex - 1; i >= 0; --i) {\n const k = this.knots[i];\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\n ++m; // found multiple to left of knot\n else if (knot > k)\n break;\n }\n for (let i = knotIndex + 1; i < this.knots.length; ++i) {\n const k = this.knots[i];\n if (Math.abs(k - knot) < KnotVector.knotTolerance)\n ++m; // found multiple to right of knot\n else if (knot < k)\n break;\n }\n }\n return m;\n }\n /**\n * Transform knots such that the active knot range becomes [0,1].\n * @returns false if and only if `this.knotLength01` is trivial.\n */\n public normalize(): boolean {\n if (this.knotLength01 < KnotVector.knotTolerance)\n return false;\n const divisor = 1.0 / this.knotLength01;\n const leftKnot = this.leftKnot;\n for (let i = 0; i < this.knots.length; ++i)\n this.knots[i] = (this.knots[i] - leftKnot) * divisor;\n // explicitly set rightKnot and its multiples to 1.0 to avoid round-off\n for (let i = this.rightKnotIndex - 1; i > this.leftKnotIndex && (this.knots[i] === this.knots[this.rightKnotIndex]); --i)\n this.knots[i] = 1.0;\n for (let i = this.rightKnotIndex + 1; i < this.knots.length && (this.knots[i] === this.knots[this.rightKnotIndex]); ++i)\n this.knots[i] = 1.0;\n this.knots[this.rightKnotIndex] = 1.0;\n this.setupFixedValues();\n return true;\n }\n /** Install knot values from an array, optionally ignoring first and last. */\n public setKnots(knots: number[] | Float64Array, skipFirstAndLast?: boolean) {\n const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;\n if (numAllocate !== this.knots.length)\n this.knots = new Float64Array(numAllocate);\n if (skipFirstAndLast) {\n for (let i = 1; i + 1 < knots.length; i++)\n this.knots[i - 1] = knots[i];\n } else {\n for (let i = 0; i < knots.length; i++)\n this.knots[i] = knots[i];\n }\n this.setupFixedValues();\n }\n /** Set knots to input array (CAPTURED). */\n public setKnotsCapture(knots: Float64Array) {\n this.knots = knots;\n this.setupFixedValues();\n }\n /**\n * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.\n * @param numPoles number of poles.\n * @param degree degree of polynomial.\n * @param a0 left knot value for active interval.\n * @param a1 right knot value for active interval.\n */\n public static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector {\n const knots = new KnotVector(numPoles + degree - 1, degree);\n let k = 0;\n for (let m = 0; m < degree; m++)\n knots.knots[k++] = a0;\n const du = 1.0 / (numPoles - degree);\n for (let i = 1; i + degree < numPoles; i++)\n knots.knots[k++] = a0 + i * du * (a1 - a0);\n for (let m = 0; m < degree; m++)\n knots.knots[k++] = a1;\n knots.setupFixedValues();\n return knots;\n }\n /**\n * Create knot vector with wraparound knots at start and end, and uniform knots between.\n * @param numInterval the number of intervals into which to uniformly divide the active knot interval `[a0,a1]`,\n * creating `numInterval-1` equally spaced interior knots between `a0` and `a1`.\n * This number is equal to the number of Bezier spans in the associated B-spline object.\n * It is _not_ the pole count.\n * @param degree degree of polynomial.\n * @param a0 left knot value for active interval.\n * @param a1 right knot value for active interval.\n */\n public static createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector {\n const knots = new KnotVector(numInterval + 2 * degree - 1, degree);\n const du = 1.0 / numInterval;\n for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++)\n knots.knots[k] = Geometry.interpolate(a0, i * du, a1);\n knots.setupFixedValues();\n return knots;\n }\n /**\n * Create knot vector with given knot values and degree.\n * @param knotArray knot values.\n * @param degree degree of polynomial.\n * @param skipFirstAndLast true to skip copying the first and last knot values.\n */\n public static create(knotArray: number[] | Float64Array, degree: number, skipFirstAndLast?: boolean): KnotVector {\n const numAllocate = skipFirstAndLast ? knotArray.length - 2 : knotArray.length;\n const knots = new KnotVector(numAllocate, degree);\n knots.setKnots(knotArray, skipFirstAndLast);\n return knots;\n }\n /**\n * Return the average of degree consecutive knots beginning at knotIndex.\n * * If `knotIndex` is negative, return `leftKnot`.\n * * If `knotIndex > rightKnotIndex` return `rightKnot`.\n */\n public grevilleKnot(knotIndex: number): number {\n if (knotIndex < 0)\n return this.leftKnot;\n if (knotIndex > this.rightKnotIndex)\n return this.rightKnot;\n knotIndex = Math.floor(knotIndex);\n let sum = 0.0;\n for (let i = knotIndex; i < knotIndex + this.degree; i++)\n sum += this.knots[i];\n return sum / this.degree;\n }\n /** Return an array of size `degree + 1`, e.g., to hold the set of relevant basis function values at a parameter. */\n public createBasisArray(): Float64Array {\n return new Float64Array(this.degree + 1);\n }\n /** Convert localFraction within the interval following an indexed knot to a knot value. */\n public baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number {\n const knot0 = this.knots[knotIndex0];\n localFraction = Geometry.clamp(localFraction, 0, 1);\n return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);\n }\n /** Convert localFraction within an indexed bezier span to a knot value. */\n public spanFractionToKnot(spanIndex: number, localFraction: number): number {\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\n localFraction = Geometry.clamp(localFraction, 0, 1);\n return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);\n }\n /** Convert localFraction within an indexed bezier span to fraction of active knot range. */\n public spanFractionToFraction(spanIndex: number, localFraction: number): number {\n const knot = this.spanFractionToKnot(spanIndex, localFraction);\n return (knot - this.leftKnot) / (this.rightKnot - this.leftKnot);\n }\n /** Return fraction of active knot range to knot value. */\n public fractionToKnot(fraction: number): number {\n fraction = Geometry.clamp(fraction, 0, 1); // B-splines are not extendable\n return Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);\n }\n private isKnotInValidSpan(knotIndex0: number, u: number): boolean {\n const spanIsValid = knotIndex0 >= this.degree - 1 && knotIndex0 + this.degree < this.knots.length;\n const uIsInSpan = this.knots[knotIndex0] <= u && u <= this.knots[knotIndex0 + 1];\n return spanIsValid && uIsInSpan;\n }\n /**\n * Evaluate the B-spline basis functions f[] at a parameter u in a knot span.\n * * This method implements the Mansfield-Cox-de Boor recurrence relation.\n * @param knotIndex0 index of the left knot of the span.\n * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].\n * @param f preallocated output array of order basis function values.\n * @returns true if and only if output array is sufficiently sized.\n */\n public evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array): boolean {\n if (f.length < this.degree + 1)\n return false;\n assert(() => this.isKnotInValidSpan(knotIndex0, u), \"knot is in a valid span\");\n f[0] = 1.0;\n if (this.degree < 1)\n return true;\n // direct compute for linear part\n const u0 = this.knots[knotIndex0];\n const u1 = this.knots[knotIndex0 + 1];\n f[1] = (u - u0) / (u1 - u0);\n f[0] = 1.0 - f[1];\n if (this.degree < 2)\n return true;\n // each iteration of the outer loop evaluates the basis functions of degree depth+1 using\n // one or two values of the basis functions of one less degree from the preceding iteration\n for (let depth = 1; depth < this.degree; depth++) {\n let kLeft = knotIndex0 - depth;\n let kRight = knotIndex0 + 1;\n let gCarry = 0.0;\n for (let step = 0; step <= depth; step++) {\n const tLeft = this.knots[kLeft++];\n const tRight = this.knots[kRight++];\n const fraction = (u - tLeft) / (tRight - tLeft);\n const g1 = f[step] * fraction;\n const g0 = f[step] * (1.0 - fraction);\n f[step] = gCarry + g0;\n gCarry = g1;\n }\n f[depth + 1] = gCarry;\n // at this point, the head of f[] contains the depth+2 values at u\n // of the basis functions of degree depth+1 with support over [u0,u1)\n }\n return true;\n }\n /**\n * Evaluate basis functions f[], derivatives df[], and optional second derivatives ddf[] at a parameter u\n * in a knot span.\n * @param knotIndex0 index of the left knot of the span.\n * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].\n * @param f preallocated output array of order basis function values.\n * @param df preallocated output array of order basis derivative values.\n * @param ddf optional preallocated output array of order basis second derivative values.\n * @returns true if and only if output arrays are sufficiently sized.\n */\n public evaluateBasisFunctions1(\n knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array,\n ): boolean {\n if (f.length < this.degree + 1)\n return false;\n if (df.length < this.degree + 1)\n return false;\n if (ddf && ddf.length < this.degree + 1)\n return false;\n assert(() => this.isKnotInValidSpan(knotIndex0, u), \"knot is in a valid span\");\n f[0] = 1.0;\n df[0] = 0.0;\n if (this.degree < 1)\n return true;\n // direct compute for linear part\n const u0 = this.knots[knotIndex0];\n const u1 = this.knots[knotIndex0 + 1];\n // ah = 1/(u1-u0) is the derivative of fraction0\n // -ah is the derivative of fraction1\n let ah = 1.0 / (u1 - u0);\n f[1] = (u - u0) * ah;\n f[0] = 1.0 - f[1];\n df[0] = -ah; df[1] = ah;\n if (ddf) { // first derivative started constant, second derivative started zero.\n ddf[0] = 0.0;\n ddf[1] = 0.0;\n }\n if (this.degree < 2)\n return true;\n for (let depth = 1; depth < this.degree; depth++) {\n let kLeft = knotIndex0 - depth;\n let kRight = kLeft + depth + 1;\n let gCarry = 0.0;\n let dgCarry = 0.0;\n let ddgCarry = 0.0;\n // f, df, ddf, are each row vectors with product of `step` linear terms.\n // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)\n // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)\n // Hence fnew = f * V\n // dfnew = df * V + f * dV\n // ddfnew = ddf * V + df*dV + df * dV + f * ddV\n // but ddV is zero so\n // ddfnew = ddf * V + 2 * df * dV\n for (let step = 0; step <= depth; step++) {\n const tLeft = this.knots[kLeft++];\n const tRight = this.knots[kRight++];\n ah = 1.0 / (tRight - tLeft);\n const fraction = (u - tLeft) * ah;\n const fraction1 = 1.0 - fraction;\n const g1 = f[step] * fraction;\n const g0 = f[step] * fraction1;\n const dg1 = df[step] * fraction + f[step] * ah;\n const dg0 = df[step] * fraction1 - f[step] * ah;\n const dfSave = 2.0 * df[step] * ah;\n f[step] = gCarry + g0;\n df[step] = dgCarry + dg0;\n gCarry = g1;\n dgCarry = dg1;\n if (ddf) { // do the backward reference to df before rewriting df\n const ddg1 = ddf[step] * fraction + dfSave;\n const ddg0 = ddf[step] * fraction1 - dfSave;\n ddf[step] = ddgCarry + ddg0;\n ddgCarry = ddg1;\n }\n }\n f[depth + 1] = gCarry;\n df[depth + 1] = dgCarry;\n if (ddf)\n ddf[depth + 1] = ddgCarry;\n }\n return true;\n }\n /**\n * Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.\n * * If u has no such bracket, return the smaller index of the closest nontrivial bracket.\n * @param u value to bracket.\n */\n public knotToLeftKnotIndex(u: number): number {\n for (let i = this.leftKnotIndex; i < this.rightKnotIndex; ++i) {\n if (u < this.knots[i + 1])\n return i;\n }\n // for u >= rightKnot, return left index of last nontrivial span\n for (let i = this.rightKnotIndex; i > this.leftKnotIndex; --i) {\n if (this.knots[i] - this.knots[i - 1] >= KnotVector.knotTolerance)\n return i - 1;\n }\n return this.rightKnotIndex - 1; // shouldn't get here\n }\n /**\n * Given a span index, return the index of the knot at its left.\n * @param spanIndex index of span.\n */\n public spanIndexToLeftKnotIndex(spanIndex: number): number {\n const d = this.degree;\n if (spanIndex <= 0.0)\n return d - 1;\n return Math.min(spanIndex + d - 1, this.knots.length - d - 1);\n }\n /** Return the knot interval length of indexed bezier span. */\n public spanIndexToSpanLength(spanIndex: number): number {\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\n return this.knots[k + 1] - this.knots[k];\n }\n /**\n * Given a span index, test if it is within range and has nonzero length.\n * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span)\n * followed by more real spans\n * @param spanIndex index of span to test.\n */\n public isIndexOfRealSpan(spanIndex: number): boolean {\n if (spanIndex >= 0 && spanIndex < this.numSpans)\n return !Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));\n return false;\n }\n /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths are reversed. */\n public reflectKnots(): void {\n const a = this.leftKnot;\n const b = this.rightKnot;\n const numKnots = this.knots.length;\n for (let i = 0; i < numKnots; i++)\n this.knots[i] = a + (b - this.knots[i]);\n this.knots.reverse();\n }\n /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */\n public static copyKnots(\n knots: number[] | Float64Array, degree: number, includeExtraEndKnot?: boolean, wrapMode?: BSplineWrapMode,\n ): number[] {\n const isExtraEndKnotPeriodic = (includeExtraEndKnot && wrapMode === BSplineWrapMode.OpenByAddingControlPoints);\n const leftIndex = degree - 1;\n const rightIndex = knots.length - degree;\n const a0 = knots[leftIndex];\n const a1 = knots[rightIndex];\n const delta = a1 - a0;\n const values: number[] = [];\n if (includeExtraEndKnot) {\n if (isExtraEndKnotPeriodic)\n values.push(knots[rightIndex - degree] - delta);\n else\n values.push(knots[0]);\n }\n for (const u of knots) {\n values.push(u);\n }\n if (includeExtraEndKnot) {\n if (isExtraEndKnotPeriodic)\n values.push(knots[leftIndex + degree] + delta);\n else\n values.push(knots[knots.length - 1]);\n }\n return values;\n }\n /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */\n public copyKnots(includeExtraEndKnot: boolean): number[] {\n const wrapMode = (includeExtraEndKnot && this.testClosable()) ? this.wrappable : undefined;\n return KnotVector.copyKnots(this.knots, this.degree, includeExtraEndKnot, wrapMode);\n }\n}\n"]}