@itwin/core-geometry 5.9.0-dev.7 → 5.9.0-dev.9

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 (225) hide show
  1. package/lib/cjs/Geometry.d.ts +8 -6
  2. package/lib/cjs/Geometry.d.ts.map +1 -1
  3. package/lib/cjs/Geometry.js +8 -6
  4. package/lib/cjs/Geometry.js.map +1 -1
  5. package/lib/cjs/curve/Arc3d.d.ts +7 -0
  6. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  7. package/lib/cjs/curve/Arc3d.js +11 -0
  8. package/lib/cjs/curve/Arc3d.js.map +1 -1
  9. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +11 -2
  10. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  11. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +25 -15
  12. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  13. package/lib/cjs/curve/CurveCollection.d.ts +15 -6
  14. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  15. package/lib/cjs/curve/CurveCollection.js +15 -6
  16. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  17. package/lib/cjs/curve/CurveCurve.d.ts +1 -1
  18. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  19. package/lib/cjs/curve/CurveCurve.js +2 -1
  20. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  21. package/lib/cjs/curve/CurveLocationDetail.d.ts +21 -0
  22. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  23. package/lib/cjs/curve/CurveLocationDetail.js +59 -0
  24. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  25. package/lib/cjs/curve/CurvePrimitive.d.ts +13 -12
  26. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  27. package/lib/cjs/curve/CurvePrimitive.js +12 -11
  28. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  29. package/lib/cjs/curve/RegionOps.d.ts +17 -4
  30. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  31. package/lib/cjs/curve/RegionOps.js +114 -18
  32. package/lib/cjs/curve/RegionOps.js.map +1 -1
  33. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +3 -11
  34. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  35. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +1 -91
  36. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  37. package/lib/cjs/curve/StrokeOptions.d.ts +13 -6
  38. package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
  39. package/lib/cjs/curve/StrokeOptions.js +13 -6
  40. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  41. package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts +1 -1
  42. package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts.map +1 -1
  43. package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.js +1 -2
  44. package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.js.map +1 -1
  45. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +1 -1
  46. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -1
  47. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +1 -2
  48. package/lib/cjs/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -1
  49. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  50. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  51. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +1 -2
  52. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  53. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +113 -103
  54. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  55. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +368 -337
  56. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  57. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +2 -3
  58. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  59. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +20 -32
  60. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  61. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +1 -2
  62. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  63. package/lib/cjs/curve/spiral/DirectSpiral3d.js +9 -3
  64. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  65. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts +1 -2
  66. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  67. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +10 -4
  68. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  69. package/lib/cjs/geometry3d/AngleSweep.d.ts +3 -1
  70. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  71. package/lib/cjs/geometry3d/AngleSweep.js +6 -2
  72. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  73. package/lib/cjs/geometry3d/GeometryHandler.d.ts +33 -4
  74. package/lib/cjs/geometry3d/GeometryHandler.d.ts.map +1 -1
  75. package/lib/cjs/geometry3d/GeometryHandler.js +79 -1
  76. package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
  77. package/lib/cjs/geometry3d/GrowableXYArray.d.ts +9 -6
  78. package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
  79. package/lib/cjs/geometry3d/GrowableXYArray.js +20 -10
  80. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  81. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +9 -6
  82. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  83. package/lib/cjs/geometry3d/GrowableXYZArray.js +20 -10
  84. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  85. package/lib/cjs/geometry3d/Matrix3d.d.ts +4 -4
  86. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  87. package/lib/cjs/geometry3d/Matrix3d.js +5 -4
  88. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  89. package/lib/cjs/numerics/BezierPolynomials.d.ts.map +1 -1
  90. package/lib/cjs/numerics/BezierPolynomials.js +1 -1
  91. package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
  92. package/lib/cjs/numerics/Newton.d.ts +44 -13
  93. package/lib/cjs/numerics/Newton.d.ts.map +1 -1
  94. package/lib/cjs/numerics/Newton.js +73 -23
  95. package/lib/cjs/numerics/Newton.js.map +1 -1
  96. package/lib/cjs/polyface/PolyfaceQuery.d.ts +14 -14
  97. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  98. package/lib/cjs/polyface/PolyfaceQuery.js +14 -14
  99. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  100. package/lib/cjs/serialization/BGFBReader.js +2 -2
  101. package/lib/cjs/serialization/BGFBReader.js.map +1 -1
  102. package/lib/cjs/topology/Graph.d.ts +15 -15
  103. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  104. package/lib/cjs/topology/Graph.js +1 -1
  105. package/lib/cjs/topology/Graph.js.map +1 -1
  106. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts +3 -3
  107. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  108. package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
  109. package/lib/esm/Geometry.d.ts +8 -6
  110. package/lib/esm/Geometry.d.ts.map +1 -1
  111. package/lib/esm/Geometry.js +8 -6
  112. package/lib/esm/Geometry.js.map +1 -1
  113. package/lib/esm/curve/Arc3d.d.ts +7 -0
  114. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  115. package/lib/esm/curve/Arc3d.js +11 -0
  116. package/lib/esm/curve/Arc3d.js.map +1 -1
  117. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +11 -2
  118. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  119. package/lib/esm/curve/CurveChainWithDistanceIndex.js +25 -15
  120. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  121. package/lib/esm/curve/CurveCollection.d.ts +15 -6
  122. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  123. package/lib/esm/curve/CurveCollection.js +15 -6
  124. package/lib/esm/curve/CurveCollection.js.map +1 -1
  125. package/lib/esm/curve/CurveCurve.d.ts +1 -1
  126. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  127. package/lib/esm/curve/CurveCurve.js +2 -1
  128. package/lib/esm/curve/CurveCurve.js.map +1 -1
  129. package/lib/esm/curve/CurveLocationDetail.d.ts +21 -0
  130. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  131. package/lib/esm/curve/CurveLocationDetail.js +59 -0
  132. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  133. package/lib/esm/curve/CurvePrimitive.d.ts +13 -12
  134. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  135. package/lib/esm/curve/CurvePrimitive.js +12 -11
  136. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  137. package/lib/esm/curve/RegionOps.d.ts +17 -4
  138. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  139. package/lib/esm/curve/RegionOps.js +116 -20
  140. package/lib/esm/curve/RegionOps.js.map +1 -1
  141. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +3 -11
  142. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  143. package/lib/esm/curve/RegionOpsClassificationSweeps.js +2 -92
  144. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  145. package/lib/esm/curve/StrokeOptions.d.ts +13 -6
  146. package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
  147. package/lib/esm/curve/StrokeOptions.js +13 -6
  148. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  149. package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts +1 -1
  150. package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts.map +1 -1
  151. package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.js +1 -2
  152. package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.js.map +1 -1
  153. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts +1 -1
  154. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.d.ts.map +1 -1
  155. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js +1 -2
  156. package/lib/esm/curve/internalContexts/AppendPlaneIntersectionStrokeHandler.js.map +1 -1
  157. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  158. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  159. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +1 -2
  160. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  161. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +113 -103
  162. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  163. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +370 -339
  164. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  165. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +2 -3
  166. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  167. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +20 -32
  168. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  169. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +1 -2
  170. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  171. package/lib/esm/curve/spiral/DirectSpiral3d.js +9 -3
  172. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  173. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts +1 -2
  174. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  175. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +10 -4
  176. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  177. package/lib/esm/geometry3d/AngleSweep.d.ts +3 -1
  178. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  179. package/lib/esm/geometry3d/AngleSweep.js +6 -2
  180. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  181. package/lib/esm/geometry3d/GeometryHandler.d.ts +33 -4
  182. package/lib/esm/geometry3d/GeometryHandler.d.ts.map +1 -1
  183. package/lib/esm/geometry3d/GeometryHandler.js +77 -0
  184. package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
  185. package/lib/esm/geometry3d/GrowableXYArray.d.ts +9 -6
  186. package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
  187. package/lib/esm/geometry3d/GrowableXYArray.js +20 -10
  188. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  189. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +9 -6
  190. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  191. package/lib/esm/geometry3d/GrowableXYZArray.js +20 -10
  192. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  193. package/lib/esm/geometry3d/Matrix3d.d.ts +4 -4
  194. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  195. package/lib/esm/geometry3d/Matrix3d.js +5 -4
  196. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  197. package/lib/esm/numerics/BezierPolynomials.d.ts.map +1 -1
  198. package/lib/esm/numerics/BezierPolynomials.js +1 -1
  199. package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
  200. package/lib/esm/numerics/Newton.d.ts +44 -13
  201. package/lib/esm/numerics/Newton.d.ts.map +1 -1
  202. package/lib/esm/numerics/Newton.js +71 -22
  203. package/lib/esm/numerics/Newton.js.map +1 -1
  204. package/lib/esm/polyface/PolyfaceQuery.d.ts +14 -14
  205. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  206. package/lib/esm/polyface/PolyfaceQuery.js +14 -14
  207. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  208. package/lib/esm/serialization/BGFBReader.js +2 -2
  209. package/lib/esm/serialization/BGFBReader.js.map +1 -1
  210. package/lib/esm/topology/Graph.d.ts +15 -15
  211. package/lib/esm/topology/Graph.d.ts.map +1 -1
  212. package/lib/esm/topology/Graph.js +1 -1
  213. package/lib/esm/topology/Graph.js.map +1 -1
  214. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts +3 -3
  215. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  216. package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
  217. package/package.json +3 -3
  218. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +0 -23
  219. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +0 -1
  220. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js +0 -37
  221. package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +0 -1
  222. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +0 -23
  223. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +0 -1
  224. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js +0 -33
  225. package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +0 -1
@@ -21,7 +21,7 @@ export declare abstract class AbstractNewtonIterator {
21
21
  * Apply the current step (in all dimensions).
22
22
  * @param isFinalStep true if this is a final step.
23
23
  */
24
- abstract applyCurrentStep(isFinalStep: boolean): boolean;
24
+ abstract applyCurrentStep(isFinalStep: boolean): void;
25
25
  /**
26
26
  * The constructor.
27
27
  * @param stepSizeTolerance tolerance to consider a single step converged.
@@ -29,10 +29,10 @@ export declare abstract class AbstractNewtonIterator {
29
29
  * it is expected that a first "accept" for (say) 10 to 14 digit step will be followed by another
30
30
  * iteration. A well behaved newton would then hypothetically double the number of digits to
31
31
  * 20 to 28. Since the IEEE double only carries 16 digits, this second-convergence step will
32
- * typically achieve full precision.
33
- * @param successiveConvergenceTarget number of successive convergences required for acceptance.
32
+ * typically achieve full precision. Default [[Geometry.smallNewtonStep]].
33
+ * @param successiveConvergenceTarget number of successive convergences required for acceptance. Default 2.
34
34
  * @param maxIterations max number of iterations. A typical newton step converges in 3 to 6 iterations.
35
- * Allow 15 to 20 to catch difficult cases.
35
+ * Allow 15 to 20 to catch difficult cases. Default 15.
36
36
  */
37
37
  protected constructor(stepSizeTolerance?: number, successiveConvergenceTarget?: number, maxIterations?: number);
38
38
  /** Number of consecutive steps which passed convergence condition. */
@@ -45,6 +45,14 @@ export declare abstract class AbstractNewtonIterator {
45
45
  protected _maxIterations: number;
46
46
  /** Number of iterations (incremented at each step). */
47
47
  numIterations: number;
48
+ /** Get the relative tolerance for comparing iterations in [[testConvergence]]. */
49
+ get stepSizeTolerance(): number;
50
+ /** Smallest iterate size difference in later iterations. */
51
+ private _leastDelta;
52
+ /** The current late iterate has the least delta encountered. Remember it. Implement along with [[restoreCandidate]].*/
53
+ protected cacheCandidate?(): void;
54
+ /** Set Newton result to the cached candidate. Implement along with [[cacheCandidate]]. */
55
+ protected restoreCandidate?(): void;
48
56
  /**
49
57
  * Test if a step is converged.
50
58
  * * Convergence is accepted with enough (_successiveConvergenceTarget) small steps (according to _stepSizeTolerance)
@@ -95,13 +103,13 @@ export declare class Newton1dUnbounded extends AbstractNewtonIterator {
95
103
  */
96
104
  constructor(func: NewtonEvaluatorRtoRD, maxIterations?: number);
97
105
  /** Set the independent variable, i.e., x_n. */
98
- setX(x: number): boolean;
106
+ setX(x: number): void;
99
107
  /** Get the independent variable, i.e., x_n. */
100
108
  getX(): number;
101
109
  /** Set the target function value. */
102
110
  setTarget(y: number): void;
103
111
  /** Move the current X by the just-computed step, i.e., `x_n - dx`. */
104
- applyCurrentStep(): boolean;
112
+ applyCurrentStep(): void;
105
113
  /** Compute the univariate newton step dx. */
106
114
  computeStep(): boolean;
107
115
  /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */
@@ -117,6 +125,23 @@ export declare abstract class NewtonEvaluatorRtoR {
117
125
  /** Most recent function evaluation, i.e., f(x_n). */
118
126
  currentF: number;
119
127
  }
128
+ /**
129
+ * Intermediate class for managing the parentCurve announcements from an IStrokeHandler.
130
+ * @internal
131
+ */
132
+ export declare abstract class NewtonRtoRStrokeHandler extends NewtonEvaluatorRtoR {
133
+ protected _parentCurvePrimitive: CurvePrimitive | undefined;
134
+ constructor();
135
+ /**
136
+ * Retain the parentCurvePrimitive.
137
+ * * Calling this method tells the handler that the parent curve is to be used for detail searches.
138
+ * * Example: Transition spiral search is based on linestring first, then the exact spiral.
139
+ * * Example: CurveChainWithDistanceIndex does NOT do this announcement; the constituents act independently.
140
+ */
141
+ startParentCurvePrimitive(curve: CurvePrimitive | undefined): void;
142
+ /** Forget the parentCurvePrimitive */
143
+ endParentCurvePrimitive(_curve: CurvePrimitive | undefined): void;
144
+ }
120
145
  /**
121
146
  * Newton iteration for a univariate function, using approximate derivatives.
122
147
  * To approximate the derivatives we use a small step `h`, i.e., `f'(x_n) = (f(x_n + h) - f(x_n)) / h`.
@@ -142,11 +167,11 @@ export declare class Newton1dUnboundedApproximateDerivative extends AbstractNewt
142
167
  */
143
168
  constructor(func: NewtonEvaluatorRtoR, maxIterations?: number);
144
169
  /** Set the independent variable, i.e., x_n. */
145
- setX(x: number): boolean;
170
+ setX(x: number): void;
146
171
  /** Get the independent variable, i.e., x_n. */
147
172
  getX(): number;
148
173
  /** Move the current X by the just-computed step, i.e., `x_n - dx`. */
149
- applyCurrentStep(): boolean;
174
+ applyCurrentStep(): void;
150
175
  /** Univariate newton step dx, computed with approximate derivative. */
151
176
  computeStep(): boolean;
152
177
  /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */
@@ -198,18 +223,18 @@ export declare class Newton2dUnboundedWithDerivative extends AbstractNewtonItera
198
223
  /**
199
224
  * Constructor for 2D newton iteration with derivatives.
200
225
  * @param func function that returns both function value and derivative.
226
+ * @param maxIterations max number of iterations. Default 15.
227
+ * @param stepSizeTolerance tolerance to consider a single step converged. Default [[Geometry.smallNewtonStep]].
201
228
  */
202
- constructor(func: NewtonEvaluatorRRtoRRD, maxIterations?: number);
229
+ constructor(func: NewtonEvaluatorRRtoRRD, maxIterations?: number, stepSizeTolerance?: number);
203
230
  /** Set the current uv parameters, i.e., `X_n = (u_n, v_n)`. */
204
- setUV(u: number, v: number): boolean;
231
+ setUV(u: number, v: number): void;
205
232
  /** Get the current u parameter of X_n, i.e., u_n. */
206
233
  getU(): number;
207
234
  /** Get the current v parameter of X_n, i.e., v_n. */
208
235
  getV(): number;
209
- /** Get the relative tolerance for comparing iterations in [[testConvergence]]. */
210
- get stepSizeTolerance(): number;
211
236
  /** Update the current uv parameter by currentStep, i.e., compute `X_{n+1} := X_n - dX = (u_n - du, v_n - dv)`. */
212
- applyCurrentStep(): boolean;
237
+ applyCurrentStep(): void;
213
238
  /**
214
239
  * Evaluate the functions and derivatives at `X_n = (u_n, v_n)`, and solve the Jacobian matrix equation to
215
240
  * compute `dX = (du, dv)`.
@@ -219,6 +244,12 @@ export declare class Newton2dUnboundedWithDerivative extends AbstractNewtonItera
219
244
  * Return the current relative step size, i.e., the larger absolute component of `dX / (1 + |X_n|)`
220
245
  */
221
246
  currentStepSize(): number;
247
+ /** Candidate solution cache. */
248
+ private _cachedUV;
249
+ /** The current late iterate has the least delta encountered. Remember it. */
250
+ protected cacheCandidate(): void;
251
+ /** Set Newton result to the cached candidate. */
252
+ protected restoreCandidate(): void;
222
253
  }
223
254
  /**
224
255
  * SimpleNewton has static methods for newton methods with evaluated functions presented as immediate arguments
@@ -1 +1 @@
1
- {"version":3,"file":"Newton.d.ts","sourceRoot":"","sources":["../../../src/numerics/Newton.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAMxD;;;;GAIG;AACH,8BAAsB,sBAAsB;IAC1C,wGAAwG;aACxF,WAAW,IAAI,OAAO;IACtC;;;OAGG;aACa,eAAe,IAAI,MAAM;IACzC;;;OAGG;aACa,gBAAgB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAC/D;;;;;;;;;;;OAWG;IACH,SAAS,aACP,iBAAiB,GAAE,MAAgB,EACnC,2BAA2B,GAAE,MAAU,EACvC,aAAa,GAAE,MAAW;IAM5B,sEAAsE;IACtE,SAAS,CAAC,YAAY,EAAE,MAAM,CAAK;IACnC,gDAAgD;IAChD,SAAS,CAAC,4BAA4B,EAAE,MAAM,CAAC;IAC/C,4FAA4F;IAC5F,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACrC,8BAA8B;IAC9B,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IACjC,uDAAuD;IAChD,aAAa,EAAE,MAAM,CAAK;IACjC;;;;;OAKG;IACI,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAQ9C;;;;;;OAMG;IACI,aAAa,IAAI,OAAO;CAYhC;AACD;;;;GAIG;AACH,8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AE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC7C,iBAAiB,GAAE,MAAoC,GACtD,MAAM,GAAG,SAAS;CAyBtB;AAED;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,sBAAsB;IACzE,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,KAAK,CAAQ;gBACT,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc;IAOnD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;CAmB/D;AAED;;;GAGG;AACH,qBAAa,8BAA+B,SAAQ,oBAAoB;IACtE,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAA4B;gBAC/B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO;IAM5C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAqB5C;AAED;;;GAGG;AACH,qBAAa,gCAAiC,SAAQ,sBAAsB;IAC1E,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,OAAO,CAA4B;gBAC/B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc;IAOnD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;CAqC/D"}
@@ -4,13 +4,19 @@
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.CurveCurveCloseApproachXYRRtoRRD = exports.CurvePointCloseApproachXYRtoRD = exports.CurveCurveIntersectionXYRRToRRD = exports.SimpleNewton = exports.Newton2dUnboundedWithDerivative = exports.NewtonEvaluatorRRtoRRD = exports.Newton1dUnboundedApproximateDerivative = exports.NewtonEvaluatorRtoR = exports.Newton1dUnbounded = exports.NewtonEvaluatorRtoRD = exports.AbstractNewtonIterator = void 0;
7
+ exports.CurveCurveCloseApproachXYRRtoRRD = exports.CurvePointCloseApproachXYRtoRD = exports.CurveCurveIntersectionXYRRToRRD = exports.SimpleNewton = exports.Newton2dUnboundedWithDerivative = exports.NewtonEvaluatorRRtoRRD = exports.Newton1dUnboundedApproximateDerivative = exports.NewtonRtoRStrokeHandler = exports.NewtonEvaluatorRtoR = exports.Newton1dUnbounded = exports.NewtonEvaluatorRtoRD = exports.AbstractNewtonIterator = void 0;
8
8
  const Geometry_1 = require("../Geometry");
9
9
  const Plane3dByOriginAndVectors_1 = require("../geometry3d/Plane3dByOriginAndVectors");
10
10
  const Point2dVector2d_1 = require("../geometry3d/Point2dVector2d");
11
11
  const Ray3d_1 = require("../geometry3d/Ray3d");
12
12
  const SmallSystem_1 = require("./SmallSystem");
13
13
  // cspell:word currentdFdX XYRR
14
+ // A note on differences between using derivatives vs. approximate derivatives for Newton:
15
+ // * Converged values are the same under both schemes.
16
+ // * With derivatives, Newton convergence is quadratic rather than power 1.62 with approximate derivatives.
17
+ // * With approximate derivatives:
18
+ // - the extra iterative cost is incidental for low iteration counts, and may even be offset by simpler computation.
19
+ // - the step choice is not based on serious analysis, so could be problematic.
14
20
  /**
15
21
  * Base class for Newton iterations in various dimensions.
16
22
  * Dimension-specific classes carry all dimension-related data and answer generalized queries from this base class.
@@ -24,12 +30,12 @@ class AbstractNewtonIterator {
24
30
  * it is expected that a first "accept" for (say) 10 to 14 digit step will be followed by another
25
31
  * iteration. A well behaved newton would then hypothetically double the number of digits to
26
32
  * 20 to 28. Since the IEEE double only carries 16 digits, this second-convergence step will
27
- * typically achieve full precision.
28
- * @param successiveConvergenceTarget number of successive convergences required for acceptance.
33
+ * typically achieve full precision. Default [[Geometry.smallNewtonStep]].
34
+ * @param successiveConvergenceTarget number of successive convergences required for acceptance. Default 2.
29
35
  * @param maxIterations max number of iterations. A typical newton step converges in 3 to 6 iterations.
30
- * Allow 15 to 20 to catch difficult cases.
36
+ * Allow 15 to 20 to catch difficult cases. Default 15.
31
37
  */
32
- constructor(stepSizeTolerance = 1.0e-11, successiveConvergenceTarget = 2, maxIterations = 15) {
38
+ constructor(stepSizeTolerance = Geometry_1.Geometry.smallNewtonStep, successiveConvergenceTarget = 2, maxIterations = 15) {
33
39
  this._stepSizeTolerance = stepSizeTolerance;
34
40
  this._successiveConvergenceTarget = successiveConvergenceTarget;
35
41
  this._maxIterations = maxIterations;
@@ -44,6 +50,12 @@ class AbstractNewtonIterator {
44
50
  _maxIterations;
45
51
  /** Number of iterations (incremented at each step). */
46
52
  numIterations = 0;
53
+ /** Get the relative tolerance for comparing iterations in [[testConvergence]]. */
54
+ get stepSizeTolerance() {
55
+ return this._stepSizeTolerance;
56
+ }
57
+ /** Smallest iterate size difference in later iterations. */
58
+ _leastDelta = Number.MAX_VALUE;
47
59
  /**
48
60
  * Test if a step is converged.
49
61
  * * Convergence is accepted with enough (_successiveConvergenceTarget) small steps (according to _stepSizeTolerance)
@@ -51,6 +63,10 @@ class AbstractNewtonIterator {
51
63
  * @param delta step size as reported by currentStepSize.
52
64
  */
53
65
  testConvergence(delta) {
66
+ if (this.cacheCandidate && delta < this._leastDelta && this.numIterations > 0.5 * this._maxIterations) {
67
+ this._leastDelta = delta;
68
+ this.cacheCandidate();
69
+ }
54
70
  if (Math.abs(delta) < this._stepSizeTolerance) {
55
71
  this._numAccepted++;
56
72
  return this._numAccepted >= this._successiveConvergenceTarget;
@@ -68,13 +84,16 @@ class AbstractNewtonIterator {
68
84
  runIterations() {
69
85
  this._numAccepted = 0;
70
86
  this.numIterations = 0;
87
+ this._leastDelta = Number.MAX_VALUE;
71
88
  while (this.numIterations++ < this._maxIterations && this.computeStep()) {
72
- if (this.testConvergence(this.currentStepSize()) && this.applyCurrentStep(true)) {
73
- // console.log("iter: " + this.numIterations); // print number of Newton iterations for debug
89
+ if (this.testConvergence(this.currentStepSize())) {
90
+ this.applyCurrentStep(true);
74
91
  return true;
75
92
  }
76
93
  this.applyCurrentStep(false);
77
94
  }
95
+ if (this.restoreCandidate && this.numIterations >= this._maxIterations && Math.abs(this.currentStepSize()) > this._leastDelta)
96
+ this.restoreCandidate(); // we may have ended up in a late cycle; return our best guess
78
97
  return false;
79
98
  }
80
99
  }
@@ -118,7 +137,6 @@ class Newton1dUnbounded extends AbstractNewtonIterator {
118
137
  /** Set the independent variable, i.e., x_n. */
119
138
  setX(x) {
120
139
  this._currentX = x;
121
- return true;
122
140
  }
123
141
  /** Get the independent variable, i.e., x_n. */
124
142
  getX() {
@@ -130,8 +148,7 @@ class Newton1dUnbounded extends AbstractNewtonIterator {
130
148
  }
131
149
  /** Move the current X by the just-computed step, i.e., `x_n - dx`. */
132
150
  applyCurrentStep() {
133
- // console.log(this._currentX - this._currentStep); // print approximations for debug
134
- return this.setX(this._currentX - this._currentStep);
151
+ this.setX(this._currentX - this._currentStep);
135
152
  }
136
153
  /** Compute the univariate newton step dx. */
137
154
  computeStep() {
@@ -159,6 +176,31 @@ class NewtonEvaluatorRtoR {
159
176
  currentF;
160
177
  }
161
178
  exports.NewtonEvaluatorRtoR = NewtonEvaluatorRtoR;
179
+ /**
180
+ * Intermediate class for managing the parentCurve announcements from an IStrokeHandler.
181
+ * @internal
182
+ */
183
+ class NewtonRtoRStrokeHandler extends NewtonEvaluatorRtoR {
184
+ _parentCurvePrimitive;
185
+ constructor() {
186
+ super();
187
+ this._parentCurvePrimitive = undefined;
188
+ }
189
+ /**
190
+ * Retain the parentCurvePrimitive.
191
+ * * Calling this method tells the handler that the parent curve is to be used for detail searches.
192
+ * * Example: Transition spiral search is based on linestring first, then the exact spiral.
193
+ * * Example: CurveChainWithDistanceIndex does NOT do this announcement; the constituents act independently.
194
+ */
195
+ startParentCurvePrimitive(curve) {
196
+ this._parentCurvePrimitive = curve;
197
+ }
198
+ /** Forget the parentCurvePrimitive */
199
+ endParentCurvePrimitive(_curve) {
200
+ this._parentCurvePrimitive = undefined;
201
+ }
202
+ }
203
+ exports.NewtonRtoRStrokeHandler = NewtonRtoRStrokeHandler;
162
204
  /**
163
205
  * Newton iteration for a univariate function, using approximate derivatives.
164
206
  * To approximate the derivatives we use a small step `h`, i.e., `f'(x_n) = (f(x_n + h) - f(x_n)) / h`.
@@ -190,7 +232,6 @@ class Newton1dUnboundedApproximateDerivative extends AbstractNewtonIterator {
190
232
  /** Set the independent variable, i.e., x_n. */
191
233
  setX(x) {
192
234
  this._currentX = x;
193
- return true;
194
235
  }
195
236
  /** Get the independent variable, i.e., x_n. */
196
237
  getX() {
@@ -198,8 +239,7 @@ class Newton1dUnboundedApproximateDerivative extends AbstractNewtonIterator {
198
239
  }
199
240
  /** Move the current X by the just-computed step, i.e., `x_n - dx`. */
200
241
  applyCurrentStep() {
201
- // console.log(this._currentX - this._currentStep); // print approximations for debug
202
- return this.setX(this._currentX - this._currentStep);
242
+ this.setX(this._currentX - this._currentStep);
203
243
  }
204
244
  /** Univariate newton step dx, computed with approximate derivative. */
205
245
  computeStep() {
@@ -266,9 +306,11 @@ class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {
266
306
  /**
267
307
  * Constructor for 2D newton iteration with derivatives.
268
308
  * @param func function that returns both function value and derivative.
309
+ * @param maxIterations max number of iterations. Default 15.
310
+ * @param stepSizeTolerance tolerance to consider a single step converged. Default [[Geometry.smallNewtonStep]].
269
311
  */
270
- constructor(func, maxIterations) {
271
- super(undefined, undefined, maxIterations);
312
+ constructor(func, maxIterations, stepSizeTolerance) {
313
+ super(stepSizeTolerance, undefined, maxIterations);
272
314
  this._func = func;
273
315
  this._currentStep = Point2dVector2d_1.Vector2d.createZero();
274
316
  this._currentUV = Point2dVector2d_1.Point2d.createZero();
@@ -276,7 +318,6 @@ class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {
276
318
  /** Set the current uv parameters, i.e., `X_n = (u_n, v_n)`. */
277
319
  setUV(u, v) {
278
320
  this._currentUV.set(u, v);
279
- return true;
280
321
  }
281
322
  /** Get the current u parameter of X_n, i.e., u_n. */
282
323
  getU() {
@@ -286,14 +327,9 @@ class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {
286
327
  getV() {
287
328
  return this._currentUV.y;
288
329
  }
289
- /** Get the relative tolerance for comparing iterations in [[testConvergence]]. */
290
- get stepSizeTolerance() {
291
- return this._stepSizeTolerance;
292
- }
293
330
  /** Update the current uv parameter by currentStep, i.e., compute `X_{n+1} := X_n - dX = (u_n - du, v_n - dv)`. */
294
331
  applyCurrentStep() {
295
- // console.log("(" + (this._currentUV.x - this._currentStep.x) + "," + (this._currentUV.y - this._currentStep.y) + ")");
296
- return this.setUV(this._currentUV.x - this._currentStep.x, this._currentUV.y - this._currentStep.y);
332
+ this.setUV(this._currentUV.x - this._currentStep.x, this._currentUV.y - this._currentStep.y);
297
333
  }
298
334
  /**
299
335
  * Evaluate the functions and derivatives at `X_n = (u_n, v_n)`, and solve the Jacobian matrix equation to
@@ -317,6 +353,20 @@ class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {
317
353
  currentStepSize() {
318
354
  return Geometry_1.Geometry.maxAbsXY(this._currentStep.x / (1.0 + Math.abs(this._currentUV.x)), this._currentStep.y / (1.0 + Math.abs(this._currentUV.y)));
319
355
  }
356
+ /** Candidate solution cache. */
357
+ _cachedUV;
358
+ /** The current late iterate has the least delta encountered. Remember it. */
359
+ cacheCandidate() {
360
+ if (this._cachedUV)
361
+ this._cachedUV.setFrom(this._currentUV);
362
+ else
363
+ this._cachedUV = this._currentUV.clone();
364
+ }
365
+ /** Set Newton result to the cached candidate. */
366
+ restoreCandidate() {
367
+ if (this._cachedUV)
368
+ this.setUV(this._cachedUV.x, this._cachedUV.y);
369
+ }
320
370
  }
321
371
  exports.Newton2dUnboundedWithDerivative = Newton2dUnboundedWithDerivative;
322
372
  /**
@@ -337,7 +387,7 @@ class SimpleNewton {
337
387
  static runNewton1D(x, func, derivative, absoluteTolerance = Geometry_1.Geometry.smallFloatingPoint) {
338
388
  let numConverged = 0;
339
389
  let tolerance;
340
- const relTol = 1.0e-11;
390
+ const relTol = Geometry_1.Geometry.smallNewtonStep;
341
391
  for (let iteration = 0; iteration < 20; iteration++) {
342
392
  const f = func(x);
343
393
  const df = derivative(x);
@@ -1 +1 @@
1
- {"version":3,"file":"Newton.js","sourceRoot":"","sources":["../../../src/numerics/Newton.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAO/F,0CAAuC;AACvC,uFAAoF;AACpF,mEAAkE;AAElE,+CAA4C;AAC5C,+CAA4C;AAE5C,+BAA+B;AAE/B;;;;GAIG;AACH,MAAsB,sBAAsB;IAa1C;;;;;;;;;;;OAWG;IACH,YACE,oBAA4B,OAAO,EACnC,8BAAsC,CAAC,EACvC,gBAAwB,EAAE;QAE1B,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;QAC5C,IAAI,CAAC,4BAA4B,GAAG,2BAA2B,CAAC;QAChE,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IACD,sEAAsE;IAC5D,YAAY,GAAW,CAAC,CAAC;IACnC,gDAAgD;IACtC,4BAA4B,CAAS;IAC/C,4FAA4F;IAClF,kBAAkB,CAAS;IACrC,8BAA8B;IACpB,cAAc,CAAS;IACjC,uDAAuD;IAChD,aAAa,GAAW,CAAC,CAAC;IACjC;;;;;OAKG;IACI,eAAe,CAAC,KAAa;QAClC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC9C,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,4BAA4B,CAAC;QAChE,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;;;OAMG;IACI,aAAa;QAClB,IAAI,CAAC,YA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AI,EAC/B,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,EAC/B,GAAG,EACH,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACzE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACrC,GAAG,EACH,CAAC,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,EACxC,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EACzE,GAAG,CACJ,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAjDD,4EAiDC","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\n/** @packageDocumentation\n * @module Numerics\n */\n\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { Geometry } from \"../Geometry\";\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../geometry3d/Ray3d\";\nimport { SmallSystem } from \"./SmallSystem\";\n\n// cspell:word currentdFdX XYRR\n\n/**\n * Base class for Newton iterations in various dimensions.\n * Dimension-specific classes carry all dimension-related data and answer generalized queries from this base class.\n * @internal\n */\nexport abstract class AbstractNewtonIterator {\n /** Compute a step. The current x and function values must be retained for use in later method calls. */\n public abstract computeStep(): boolean;\n /**\n * Return the current step size, scaled for use in tolerance tests.\n * * This is a single number, typically the max of various per-dimension `dx/(1+x)` for the x and dx of that dimension.\n */\n public abstract currentStepSize(): number;\n /**\n * Apply the current step (in all dimensions).\n * @param isFinalStep true if this is a final step.\n */\n public abstract applyCurrentStep(isFinalStep: boolean): boolean;\n /**\n * The constructor.\n * @param stepSizeTolerance tolerance to consider a single step converged.\n * This number should be \"moderately\" strict. Because 2 successive convergences are required,\n * it is expected that a first \"accept\" for (say) 10 to 14 digit step will be followed by another\n * iteration. A well behaved newton would then hypothetically double the number of digits to\n * 20 to 28. Since the IEEE double only carries 16 digits, this second-convergence step will\n * typically achieve full precision.\n * @param successiveConvergenceTarget number of successive convergences required for acceptance.\n * @param maxIterations max number of iterations. A typical newton step converges in 3 to 6 iterations.\n * Allow 15 to 20 to catch difficult cases.\n */\n protected constructor(\n stepSizeTolerance: number = 1.0e-11,\n successiveConvergenceTarget: number = 2,\n maxIterations: number = 15,\n ) {\n this._stepSizeTolerance = stepSizeTolerance;\n this._successiveConvergenceTarget = successiveConvergenceTarget;\n this._maxIterations = maxIterations;\n }\n /** Number of consecutive steps which passed convergence condition. */\n protected _numAccepted: number = 0;\n /** Target number of successive convergences. */\n protected _successiveConvergenceTarget: number;\n /** Convergence target (the implementation-specific currentStepSize is compared to this). */\n protected _stepSizeTolerance: number;\n /** Max iterations allowed. */\n protected _maxIterations: number;\n /** Number of iterations (incremented at each step). */\n public numIterations: number = 0;\n /**\n * Test if a step is converged.\n * * Convergence is accepted with enough (_successiveConvergenceTarget) small steps (according to _stepSizeTolerance)\n * occur in succession.\n * @param delta step size as reported by currentStepSize.\n */\n public testConvergence(delta: number): boolean {\n if (Math.abs(delta) < this._stepSizeTolerance) {\n this._numAccepted++;\n return this._numAccepted >= this._successiveConvergenceTarget;\n }\n this._numAccepted = 0;\n return false;\n }\n /**\n * Run iterations, calling various methods from base and derived classes:\n * * computeStep -- typically evaluate derivatives and solve linear system.\n * * currentStepSize -- return numeric measure of the step just computed by computeStep.\n * * testConvergence -- test if the step from currentStepSize (along with recent steps) is converged.\n * * applyCurrentStep -- apply the step to the independent variables.\n */\n public runIterations(): boolean {\n this._numAccepted = 0;\n this.numIterations = 0;\n while (this.numIterations++ < this._maxIterations && this.computeStep()) {\n if (this.testConvergence(this.currentStepSize()) && this.applyCurrentStep(true)) {\n // console.log(\"iter: \" + this.numIterations); // print number of Newton iterations for debug\n return true;\n }\n this.applyCurrentStep(false);\n }\n return false;\n }\n}\n/**\n * Object to evaluate a newton function. The object must retain most-recent function and derivative\n * values for immediate query.\n * @internal\n */\nexport abstract class NewtonEvaluatorRtoRD {\n /** Evaluate the function and its derivative at x. */\n public abstract evaluate(x: number): boolean;\n /** Most recent function value, i.e., f(x_n). */\n public currentF!: number;\n /** Most recent evaluated derivative, i.e., f'(x_n). */\n public currentdFdX!: number;\n}\n/**\n * Newton iterator for use when both function and derivative can be evaluated.\n * To solve `f(x) = 0`, the Newton iteration is `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n)`.\n * To solve `f(x) = target` which is equivalent to solving `g(x) = f(x) - target = 0`, the Newton iteration is\n * `x_{n+1} = x_n - dx = x_n - g(x_n)/g'(x_n) = x_n - (f(x_n)-target)/f'(x_n)`.\n * @internal\n */\nexport class Newton1dUnbounded extends AbstractNewtonIterator {\n private _func: NewtonEvaluatorRtoRD;\n /** Current step is dx. */\n private _currentStep!: number;\n /** Current X is x_n. */\n private _currentX!: number;\n /** The target */\n private _target!: number;\n /**\n * Constructor for 1D newton iteration with derivatives.\n * @param func function that returns both function value and derivative.\n */\n public constructor(func: NewtonEvaluatorRtoRD, maxIterations?: number) {\n super(undefined, undefined, maxIterations);\n this._func = func;\n this.setTarget(0);\n }\n /** Set the independent variable, i.e., x_n. */\n public setX(x: number): boolean {\n this._currentX = x;\n return true;\n }\n /** Get the independent variable, i.e., x_n. */\n public getX(): number {\n return this._currentX;\n }\n /** Set the target function value. */\n public setTarget(y: number): void {\n this._target = y;\n }\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\n public applyCurrentStep(): boolean {\n // console.log(this._currentX - this._currentStep); // print approximations for debug\n return this.setX(this._currentX - this._currentStep);\n }\n /** Compute the univariate newton step dx. */\n public computeStep(): boolean {\n if (this._func.evaluate(this._currentX)) {\n const dx = Geometry.conditionalDivideFraction(this._func.currentF - this._target, this._func.currentdFdX);\n if (dx !== undefined) {\n this._currentStep = dx;\n return true;\n }\n }\n return false;\n }\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\n public currentStepSize(): number {\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\n }\n}\n\n/**\n * Object to evaluate a newton function (without derivative). The object must retain most-recent function value.\n * @internal\n */\nexport abstract class NewtonEvaluatorRtoR {\n /** Evaluate function value into member currentF */\n public abstract evaluate(x: number): boolean;\n /** Most recent function evaluation, i.e., f(x_n). */\n public currentF!: number;\n}\n\n/**\n * Newton iteration for a univariate function, using approximate derivatives.\n * To approximate the derivatives we use a small step `h`, i.e., `f'(x_n) = (f(x_n + h) - f(x_n)) / h`.\n * Therefore, to solve `f(x) = 0`, the iteration is\n * `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n) = x_n - f(x_n) * h / (f(x_n + h) - f(x_n))`.\n * @internal\n */\nexport class Newton1dUnboundedApproximateDerivative extends AbstractNewtonIterator {\n private _func: NewtonEvaluatorRtoR;\n /** Current step is dx. */\n private _currentStep!: number;\n /** Current X is x_n. */\n private _currentX!: number;\n /**\n * Step size for approximate derivative for the iteration.\n * * Initialized to 1e-8, which is appropriate for iteration in fraction space.\n * * Should be larger for iteration with real distance as x.\n */\n public derivativeH: number; // h\n\n /**\n * Constructor for 1D newton iteration with approximate derivatives.\n * @param func function that only returns function value (and not derivative).\n */\n public constructor(func: NewtonEvaluatorRtoR, maxIterations?: number) {\n super(undefined, undefined, maxIterations);\n this._func = func;\n this.derivativeH = 1.0e-8;\n }\n /** Set the independent variable, i.e., x_n. */\n public setX(x: number): boolean {\n this._currentX = x;\n return true;\n }\n /** Get the independent variable, i.e., x_n. */\n public getX(): number {\n return this._currentX;\n }\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\n public applyCurrentStep(): boolean {\n // console.log(this._currentX - this._currentStep); // print approximations for debug\n return this.setX(this._currentX - this._currentStep);\n }\n /** Univariate newton step dx, computed with approximate derivative. */\n public computeStep(): boolean {\n if (this._func.evaluate(this._currentX)) {\n const fA = this._func.currentF; // f(x_n)\n if (this._func.evaluate(this._currentX + this.derivativeH)) {\n const fB = this._func.currentF; // f(x_n + h)\n const dx = Geometry.conditionalDivideFraction(fA, (fB - fA) / this.derivativeH);\n if (dx !== undefined) {\n this._currentStep = dx;\n return true;\n }\n }\n }\n return false;\n }\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\n public currentStepSize(): number {\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\n }\n}\n\n/**\n * Object to evaluate a 2-parameter newton function with derivatives.\n * @internal\n */\nexport abstract class NewtonEvaluatorRRtoRRD {\n /**\n * Iteration controller calls this to ask for evaluation of the function and its two partial derivatives.\n * * The implementation returns true, it must set the currentF object.\n */\n public abstract evaluate(x: number, y: number): boolean;\n /**\n * Most recent function evaluation as parts of the plane.\n * * See doc of [[Newton2dUnboundedWithDerivative]] class for info on 2d newton method.\n * * For `F(u,v) := (x(u,v), y(u,v))` the returned plane stores the following evaluations at current value `X := (u,v)`:\n * * `origin` = F(X) = (x(X), y(X))\n * * `vectorU` = F_u(X) = partial deriv of F wrt u at X = (x_u(X), y_u(X)) = 1st col of Jacobian matrix evaluated at X\n * * `vectorV` = F_v(X) = partial deriv of F wrt v at X = (x_v(X), y_v(X)) = 2nd col of Jacobian matrix evaluated at X\n */\n public currentF!: Plane3dByOriginAndVectors;\n /**\n * Constructor.\n * * This creates a currentF object to (repeatedly) receive function and derivatives.\n */\n public constructor() {\n this.currentF = Plane3dByOriginAndVectors.createXYPlane();\n }\n}\n\n/**\n * Implement evaluation steps for newton iteration in 2 dimensions, using caller supplied NewtonEvaluatorRRtoRRD object.\n * * Suppose we want to find the roots of `F(u,v) := (x(u,v), y(u,v))`. Writing `X := (u,v)` and `F(X)` as column vectors,\n * the 2D Newton's iteration to find a root of `F` is given by:\n * `X_{n+1} = X_n - dX = X_n - JInv(X_n)F(X_n)`, where `JInv` is the inverse of the Jacobian matrix `J`, and `J` is\n * defined by the partial derivatives of the component functions of F:\n *\n * `[dx/du dx/dv]`\n *\n * `[dy/du dy/dv]`\n * @internal\n */\nexport class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {\n private _func: NewtonEvaluatorRRtoRRD;\n /** Current step, or dX = (du, dv). */\n private _currentStep: Vector2d;\n /** Current uv parameters, or X_n = (u_n, v_n). */\n private _currentUV: Point2d;\n /**\n * Constructor for 2D newton iteration with derivatives.\n * @param func function that returns both function value and derivative.\n */\n public constructor(func: NewtonEvaluatorRRtoRRD, maxIterations?: number) {\n super(undefined, undefined, maxIterations);\n this._func = func;\n this._currentStep = Vector2d.createZero();\n this._currentUV = Point2d.createZero();\n }\n /** Set the current uv parameters, i.e., `X_n = (u_n, v_n)`. */\n public setUV(u: number, v: number): boolean {\n this._currentUV.set(u, v);\n return true;\n }\n /** Get the current u parameter of X_n, i.e., u_n. */\n public getU(): number {\n return this._currentUV.x;\n }\n /** Get the current v parameter of X_n, i.e., v_n. */\n public getV(): number {\n return this._currentUV.y;\n }\n /** Get the relative tolerance for comparing iterations in [[testConvergence]]. */\n public get stepSizeTolerance(): number {\n return this._stepSizeTolerance;\n }\n /** Update the current uv parameter by currentStep, i.e., compute `X_{n+1} := X_n - dX = (u_n - du, v_n - dv)`. */\n public applyCurrentStep(): boolean {\n // console.log(\"(\" + (this._currentUV.x - this._currentStep.x) + \",\" + (this._currentUV.y - this._currentStep.y) + \")\");\n return this.setUV(this._currentUV.x - this._currentStep.x, this._currentUV.y - this._currentStep.y);\n }\n /**\n * Evaluate the functions and derivatives at `X_n = (u_n, v_n)`, and solve the Jacobian matrix equation to\n * compute `dX = (du, dv)`.\n */\n public computeStep(): boolean {\n if (!this._func.evaluate(this._currentUV.x, this._currentUV.y))\n return false;\n const fA = this._func.currentF;\n const jCol0 = fA.vectorU;\n const jCol1 = fA.vectorV;\n const fX = fA.origin;\n // Given X_{n+1} = X_n - dX = X_n - JInv(X_n) F(X_n), we solve J(X_n) dX = F(X_n) for dX:\n if (SmallSystem.linearSystem2d(jCol0.x, jCol1.x, jCol0.y, jCol1.y, fX.x, fX.y, this._currentStep))\n return true;\n return false;\n }\n /**\n * Return the current relative step size, i.e., the larger absolute component of `dX / (1 + |X_n|)`\n */\n public currentStepSize(): number {\n return Geometry.maxAbsXY(\n this._currentStep.x / (1.0 + Math.abs(this._currentUV.x)),\n this._currentStep.y / (1.0 + Math.abs(this._currentUV.y)),\n );\n }\n}\n/**\n * SimpleNewton has static methods for newton methods with evaluated functions presented as immediate arguments\n * (not function object).\n * @internal\n */\nexport class SimpleNewton {\n /**\n * Run a one-dimensional newton iteration with separate functions for function and derivative.\n * * Completion is at 2 (TWO) successive passes at `absoluteTolerance + relTol * abs(x)`, where relTol is\n * chosen internally.\n * * `absoluteTolerance` is usually aggressively tight -- should come into play only for x near zero.\n * * The `relTol` is fluffy (for instance around 1e-11) but in properly converging cases the extra pass after\n * first success normally moves to full machine precision.\n * * This is an open-loop newton -- it just runs, and returns undefined if anything bad happens.\n */\n public static runNewton1D(\n x: number,\n func: (x: number) => number | undefined,\n derivative: (x: number) => number | undefined,\n absoluteTolerance: number = Geometry.smallFloatingPoint,\n ): number | undefined {\n let numConverged = 0;\n let tolerance: number;\n const relTol = 1.0e-11;\n for (let iteration = 0; iteration < 20; iteration++) {\n const f = func(x);\n const df = derivative(x);\n if (f !== undefined && df !== undefined) {\n const dx = Geometry.conditionalDivideCoordinate(f, df);\n if (dx === undefined)\n return undefined;\n x -= dx;\n // console.log(x); // print approximations for debug\n tolerance = absoluteTolerance + Math.abs(x) * relTol;\n if (Math.abs(dx) < tolerance) {\n numConverged++;\n if (dx === 0.0 || numConverged > 1) // bypass convergence count on true 0 dx\n return x;\n } else {\n numConverged = 0;\n }\n }\n }\n return undefined;\n }\n}\n\n/**\n * Class to evaluate XY intersection between 2 curve primitives using the Newton method.\n * @internal\n */\nexport class CurveCurveIntersectionXYRRToRRD extends NewtonEvaluatorRRtoRRD {\n private _curveP: CurvePrimitive;\n private _curveQ: CurvePrimitive;\n private _rayP: Ray3d;\n private _rayQ: Ray3d;\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\n super();\n this._curveP = curveP;\n this._curveQ = curveQ;\n this._rayP = Ray3d.createZero();\n this._rayQ = Ray3d.createZero();\n }\n public evaluate(fractionU: number, fractionV: number): boolean {\n /**\n * To find an intersection between xy-curves P(u) = (x_p(u), y_p(u)) and Q(v) = (x_q(v), y_q(v)) we should solve\n * F(u,v) := P(u) - Q(v) = (0,0)\n * Using the Newton method we can find the fractions u and v at the intersection via\n * [u_{n+1}] [u_n] [x_p'(u_n) -x_q'(v_n)] [x_p(u_n) - x_q(v_n)]\n * = - Inv( )\n * [v_{n+1}] [v_n] [y_p'(u_n) -y_q'(v_n)] [y_p(u_n) - y_q(v_n)]\n * Note that this is xy intersection so we can ignore z.\n */\n this._curveP.fractionToPointAndDerivative(fractionU, this._rayP);\n this._curveQ.fractionToPointAndDerivative(fractionV, this._rayQ);\n this.currentF.setOriginAndVectorsXYZ(\n this._rayP.origin.x - this._rayQ.origin.x, this._rayP.origin.y - this._rayQ.origin.y, 0.0,\n this._rayP.direction.x, this._rayP.direction.y, 0.0,\n -this._rayQ.direction.x, -this._rayQ.direction.y, 0.0,\n );\n return true;\n }\n}\n\n/**\n * Class to evaluate XY close approach between a curve primitive and a point using the Newton method.\n * @internal\n */\nexport class CurvePointCloseApproachXYRtoRD extends NewtonEvaluatorRtoRD {\n private _curveP: CurvePrimitive;\n private _pointQ: Point3d;\n private _planeP: Plane3dByOriginAndVectors;\n constructor(curveP: CurvePrimitive, pointQ: Point3d) {\n super();\n this._curveP = curveP;\n this._pointQ = pointQ;\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\n }\n public evaluate(fractionU: number): boolean {\n /**\n * To find a close approach between xy-curve P(u) and xy-point q we should solve\n * F(u) := P'(u).(P(u) - q) = 0\n * For a solution u, the segment S(u) := P(u) - q is perpendicular to the curve tangent P'(u), which means S(u) is\n * a close approach.\n * Using the Newton method we can find the fractions u at the close approach location via\n * u_{n+1} = u_n + F(u_n)/F'(u_n) = u_n + [ P'(u_n).S(u_n) ]/[ P''(u_n).S(u_n) + P'(u_n).P'(u_n) ]\n * Note that this is xy close approach so we can ignore z.\n */\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\n const segX = this._planeP.origin.x - this._pointQ.x;\n const segY = this._planeP.origin.y - this._pointQ.y;\n const pDerivX = this._planeP.vectorU.x;\n const pDerivY = this._planeP.vectorU.y;\n const p2DerivX = this._planeP.vectorV.x;\n const p2DerivY = this._planeP.vectorV.y;\n this.currentF = pDerivX * segX + pDerivY * segY;\n this.currentdFdX = p2DerivX * segX + pDerivX * pDerivX + p2DerivY * segY + pDerivY * pDerivY;\n return true;\n }\n}\n\n/**\n * Class to evaluate XY close approach between 2 curve primitives using the Newton method.\n * @internal\n */\nexport class CurveCurveCloseApproachXYRRtoRRD extends NewtonEvaluatorRRtoRRD {\n private _curveP: CurvePrimitive;\n private _curveQ: CurvePrimitive;\n private _planeP: Plane3dByOriginAndVectors;\n private _planeQ: Plane3dByOriginAndVectors;\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\n super();\n this._curveP = curveP;\n this._curveQ = curveQ;\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\n this._planeQ = Plane3dByOriginAndVectors.createXYPlane();\n }\n public evaluate(fractionU: number, fractionV: number): boolean {\n /**\n * To find a close approach between xy-curves P(u) and Q(v) we should solve\n * F(u,v) := (P'(u).(P(u) - Q(v)), Q'(v).(P(u) - Q(v))) = (0,0)\n * For a solution (u,v), the segment S(u,v) := P(u) - Q(v) is perpendicular to the curve tangents P'(u) and Q'(v),\n * which means S(u,v) is a close approach.\n * Using the Newton method we can find the fractions u and v at the close approach location via\n * [u_{n+1}] [u_n] [P''(u_n).S(u_n,v_n) + P'(u_n).P'(u_n) -P'(u_n).Q'(v_n)] [P'(u_n).S(u_n,v_n)]\n * = - Inv( )\n * [v_{n+1}] [v_n] [Q'(v_n).P'(u_n) Q''(v_n).S(u_n,v_n) - Q'(v_n).Q'(v_n)] [Q'(v_n).S(u_n,v_n)]\n * Note that this is xy close approach so we can ignore z.\n */\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\n this._curveQ.fractionToPointAnd2Derivatives(fractionV, this._planeQ);\n const segX = this._planeP.origin.x - this._planeQ.origin.x;\n const segY = this._planeP.origin.y - this._planeQ.origin.y;\n const pDerivX = this._planeP.vectorU.x;\n const pDerivY = this._planeP.vectorU.y;\n const qDerivX = this._planeQ.vectorU.x;\n const qDerivY = this._planeQ.vectorU.y;\n const p2DerivX = this._planeP.vectorV.x;\n const p2DerivY = this._planeP.vectorV.y;\n const q2DerivX = this._planeQ.vectorV.x;\n const q2DerivY = this._planeQ.vectorV.y;\n this.currentF.setOriginAndVectorsXYZ(\n pDerivX * segX + pDerivY * segY,\n qDerivX * segX + qDerivY * segY,\n 0.0,\n p2DerivX * segX + p2DerivY * segY + pDerivX * pDerivX + pDerivY * pDerivY,\n qDerivX * pDerivX + qDerivY * pDerivY,\n 0.0,\n -(pDerivX * qDerivX + pDerivY * qDerivY),\n q2DerivX * segX + q2DerivY * segY - qDerivX * qDerivX - qDerivY * qDerivY,\n 0.0,\n );\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"Newton.js","sourceRoot":"","sources":["../../../src/numerics/Newton.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAO/F,0CAAuC;AACvC,uFAAoF;AACpF,mEAAkE;AAElE,+CAA4C;AAC5C,+CAA4C;AAE5C,+BAA+B;AAE/B,0FAA0F;AAC1F,sDAAsD;AACtD,2GAA2G;AAC3G,kCAAkC;AAClC,sHAAsH;AACtH,iFAAiF;AAEjF;;;;GAIG;AACH,MAAsB,sBAAsB;IAa1C;;;;;;;;;;;OAWG;IACH,YACE,oBAA4B,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AAC;CACF;AAjDD,4EAiDC","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\n/** @packageDocumentation\n * @module Numerics\n */\n\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\nimport { Geometry } from \"../Geometry\";\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\nimport { Point2d, Vector2d } from \"../geometry3d/Point2dVector2d\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../geometry3d/Ray3d\";\nimport { SmallSystem } from \"./SmallSystem\";\n\n// cspell:word currentdFdX XYRR\n\n// A note on differences between using derivatives vs. approximate derivatives for Newton:\n// * Converged values are the same under both schemes.\n// * With derivatives, Newton convergence is quadratic rather than power 1.62 with approximate derivatives.\n// * With approximate derivatives:\n// - the extra iterative cost is incidental for low iteration counts, and may even be offset by simpler computation.\n// - the step choice is not based on serious analysis, so could be problematic.\n\n/**\n * Base class for Newton iterations in various dimensions.\n * Dimension-specific classes carry all dimension-related data and answer generalized queries from this base class.\n * @internal\n */\nexport abstract class AbstractNewtonIterator {\n /** Compute a step. The current x and function values must be retained for use in later method calls. */\n public abstract computeStep(): boolean;\n /**\n * Return the current step size, scaled for use in tolerance tests.\n * * This is a single number, typically the max of various per-dimension `dx/(1+x)` for the x and dx of that dimension.\n */\n public abstract currentStepSize(): number;\n /**\n * Apply the current step (in all dimensions).\n * @param isFinalStep true if this is a final step.\n */\n public abstract applyCurrentStep(isFinalStep: boolean): void;\n /**\n * The constructor.\n * @param stepSizeTolerance tolerance to consider a single step converged.\n * This number should be \"moderately\" strict. Because 2 successive convergences are required,\n * it is expected that a first \"accept\" for (say) 10 to 14 digit step will be followed by another\n * iteration. A well behaved newton would then hypothetically double the number of digits to\n * 20 to 28. Since the IEEE double only carries 16 digits, this second-convergence step will\n * typically achieve full precision. Default [[Geometry.smallNewtonStep]].\n * @param successiveConvergenceTarget number of successive convergences required for acceptance. Default 2.\n * @param maxIterations max number of iterations. A typical newton step converges in 3 to 6 iterations.\n * Allow 15 to 20 to catch difficult cases. Default 15.\n */\n protected constructor(\n stepSizeTolerance: number = Geometry.smallNewtonStep,\n successiveConvergenceTarget: number = 2,\n maxIterations: number = 15,\n ) {\n this._stepSizeTolerance = stepSizeTolerance;\n this._successiveConvergenceTarget = successiveConvergenceTarget;\n this._maxIterations = maxIterations;\n }\n /** Number of consecutive steps which passed convergence condition. */\n protected _numAccepted: number = 0;\n /** Target number of successive convergences. */\n protected _successiveConvergenceTarget: number;\n /** Convergence target (the implementation-specific currentStepSize is compared to this). */\n protected _stepSizeTolerance: number;\n /** Max iterations allowed. */\n protected _maxIterations: number;\n /** Number of iterations (incremented at each step). */\n public numIterations: number = 0;\n /** Get the relative tolerance for comparing iterations in [[testConvergence]]. */\n public get stepSizeTolerance(): number {\n return this._stepSizeTolerance;\n }\n /** Smallest iterate size difference in later iterations. */\n private _leastDelta: number = Number.MAX_VALUE;\n /** The current late iterate has the least delta encountered. Remember it. Implement along with [[restoreCandidate]].*/\n protected cacheCandidate?(): void;\n /** Set Newton result to the cached candidate. Implement along with [[cacheCandidate]]. */\n protected restoreCandidate?(): void;\n\n /**\n * Test if a step is converged.\n * * Convergence is accepted with enough (_successiveConvergenceTarget) small steps (according to _stepSizeTolerance)\n * occur in succession.\n * @param delta step size as reported by currentStepSize.\n */\n public testConvergence(delta: number): boolean {\n if (this.cacheCandidate && delta < this._leastDelta && this.numIterations > 0.5 * this._maxIterations) {\n this._leastDelta = delta;\n this.cacheCandidate();\n }\n if (Math.abs(delta) < this._stepSizeTolerance) {\n this._numAccepted++;\n return this._numAccepted >= this._successiveConvergenceTarget;\n }\n this._numAccepted = 0;\n return false;\n }\n /**\n * Run iterations, calling various methods from base and derived classes:\n * * computeStep -- typically evaluate derivatives and solve linear system.\n * * currentStepSize -- return numeric measure of the step just computed by computeStep.\n * * testConvergence -- test if the step from currentStepSize (along with recent steps) is converged.\n * * applyCurrentStep -- apply the step to the independent variables.\n */\n public runIterations(): boolean {\n this._numAccepted = 0;\n this.numIterations = 0;\n this._leastDelta = Number.MAX_VALUE;\n while (this.numIterations++ < this._maxIterations && this.computeStep()) {\n if (this.testConvergence(this.currentStepSize())) {\n this.applyCurrentStep(true);\n return true;\n }\n this.applyCurrentStep(false);\n }\n if (this.restoreCandidate && this.numIterations >= this._maxIterations && Math.abs(this.currentStepSize()) > this._leastDelta)\n this.restoreCandidate(); // we may have ended up in a late cycle; return our best guess\n return false;\n }\n}\n/**\n * Object to evaluate a newton function. The object must retain most-recent function and derivative\n * values for immediate query.\n * @internal\n */\nexport abstract class NewtonEvaluatorRtoRD {\n /** Evaluate the function and its derivative at x. */\n public abstract evaluate(x: number): boolean;\n /** Most recent function value, i.e., f(x_n). */\n public currentF!: number;\n /** Most recent evaluated derivative, i.e., f'(x_n). */\n public currentdFdX!: number;\n}\n/**\n * Newton iterator for use when both function and derivative can be evaluated.\n * To solve `f(x) = 0`, the Newton iteration is `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n)`.\n * To solve `f(x) = target` which is equivalent to solving `g(x) = f(x) - target = 0`, the Newton iteration is\n * `x_{n+1} = x_n - dx = x_n - g(x_n)/g'(x_n) = x_n - (f(x_n)-target)/f'(x_n)`.\n * @internal\n */\nexport class Newton1dUnbounded extends AbstractNewtonIterator {\n private _func: NewtonEvaluatorRtoRD;\n /** Current step is dx. */\n private _currentStep!: number;\n /** Current X is x_n. */\n private _currentX!: number;\n /** The target */\n private _target!: number;\n /**\n * Constructor for 1D newton iteration with derivatives.\n * @param func function that returns both function value and derivative.\n */\n public constructor(func: NewtonEvaluatorRtoRD, maxIterations?: number) {\n super(undefined, undefined, maxIterations);\n this._func = func;\n this.setTarget(0);\n }\n /** Set the independent variable, i.e., x_n. */\n public setX(x: number) {\n this._currentX = x;\n }\n /** Get the independent variable, i.e., x_n. */\n public getX(): number {\n return this._currentX;\n }\n /** Set the target function value. */\n public setTarget(y: number): void {\n this._target = y;\n }\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\n public applyCurrentStep(): void {\n this.setX(this._currentX - this._currentStep);\n }\n /** Compute the univariate newton step dx. */\n public computeStep(): boolean {\n if (this._func.evaluate(this._currentX)) {\n const dx = Geometry.conditionalDivideFraction(this._func.currentF - this._target, this._func.currentdFdX);\n if (dx !== undefined) {\n this._currentStep = dx;\n return true;\n }\n }\n return false;\n }\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\n public currentStepSize(): number {\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\n }\n}\n\n/**\n * Object to evaluate a newton function (without derivative). The object must retain most-recent function value.\n * @internal\n */\nexport abstract class NewtonEvaluatorRtoR {\n /** Evaluate function value into member currentF */\n public abstract evaluate(x: number): boolean;\n /** Most recent function evaluation, i.e., f(x_n). */\n public currentF!: number;\n}\n\n/**\n * Intermediate class for managing the parentCurve announcements from an IStrokeHandler.\n * @internal\n */\nexport abstract class NewtonRtoRStrokeHandler extends NewtonEvaluatorRtoR {\n protected _parentCurvePrimitive: CurvePrimitive | undefined;\n constructor() {\n super();\n this._parentCurvePrimitive = undefined;\n }\n /**\n * Retain the parentCurvePrimitive.\n * * Calling this method tells the handler that the parent curve is to be used for detail searches.\n * * Example: Transition spiral search is based on linestring first, then the exact spiral.\n * * Example: CurveChainWithDistanceIndex does NOT do this announcement; the constituents act independently.\n */\n public startParentCurvePrimitive(curve: CurvePrimitive | undefined): void {\n this._parentCurvePrimitive = curve;\n }\n /** Forget the parentCurvePrimitive */\n public endParentCurvePrimitive(_curve: CurvePrimitive | undefined): void {\n this._parentCurvePrimitive = undefined;\n }\n}\n\n/**\n * Newton iteration for a univariate function, using approximate derivatives.\n * To approximate the derivatives we use a small step `h`, i.e., `f'(x_n) = (f(x_n + h) - f(x_n)) / h`.\n * Therefore, to solve `f(x) = 0`, the iteration is\n * `x_{n+1} = x_n - dx = x_n - f(x_n)/f'(x_n) = x_n - f(x_n) * h / (f(x_n + h) - f(x_n))`.\n * @internal\n */\nexport class Newton1dUnboundedApproximateDerivative extends AbstractNewtonIterator {\n private _func: NewtonEvaluatorRtoR;\n /** Current step is dx. */\n private _currentStep!: number;\n /** Current X is x_n. */\n private _currentX!: number;\n /**\n * Step size for approximate derivative for the iteration.\n * * Initialized to 1e-8, which is appropriate for iteration in fraction space.\n * * Should be larger for iteration with real distance as x.\n */\n public derivativeH: number; // h\n\n /**\n * Constructor for 1D newton iteration with approximate derivatives.\n * @param func function that only returns function value (and not derivative).\n */\n public constructor(func: NewtonEvaluatorRtoR, maxIterations?: number) {\n super(undefined, undefined, maxIterations);\n this._func = func;\n this.derivativeH = 1.0e-8;\n }\n /** Set the independent variable, i.e., x_n. */\n public setX(x: number): void {\n this._currentX = x;\n }\n /** Get the independent variable, i.e., x_n. */\n public getX(): number {\n return this._currentX;\n }\n /** Move the current X by the just-computed step, i.e., `x_n - dx`. */\n public applyCurrentStep(): void {\n this.setX(this._currentX - this._currentStep);\n }\n /** Univariate newton step dx, computed with approximate derivative. */\n public computeStep(): boolean {\n if (this._func.evaluate(this._currentX)) {\n const fA = this._func.currentF; // f(x_n)\n if (this._func.evaluate(this._currentX + this.derivativeH)) {\n const fB = this._func.currentF; // f(x_n + h)\n const dx = Geometry.conditionalDivideFraction(fA, (fB - fA) / this.derivativeH);\n if (dx !== undefined) {\n this._currentStep = dx;\n return true;\n }\n }\n }\n return false;\n }\n /** Return the current step size as a relative number, i.e., `|dx / (1 + |x_n|)|`. */\n public currentStepSize(): number {\n return Math.abs(this._currentStep / (1.0 + Math.abs(this._currentX)));\n }\n}\n\n/**\n * Object to evaluate a 2-parameter newton function with derivatives.\n * @internal\n */\nexport abstract class NewtonEvaluatorRRtoRRD {\n /**\n * Iteration controller calls this to ask for evaluation of the function and its two partial derivatives.\n * * The implementation returns true, it must set the currentF object.\n */\n public abstract evaluate(x: number, y: number): boolean;\n /**\n * Most recent function evaluation as parts of the plane.\n * * See doc of [[Newton2dUnboundedWithDerivative]] class for info on 2d newton method.\n * * For `F(u,v) := (x(u,v), y(u,v))` the returned plane stores the following evaluations at current value `X := (u,v)`:\n * * `origin` = F(X) = (x(X), y(X))\n * * `vectorU` = F_u(X) = partial deriv of F wrt u at X = (x_u(X), y_u(X)) = 1st col of Jacobian matrix evaluated at X\n * * `vectorV` = F_v(X) = partial deriv of F wrt v at X = (x_v(X), y_v(X)) = 2nd col of Jacobian matrix evaluated at X\n */\n public currentF!: Plane3dByOriginAndVectors;\n /**\n * Constructor.\n * * This creates a currentF object to (repeatedly) receive function and derivatives.\n */\n public constructor() {\n this.currentF = Plane3dByOriginAndVectors.createXYPlane();\n }\n}\n\n/**\n * Implement evaluation steps for newton iteration in 2 dimensions, using caller supplied NewtonEvaluatorRRtoRRD object.\n * * Suppose we want to find the roots of `F(u,v) := (x(u,v), y(u,v))`. Writing `X := (u,v)` and `F(X)` as column vectors,\n * the 2D Newton's iteration to find a root of `F` is given by:\n * `X_{n+1} = X_n - dX = X_n - JInv(X_n)F(X_n)`, where `JInv` is the inverse of the Jacobian matrix `J`, and `J` is\n * defined by the partial derivatives of the component functions of F:\n *\n * `[dx/du dx/dv]`\n *\n * `[dy/du dy/dv]`\n * @internal\n */\nexport class Newton2dUnboundedWithDerivative extends AbstractNewtonIterator {\n private _func: NewtonEvaluatorRRtoRRD;\n /** Current step, or dX = (du, dv). */\n private _currentStep: Vector2d;\n /** Current uv parameters, or X_n = (u_n, v_n). */\n private _currentUV: Point2d;\n /**\n * Constructor for 2D newton iteration with derivatives.\n * @param func function that returns both function value and derivative.\n * @param maxIterations max number of iterations. Default 15.\n * @param stepSizeTolerance tolerance to consider a single step converged. Default [[Geometry.smallNewtonStep]].\n */\n public constructor(func: NewtonEvaluatorRRtoRRD, maxIterations?: number, stepSizeTolerance?: number) {\n super(stepSizeTolerance, undefined, maxIterations);\n this._func = func;\n this._currentStep = Vector2d.createZero();\n this._currentUV = Point2d.createZero();\n }\n /** Set the current uv parameters, i.e., `X_n = (u_n, v_n)`. */\n public setUV(u: number, v: number): void {\n this._currentUV.set(u, v);\n }\n /** Get the current u parameter of X_n, i.e., u_n. */\n public getU(): number {\n return this._currentUV.x;\n }\n /** Get the current v parameter of X_n, i.e., v_n. */\n public getV(): number {\n return this._currentUV.y;\n }\n /** Update the current uv parameter by currentStep, i.e., compute `X_{n+1} := X_n - dX = (u_n - du, v_n - dv)`. */\n public applyCurrentStep(): void {\n this.setUV(this._currentUV.x - this._currentStep.x, this._currentUV.y - this._currentStep.y);\n }\n /**\n * Evaluate the functions and derivatives at `X_n = (u_n, v_n)`, and solve the Jacobian matrix equation to\n * compute `dX = (du, dv)`.\n */\n public computeStep(): boolean {\n if (!this._func.evaluate(this._currentUV.x, this._currentUV.y))\n return false;\n const fA = this._func.currentF;\n const jCol0 = fA.vectorU;\n const jCol1 = fA.vectorV;\n const fX = fA.origin;\n // Given X_{n+1} = X_n - dX = X_n - JInv(X_n) F(X_n), we solve J(X_n) dX = F(X_n) for dX:\n if (SmallSystem.linearSystem2d(jCol0.x, jCol1.x, jCol0.y, jCol1.y, fX.x, fX.y, this._currentStep))\n return true;\n return false;\n }\n /**\n * Return the current relative step size, i.e., the larger absolute component of `dX / (1 + |X_n|)`\n */\n public currentStepSize(): number {\n return Geometry.maxAbsXY(\n this._currentStep.x / (1.0 + Math.abs(this._currentUV.x)),\n this._currentStep.y / (1.0 + Math.abs(this._currentUV.y)),\n );\n }\n /** Candidate solution cache. */\n private _cachedUV: Point2d | undefined;\n /** The current late iterate has the least delta encountered. Remember it. */\n protected override cacheCandidate(): void {\n if (this._cachedUV)\n this._cachedUV.setFrom(this._currentUV);\n else\n this._cachedUV = this._currentUV.clone();\n }\n /** Set Newton result to the cached candidate. */\n protected override restoreCandidate(): void {\n if (this._cachedUV)\n this.setUV(this._cachedUV.x, this._cachedUV.y);\n }\n}\n/**\n * SimpleNewton has static methods for newton methods with evaluated functions presented as immediate arguments\n * (not function object).\n * @internal\n */\nexport class SimpleNewton {\n /**\n * Run a one-dimensional newton iteration with separate functions for function and derivative.\n * * Completion is at 2 (TWO) successive passes at `absoluteTolerance + relTol * abs(x)`, where relTol is\n * chosen internally.\n * * `absoluteTolerance` is usually aggressively tight -- should come into play only for x near zero.\n * * The `relTol` is fluffy (for instance around 1e-11) but in properly converging cases the extra pass after\n * first success normally moves to full machine precision.\n * * This is an open-loop newton -- it just runs, and returns undefined if anything bad happens.\n */\n public static runNewton1D(\n x: number,\n func: (x: number) => number | undefined,\n derivative: (x: number) => number | undefined,\n absoluteTolerance: number = Geometry.smallFloatingPoint,\n ): number | undefined {\n let numConverged = 0;\n let tolerance: number;\n const relTol = Geometry.smallNewtonStep;\n for (let iteration = 0; iteration < 20; iteration++) {\n const f = func(x);\n const df = derivative(x);\n if (f !== undefined && df !== undefined) {\n const dx = Geometry.conditionalDivideCoordinate(f, df);\n if (dx === undefined)\n return undefined;\n x -= dx;\n // console.log(x); // print approximations for debug\n tolerance = absoluteTolerance + Math.abs(x) * relTol;\n if (Math.abs(dx) < tolerance) {\n numConverged++;\n if (dx === 0.0 || numConverged > 1) // bypass convergence count on true 0 dx\n return x;\n } else {\n numConverged = 0;\n }\n }\n }\n return undefined;\n }\n}\n\n/**\n * Class to evaluate XY intersection between 2 curve primitives using the Newton method.\n * @internal\n */\nexport class CurveCurveIntersectionXYRRToRRD extends NewtonEvaluatorRRtoRRD {\n private _curveP: CurvePrimitive;\n private _curveQ: CurvePrimitive;\n private _rayP: Ray3d;\n private _rayQ: Ray3d;\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\n super();\n this._curveP = curveP;\n this._curveQ = curveQ;\n this._rayP = Ray3d.createZero();\n this._rayQ = Ray3d.createZero();\n }\n public evaluate(fractionU: number, fractionV: number): boolean {\n /**\n * To find an intersection between xy-curves P(u) = (x_p(u), y_p(u)) and Q(v) = (x_q(v), y_q(v)) we should solve\n * F(u,v) := P(u) - Q(v) = (0,0)\n * Using the Newton method we can find the fractions u and v at the intersection via\n * [u_{n+1}] [u_n] [x_p'(u_n) -x_q'(v_n)] [x_p(u_n) - x_q(v_n)]\n * = - Inv( )\n * [v_{n+1}] [v_n] [y_p'(u_n) -y_q'(v_n)] [y_p(u_n) - y_q(v_n)]\n * Note that this is xy intersection so we can ignore z.\n */\n this._curveP.fractionToPointAndDerivative(fractionU, this._rayP);\n this._curveQ.fractionToPointAndDerivative(fractionV, this._rayQ);\n this.currentF.setOriginAndVectorsXYZ(\n this._rayP.origin.x - this._rayQ.origin.x, this._rayP.origin.y - this._rayQ.origin.y, 0.0,\n this._rayP.direction.x, this._rayP.direction.y, 0.0,\n -this._rayQ.direction.x, -this._rayQ.direction.y, 0.0,\n );\n return true;\n }\n}\n\n/**\n * Class to evaluate XY close approach between a curve primitive and a point using the Newton method.\n * @internal\n */\nexport class CurvePointCloseApproachXYRtoRD extends NewtonEvaluatorRtoRD {\n private _curveP: CurvePrimitive;\n private _pointQ: Point3d;\n private _planeP: Plane3dByOriginAndVectors;\n constructor(curveP: CurvePrimitive, pointQ: Point3d) {\n super();\n this._curveP = curveP;\n this._pointQ = pointQ;\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\n }\n public evaluate(fractionU: number): boolean {\n /**\n * To find a close approach between xy-curve P(u) and xy-point q we should solve\n * F(u) := P'(u).(P(u) - q) = 0\n * For a solution u, the segment S(u) := P(u) - q is perpendicular to the curve tangent P'(u), which means S(u) is\n * a close approach.\n * Using the Newton method we can find the fractions u at the close approach location via\n * u_{n+1} = u_n + F(u_n)/F'(u_n) = u_n + [ P'(u_n).S(u_n) ]/[ P''(u_n).S(u_n) + P'(u_n).P'(u_n) ]\n * Note that this is xy close approach so we can ignore z.\n */\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\n const segX = this._planeP.origin.x - this._pointQ.x;\n const segY = this._planeP.origin.y - this._pointQ.y;\n const pDerivX = this._planeP.vectorU.x;\n const pDerivY = this._planeP.vectorU.y;\n const p2DerivX = this._planeP.vectorV.x;\n const p2DerivY = this._planeP.vectorV.y;\n this.currentF = pDerivX * segX + pDerivY * segY;\n this.currentdFdX = p2DerivX * segX + pDerivX * pDerivX + p2DerivY * segY + pDerivY * pDerivY;\n return true;\n }\n}\n\n/**\n * Class to evaluate XY close approach between 2 curve primitives using the Newton method.\n * @internal\n */\nexport class CurveCurveCloseApproachXYRRtoRRD extends NewtonEvaluatorRRtoRRD {\n private _curveP: CurvePrimitive;\n private _curveQ: CurvePrimitive;\n private _planeP: Plane3dByOriginAndVectors;\n private _planeQ: Plane3dByOriginAndVectors;\n constructor(curveP: CurvePrimitive, curveQ: CurvePrimitive) {\n super();\n this._curveP = curveP;\n this._curveQ = curveQ;\n this._planeP = Plane3dByOriginAndVectors.createXYPlane();\n this._planeQ = Plane3dByOriginAndVectors.createXYPlane();\n }\n public evaluate(fractionU: number, fractionV: number): boolean {\n /**\n * To find a close approach between xy-curves P(u) and Q(v) we should solve\n * F(u,v) := (P'(u).(P(u) - Q(v)), Q'(v).(P(u) - Q(v))) = (0,0)\n * For a solution (u,v), the segment S(u,v) := P(u) - Q(v) is perpendicular to the curve tangents P'(u) and Q'(v),\n * which means S(u,v) is a close approach.\n * Using the Newton method we can find the fractions u and v at the close approach location via\n * [u_{n+1}] [u_n] [P''(u_n).S(u_n,v_n) + P'(u_n).P'(u_n) -P'(u_n).Q'(v_n)] [P'(u_n).S(u_n,v_n)]\n * = - Inv( )\n * [v_{n+1}] [v_n] [Q'(v_n).P'(u_n) Q''(v_n).S(u_n,v_n) - Q'(v_n).Q'(v_n)] [Q'(v_n).S(u_n,v_n)]\n * Note that this is xy close approach so we can ignore z.\n */\n this._curveP.fractionToPointAnd2Derivatives(fractionU, this._planeP);\n this._curveQ.fractionToPointAnd2Derivatives(fractionV, this._planeQ);\n const segX = this._planeP.origin.x - this._planeQ.origin.x;\n const segY = this._planeP.origin.y - this._planeQ.origin.y;\n const pDerivX = this._planeP.vectorU.x;\n const pDerivY = this._planeP.vectorU.y;\n const qDerivX = this._planeQ.vectorU.x;\n const qDerivY = this._planeQ.vectorU.y;\n const p2DerivX = this._planeP.vectorV.x;\n const p2DerivY = this._planeP.vectorV.y;\n const q2DerivX = this._planeQ.vectorV.x;\n const q2DerivY = this._planeQ.vectorV.y;\n this.currentF.setOriginAndVectorsXYZ(\n pDerivX * segX + pDerivY * segY,\n qDerivX * segX + qDerivY * segY,\n 0.0,\n p2DerivX * segX + p2DerivY * segY + pDerivX * pDerivX + pDerivY * pDerivY,\n qDerivX * pDerivX + qDerivY * pDerivY,\n 0.0,\n -(pDerivX * qDerivX + pDerivY * qDerivY),\n q2DerivX * segX + q2DerivY * segY - qDerivX * qDerivX - qDerivY * qDerivY,\n 0.0,\n );\n return true;\n }\n}\n"]}
@@ -264,20 +264,20 @@ export declare class PolyfaceQuery {
264
264
  */
265
265
  static dihedralAngleSummary(source: Polyface | PolyfaceVisitor, ignoreBoundaries?: boolean): number;
266
266
  /**
267
- * Test for convex volume by dihedral angle tests on all edges.
268
- * * This tests if all dihedral angles of the mesh are positive.
269
- * * In a closed solid, this is a strong test for overall mesh convexity with outward facing normals.
270
- * * See [[dihedralAngleSummary]] for the definition of "dihedral angle".
271
- * * With `ignoreBoundaries` true, this may be a useful test when all the facets are in a single edge-connected
272
- * component, such as a pyramid with no underside.
273
- * * It is not a correct test if there are multiple, disjoint components.
274
- * * Take the above-mentioned pyramid with no underside.
275
- * * Within the same mesh, have a second pyramid placed to the side, still facing upward.
276
- * * The angles will pass the dihedral convexity test, but the composite thing surely is not convex.
277
- * @param source mesh.
278
- * @param ignoreBoundaries if `true` ignore simple boundary edges, i.e., allow unclosed meshes. Default is `false`.
279
- * @returns true if all dihedral angles of the mesh are positive.
280
- */
267
+ * Test for convex volume by dihedral angle tests on all edges.
268
+ * * This tests if all dihedral angles of the mesh are positive.
269
+ * * In a closed solid, this is a strong test for overall mesh convexity with outward facing normals.
270
+ * * See [[dihedralAngleSummary]] for the definition of "dihedral angle".
271
+ * * With `ignoreBoundaries` true, this may be a useful test when all the facets are in a single edge-connected
272
+ * component, such as a pyramid with no underside.
273
+ * * It is not a correct test if there are multiple, disjoint components.
274
+ * * Take the above-mentioned pyramid with no underside.
275
+ * * Within the same mesh, have a second pyramid placed to the side, still facing upward.
276
+ * * The angles will pass the dihedral convexity test, but the composite thing surely is not convex.
277
+ * @param source mesh.
278
+ * @param ignoreBoundaries if `true` ignore simple boundary edges, i.e., allow unclosed meshes. Default is `false`.
279
+ * @returns true if all dihedral angles of the mesh are positive.
280
+ */
281
281
  static isConvexByDihedralAngleCount(source: Polyface | PolyfaceVisitor, ignoreBoundaries?: boolean): boolean;
282
282
  /** Helper function to detect a subset visitor. */
283
283
  static isSubsetVisitor(visitor: Polyface | PolyfaceVisitor): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"PolyfaceQuery.d.ts","sourceRoot":"","sources":["../../../src/polyface/PolyfaceQuery.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAIlE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,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