@itwin/core-geometry 4.10.0-dev.2 → 4.10.0-dev.22

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 (138) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/lib/cjs/Geometry.d.ts +2 -2
  3. package/lib/cjs/Geometry.js +2 -2
  4. package/lib/cjs/Geometry.js.map +1 -1
  5. package/lib/cjs/clipping/ClipPrimitive.d.ts +7 -7
  6. package/lib/cjs/clipping/ClipPrimitive.d.ts.map +1 -1
  7. package/lib/cjs/clipping/ClipPrimitive.js +1 -1
  8. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  9. package/lib/cjs/curve/Arc3d.d.ts +21 -10
  10. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  11. package/lib/cjs/curve/Arc3d.js +64 -37
  12. package/lib/cjs/curve/Arc3d.js.map +1 -1
  13. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +27 -8
  14. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  15. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +44 -25
  16. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  17. package/lib/cjs/curve/CurveFactory.d.ts +10 -12
  18. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  19. package/lib/cjs/curve/CurveFactory.js +16 -43
  20. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  21. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +2 -2
  22. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  23. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  24. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  25. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +33 -59
  26. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  27. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
  28. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  29. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +128 -68
  30. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  31. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  32. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
  33. package/lib/cjs/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  34. package/lib/cjs/geometry3d/Angle.d.ts +5 -5
  35. package/lib/cjs/geometry3d/Angle.js +5 -5
  36. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  37. package/lib/cjs/geometry3d/AngleSweep.d.ts +101 -13
  38. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  39. package/lib/cjs/geometry3d/AngleSweep.js +156 -57
  40. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  41. package/lib/cjs/geometry3d/Matrix3d.d.ts +9 -15
  42. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  43. package/lib/cjs/geometry3d/Matrix3d.js +21 -15
  44. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  45. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +6 -5
  46. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  47. package/lib/cjs/geometry3d/Point3dVector3d.js +6 -5
  48. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  49. package/lib/cjs/geometry3d/PolygonOps.js +2 -2
  50. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  51. package/lib/cjs/geometry3d/Transform.d.ts +4 -2
  52. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  53. package/lib/cjs/geometry3d/Transform.js +4 -2
  54. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  55. package/lib/cjs/geometry4d/Map4d.d.ts +5 -5
  56. package/lib/cjs/geometry4d/Map4d.js +5 -5
  57. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  58. package/lib/cjs/geometry4d/Matrix4d.d.ts +4 -7
  59. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  60. package/lib/cjs/geometry4d/Matrix4d.js +4 -7
  61. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  62. package/lib/cjs/numerics/Polynomials.d.ts +37 -36
  63. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  64. package/lib/cjs/numerics/Polynomials.js +90 -105
  65. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  66. package/lib/cjs/polyface/PolyfaceClip.d.ts +3 -3
  67. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  68. package/lib/cjs/polyface/PolyfaceClip.js +1 -1
  69. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  70. package/lib/esm/Geometry.d.ts +2 -2
  71. package/lib/esm/Geometry.js +2 -2
  72. package/lib/esm/Geometry.js.map +1 -1
  73. package/lib/esm/clipping/ClipPrimitive.d.ts +7 -7
  74. package/lib/esm/clipping/ClipPrimitive.d.ts.map +1 -1
  75. package/lib/esm/clipping/ClipPrimitive.js +1 -1
  76. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  77. package/lib/esm/curve/Arc3d.d.ts +21 -10
  78. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  79. package/lib/esm/curve/Arc3d.js +64 -37
  80. package/lib/esm/curve/Arc3d.js.map +1 -1
  81. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +27 -8
  82. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  83. package/lib/esm/curve/CurveChainWithDistanceIndex.js +44 -25
  84. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  85. package/lib/esm/curve/CurveFactory.d.ts +10 -12
  86. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  87. package/lib/esm/curve/CurveFactory.js +16 -43
  88. package/lib/esm/curve/CurveFactory.js.map +1 -1
  89. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +2 -2
  90. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  91. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -0
  92. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  93. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +33 -59
  94. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  95. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +22 -7
  96. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  97. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +128 -68
  98. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  99. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.d.ts.map +1 -1
  100. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js +14 -11
  101. package/lib/esm/curve/internalContexts/EllipticalArcApproximationContext.js.map +1 -1
  102. package/lib/esm/geometry3d/Angle.d.ts +5 -5
  103. package/lib/esm/geometry3d/Angle.js +5 -5
  104. package/lib/esm/geometry3d/Angle.js.map +1 -1
  105. package/lib/esm/geometry3d/AngleSweep.d.ts +101 -13
  106. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  107. package/lib/esm/geometry3d/AngleSweep.js +156 -57
  108. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  109. package/lib/esm/geometry3d/Matrix3d.d.ts +9 -15
  110. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  111. package/lib/esm/geometry3d/Matrix3d.js +21 -15
  112. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  113. package/lib/esm/geometry3d/Point3dVector3d.d.ts +6 -5
  114. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  115. package/lib/esm/geometry3d/Point3dVector3d.js +6 -5
  116. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  117. package/lib/esm/geometry3d/PolygonOps.js +2 -2
  118. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  119. package/lib/esm/geometry3d/Transform.d.ts +4 -2
  120. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  121. package/lib/esm/geometry3d/Transform.js +4 -2
  122. package/lib/esm/geometry3d/Transform.js.map +1 -1
  123. package/lib/esm/geometry4d/Map4d.d.ts +5 -5
  124. package/lib/esm/geometry4d/Map4d.js +5 -5
  125. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  126. package/lib/esm/geometry4d/Matrix4d.d.ts +4 -7
  127. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  128. package/lib/esm/geometry4d/Matrix4d.js +4 -7
  129. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  130. package/lib/esm/numerics/Polynomials.d.ts +37 -36
  131. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  132. package/lib/esm/numerics/Polynomials.js +90 -105
  133. package/lib/esm/numerics/Polynomials.js.map +1 -1
  134. package/lib/esm/polyface/PolyfaceClip.d.ts +3 -3
  135. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  136. package/lib/esm/polyface/PolyfaceClip.js +1 -1
  137. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  138. package/package.json +7 -19
@@ -828,7 +828,7 @@ class AnalyticRoots {
828
828
  // EDL April 5, 2020 replace classic GraphicsGems solver by RWDNickalls.
829
829
  // Don't know if improveRoots is needed.
830
830
  // Breaks in AnalyticRoots.test.ts checkQuartic suggest it indeed converts many e-16 errors to zero.
831
- // e-13 cases are unaffected
831
+ // e-13 cases are unaffected
832
832
  this.improveRoots(c, 3, results, false);
833
833
  }
834
834
  else {
@@ -837,49 +837,46 @@ class AnalyticRoots {
837
837
  // this.appendCubicRootsUnsorted(c, results);
838
838
  results.sort();
839
839
  }
840
- /** Compute roots of quartic 'c[0] + c[1] * x + c[2] * x^2 + c[3] * x^3 + c[4] * x^4 */
840
+ /** Compute roots of quartic `c[0] + c[1] * x + c[2] * x^2 + c[3] * x^3 + c[4] * x^4` */
841
841
  static appendQuarticRoots(c, results) {
842
- const coffs = new Float64Array(4); // at various times .. coefficients of quadratic an cubic intermediates.
842
+ // for details, see core\geometry\internaldocs\quarticRoots.md
843
+ const coffs = new Float64Array(4);
843
844
  let u;
844
845
  let v;
845
- // normal form: x^4 + Ax^3 + Bx^2 + Cx + D = 0
846
846
  const coffScale = new Float64Array(1);
847
847
  if (!this.safeDivide(coffScale, 1.0, c[4], 0.0, 0)) {
848
848
  this.appendCubicRoots(c, results);
849
849
  return;
850
850
  }
851
+ // normal form: x^4 + Ax^3 + Bx^2 + Cx + D = 0
851
852
  const A = c[3] * coffScale[0];
852
853
  const B = c[2] * coffScale[0];
853
854
  const C = c[1] * coffScale[0];
854
855
  const D = c[0] * coffScale[0];
855
856
  const origin = -0.25 * A;
856
- /* substitute x = y - A/4 to eliminate cubic term:
857
- x^4 + px^2 + qx + r = 0 */
857
+ // substitute x = y - A/4 to eliminate cubic term: y^4 + py^2 + qy + r = 0
858
858
  const sq_A = A * A;
859
- const p = -3.0 / 8 * sq_A + B;
859
+ const p = -0.375 * sq_A + B;
860
860
  const q = 0.125 * sq_A * A - 0.5 * A * B + C;
861
- const r = -3.0 / 256 * sq_A * sq_A + 1.0 / 16 * sq_A * B - 1.0 / 4 * A * C + D;
862
- const tempStack = new GrowableFloat64Array_1.GrowableFloat64Array();
863
- if (this.isZero(r)) {
864
- // no absolute term: y(y^3 + py + q) = 0
861
+ const r = -0.01171875 * sq_A * sq_A + 0.0625 * sq_A * B - 0.25 * A * C + D;
862
+ const cubicSolutions = new GrowableFloat64Array_1.GrowableFloat64Array();
863
+ if (this.isZero(r)) { // no absolute term: y(y^3 + py + q) = 0
865
864
  coffs[0] = q;
866
865
  coffs[1] = p;
867
866
  coffs[2] = 0;
868
867
  coffs[3] = 1;
869
868
  this.appendCubicRoots(coffs, results);
870
- results.push(0); // APPLY ORIGIN ....
871
- this.addConstant(origin, results);
869
+ results.push(0);
870
+ this.addConstant(origin, results); // apply origin
872
871
  return;
873
872
  }
874
- else {
875
- // Solve the resolvent cubic
876
- coffs[0] = 1.0 / 2 * r * p - 1.0 / 8 * q * q;
873
+ else { // solve the resolvent cubic
874
+ coffs[0] = 0.5 * r * p - 0.125 * q * q;
877
875
  coffs[1] = -r;
878
- coffs[2] = -1.0 / 2 * p;
876
+ coffs[2] = -0.5 * p;
879
877
  coffs[3] = 1;
880
- this.appendCubicRoots(coffs, tempStack);
881
- const z = this.mostDistantFromMean(tempStack);
882
- // ... to build two quadric equations
878
+ this.appendCubicRoots(coffs, cubicSolutions);
879
+ const z = this.mostDistantFromMean(cubicSolutions);
883
880
  u = z * z - r;
884
881
  v = 2 * z - p;
885
882
  if (this.isSmallRatio(u, r)) {
@@ -898,11 +895,9 @@ class AnalyticRoots {
898
895
  v = Math.sqrt(v);
899
896
  }
900
897
  else {
901
- for (let i = 0; i < tempStack.length; i++) {
902
- results.push(tempStack.atUncheckedIndex(i));
903
- }
904
898
  return;
905
899
  }
900
+ // the two quadratic equations
906
901
  coffs[0] = z - u;
907
902
  coffs[1] = ((q < 0) ? (-v) : (v));
908
903
  coffs[2] = 1;
@@ -912,8 +907,7 @@ class AnalyticRoots {
912
907
  coffs[2] = 1;
913
908
  this.appendQuadraticRoots(coffs, results);
914
909
  }
915
- // substitute
916
- this.addConstant(origin, results);
910
+ this.addConstant(origin, results); // apply origin
917
911
  results.sort();
918
912
  this.improveRoots(c, 4, results, true);
919
913
  return;
@@ -1018,19 +1012,17 @@ class PowerPolynomial {
1018
1012
  return this.degreeKnownEvaluate(coff, degree, x);
1019
1013
  }
1020
1014
  /**
1021
- * * Accumulate Q*scale into P. Both are treated as full degree.
1022
- * * (Expect Address exceptions if P is smaller than Q)
1023
- * * Returns degree of result as determined by comparing trailing coefficients to zero
1015
+ * Accumulate `coffQ*scaleQ` into `coffP`.
1016
+ * * The length of `coffP` must be at least length of `coffQ`.
1017
+ * * Returns degree of result as determined by comparing trailing coefficients to zero.
1024
1018
  */
1025
1019
  static accumulate(coffP, coffQ, scaleQ) {
1026
1020
  let degreeP = coffP.length - 1;
1027
1021
  const degreeQ = coffQ.length - 1;
1028
- for (let i = 0; i <= degreeQ; i++) {
1022
+ for (let i = 0; i <= degreeQ; i++)
1029
1023
  coffP[i] += scaleQ * coffQ[i];
1030
- }
1031
- while (degreeP >= 0 && coffP[degreeP] === 0.0) {
1024
+ while (degreeP >= 0 && coffP[degreeP] === 0.0)
1032
1025
  degreeP--;
1033
- }
1034
1026
  return degreeP;
1035
1027
  }
1036
1028
  /** Zero all coefficients */
@@ -1047,17 +1039,18 @@ exports.PowerPolynomial = PowerPolynomial;
1047
1039
  */
1048
1040
  class TrigPolynomial {
1049
1041
  /**
1050
- * Solve a polynomial created from trigonometric condition using
1051
- * Trig.S, Trig.C, Trig.W. Solution logic includes inferring angular roots
1052
- * corresponding zero leading coefficients (roots at infinity)
1053
- * @param coff Coefficients
1054
- * @param nominalDegree degree of the polynomial under most complex
1055
- * root case. If there are any zero coefficients up to this degree, a single root
1056
- * "at infinity" is recorded as its corresponding angular parameter at negative pi/2
1057
- * @param referenceCoefficient A number which represents the size of coefficients
1058
- * at various stages of computation. A small fraction of this will be used as a zero
1059
- * tolerance
1060
- * @param radians Roots are placed here
1042
+ * Solve a polynomial created from trigonometric condition using Trig.S, Trig.C, Trig.W.
1043
+ * * Polynomial is of degree 4:
1044
+ * `p(t) = coff[0] + coff[1] * t + coff[2] * t^2 + coff[3] * t^3 + coff[4] * t^4`
1045
+ * * Solution logic includes inferring angular roots corresponding zero leading coefficients
1046
+ * (roots at infinity).
1047
+ * @param coff coefficients.
1048
+ * @param nominalDegree degree of the polynomial under most complex root case. If there are
1049
+ * any zero coefficients up to this degree, a single root "at infinity" is recorded as its
1050
+ * corresponding angular parameter at negative pi/2.
1051
+ * @param referenceCoefficient a number which represents the size of coefficients at various
1052
+ * stages of computation. A small fraction of this will be used as a zero tolerance
1053
+ * @param radians roots are placed here.
1061
1054
  * @return false if equation is all zeros. This usually means any angle is a solution.
1062
1055
  */
1063
1056
  static solveAngles(coff, nominalDegree, referenceCoefficient, radians) {
@@ -1067,31 +1060,23 @@ class TrigPolynomial {
1067
1060
  const relTol = this._smallAngle;
1068
1061
  for (let i = 0; i <= nominalDegree; i++) {
1069
1062
  a = Math.abs(coff[i]);
1070
- if (a > maxCoff) {
1063
+ if (a > maxCoff)
1071
1064
  maxCoff = a;
1072
- }
1073
1065
  }
1074
1066
  const coffTol = relTol * maxCoff;
1075
1067
  let degree = nominalDegree;
1076
- while (degree > 0 && (Math.abs(coff[degree]) <= coffTol)) {
1068
+ while (degree > 0 && (Math.abs(coff[degree]) <= coffTol))
1077
1069
  degree--;
1078
- }
1079
- // let status = false;
1080
1070
  const roots = new GrowableFloat64Array_1.GrowableFloat64Array();
1081
1071
  if (degree === -1) {
1082
- // Umm. Dunno. Nothing there.
1083
- // status = false;
1072
+ // do nothing
1084
1073
  }
1085
1074
  else {
1086
- // status = true;
1087
1075
  if (degree === 0) {
1088
- // p(t) is a nonzero constant
1089
- // No roots, but not degenerate.
1090
- // status = true;
1076
+ // p(t) is a nonzero constant; no roots but not degenerate.
1091
1077
  }
1092
1078
  else if (degree === 1) {
1093
- // p(t) = coff[1] * t + coff[0]
1094
- roots.push(-coff[0] / coff[1]);
1079
+ roots.push(-coff[0] / coff[1]); // p(t) = coff[0] + coff[1] * t
1095
1080
  }
1096
1081
  else if (degree === 2) {
1097
1082
  AnalyticRoots.appendQuadraticRoots(coff, roots);
@@ -1103,70 +1088,67 @@ class TrigPolynomial {
1103
1088
  AnalyticRoots.appendQuarticRoots(coff, roots);
1104
1089
  }
1105
1090
  else {
1106
- // TODO: WILL WORK WITH BEZIER SOLVER
1107
- // status = false;
1091
+ // TODO: WORK WITH BEZIER SOLVER
1108
1092
  }
1109
1093
  if (roots.length > 0) {
1110
- // Each solution t represents an angle with
1111
- // Math.Cos(theta)=C(t)/W(t), ,sin(theta)=S(t)/W(t)
1112
- // Division by W has no effect on Atan2 calculations, so we just compute S(t),C(t)
1094
+ // Each solution t represents an angle with Math.Cos(theta) = C(t)/W(t) and sin(theta) = S(t)/W(t)
1095
+ // Division by W has no effect on atan2 calculations, so we just compute S(t),C(t)
1113
1096
  for (let i = 0; i < roots.length; i++) {
1114
1097
  const ss = PowerPolynomial.evaluate(this.S, roots.atUncheckedIndex(i));
1115
1098
  const cc = PowerPolynomial.evaluate(this.C, roots.atUncheckedIndex(i));
1116
1099
  radians.push(Math.atan2(ss, cc));
1117
1100
  }
1118
- // Each leading zero at the front of the coefficients corresponds to a root at -PI/2.
1119
- // Only make one entry....
1120
- // for (int i = degree; i < nominalDegree; i++)
1121
- if (degree < nominalDegree) {
1101
+ // each leading zero at the front of the coefficient array corresponds to a root at -PI/2.
1102
+ // only make one entry because we don't report multiplicity.
1103
+ if (degree < nominalDegree)
1122
1104
  radians.push(-0.5 * Math.PI);
1123
- }
1124
1105
  }
1125
1106
  }
1126
1107
  return radians.length > 0;
1127
1108
  }
1128
1109
  /**
1129
1110
  * Compute intersections of unit circle `x^2 + y^2 = 1` with general quadric
1130
- * `axx * x^2 + axy * x * y + ayy * y^2 + ax * x + ay * y + a1 = 0`
1111
+ * `axx * x^2 + axy * x * y + ayy * y^2 + ax * x + ay * y + a = 0`
1131
1112
  * Solutions are returned as angles. Sine and Cosine of the angles are the x, y results.
1132
- * @param axx Coefficient of x^2
1133
- * @param axy Coefficient of xy
1134
- * @param ayy Coefficient of y^2
1135
- * @param ax Coefficient of x
1136
- * @param ay Coefficient of y
1137
- * @param a1 Constant coefficient
1138
- * @param radians solution angles
1113
+ * @param axx coefficient of x^2
1114
+ * @param axy coefficient of xy
1115
+ * @param ayy coefficient of y^2
1116
+ * @param ax coefficient of x
1117
+ * @param ay coefficient of y
1118
+ * @param a constant coefficient
1119
+ * @param radians solution angles
1139
1120
  */
1140
- static solveUnitCircleImplicitQuadricIntersection(axx, axy, ayy, ax, ay, a1, radians) {
1141
- const Coffs = new Float64Array(5);
1142
- PowerPolynomial.zero(Coffs);
1121
+ static solveUnitCircleImplicitQuadricIntersection(axx, axy, ayy, ax, ay, a, radians) {
1122
+ const coffs = new Float64Array(5);
1123
+ PowerPolynomial.zero(coffs);
1143
1124
  let degree;
1144
- if (Geometry_1.Geometry.hypotenuseXYZ(axx, axy, ayy) > TrigPolynomial._coefficientRelTol * Geometry_1.Geometry.hypotenuseXYZ(ax, ay, a1)) {
1145
- PowerPolynomial.accumulate(Coffs, this.CW, ax);
1146
- PowerPolynomial.accumulate(Coffs, this.SW, ay);
1147
- PowerPolynomial.accumulate(Coffs, this.WW, a1);
1148
- PowerPolynomial.accumulate(Coffs, this.SS, ayy);
1149
- PowerPolynomial.accumulate(Coffs, this.CC, axx);
1150
- PowerPolynomial.accumulate(Coffs, this.SC, axy);
1125
+ // see core\geometry\internaldocs\unitCircleEllipseIntersection.md for derivation of these coefficients
1126
+ if (Geometry_1.Geometry.hypotenuseXYZ(axx, axy, ayy) > TrigPolynomial._coefficientRelTol * Geometry_1.Geometry.hypotenuseXYZ(ax, ay, a)) {
1127
+ PowerPolynomial.accumulate(coffs, this.CW, ax);
1128
+ PowerPolynomial.accumulate(coffs, this.SW, ay);
1129
+ PowerPolynomial.accumulate(coffs, this.WW, a);
1130
+ PowerPolynomial.accumulate(coffs, this.SS, ayy);
1131
+ PowerPolynomial.accumulate(coffs, this.CC, axx);
1132
+ PowerPolynomial.accumulate(coffs, this.SC, axy);
1151
1133
  degree = 4;
1152
1134
  }
1153
1135
  else {
1154
- PowerPolynomial.accumulate(Coffs, this.C, ax);
1155
- PowerPolynomial.accumulate(Coffs, this.S, ay);
1156
- PowerPolynomial.accumulate(Coffs, this.W, a1);
1136
+ PowerPolynomial.accumulate(coffs, this.C, ax);
1137
+ PowerPolynomial.accumulate(coffs, this.S, ay);
1138
+ PowerPolynomial.accumulate(coffs, this.W, a);
1157
1139
  degree = 2;
1158
1140
  }
1159
- let maxCoff = 0.0;
1160
- maxCoff = Math.max(maxCoff, Math.abs(axx), Math.abs(ayy), Math.abs(axy), Math.abs(ax), Math.abs(ay), Math.abs(a1));
1161
- const b = this.solveAngles(Coffs, degree, maxCoff, radians);
1141
+ const maxCoff = Math.max(Math.abs(axx), Math.abs(ayy), Math.abs(axy), Math.abs(ax), Math.abs(ay), Math.abs(a));
1142
+ const b = this.solveAngles(coffs, degree, maxCoff, radians);
1162
1143
  /*
1163
1144
  for (const theta of angles) {
1164
1145
  const c = theta.cos();
1165
1146
  const s = theta.sin();
1166
1147
  GeometryCoreTestIO.consoleLog({
1167
1148
  angle: theta, co: c, si: s,
1168
- f: axx * c * c + axy * c * s + ayy * s * s + ax * c + ay * s + a1});
1169
- } */
1149
+ f: axx * c * c + axy * c * s + ayy * s * s + ax * c + ay * s + a,
1150
+ });
1151
+ } */
1170
1152
  return b;
1171
1153
  }
1172
1154
  /**
@@ -1184,6 +1166,7 @@ class TrigPolynomial {
1184
1166
  */
1185
1167
  static solveUnitCircleEllipseIntersection(cx, cy, ux, uy, vx, vy, ellipseRadians, circleRadians) {
1186
1168
  circleRadians.length = 0;
1169
+ // see core\geometry\internaldocs\unitCircleEllipseIntersection.md for derivation of these coefficients:
1187
1170
  const acc = ux * ux + uy * uy;
1188
1171
  const acs = 2.0 * (ux * vx + uy * vy);
1189
1172
  const ass = vx * vx + vy * vy;
@@ -1201,7 +1184,7 @@ class TrigPolynomial {
1201
1184
  return status;
1202
1185
  }
1203
1186
  /**
1204
- * Compute intersections of unit circle `x^2 + y^2 = w^2` with the ellipse
1187
+ * Compute intersections of unit circle `x^2 + y^2 = w^2` (in homogeneous coordinates) with the ellipse
1205
1188
  * `F(t) = (cx + ux cos(t) + vx sin(t), cy + uy cos(t) + vy sin(t)) / (cw + uw cos(t) + vw sin(t))`.
1206
1189
  * @param cx center x
1207
1190
  * @param cy center y
@@ -1217,13 +1200,14 @@ class TrigPolynomial {
1217
1200
  */
1218
1201
  static solveUnitCircleHomogeneousEllipseIntersection(cx, cy, cw, ux, uy, uw, vx, vy, vw, ellipseRadians, circleRadians) {
1219
1202
  circleRadians.length = 0;
1203
+ // see core\geometry\internaldocs\unitCircleEllipseIntersection.md for derivation of these coefficients:
1220
1204
  const acc = ux * ux + uy * uy - uw * uw;
1221
1205
  const acs = 2.0 * (ux * vx + uy * vy - uw * vw);
1222
1206
  const ass = vx * vx + vy * vy - vw * vw;
1223
1207
  const ac = 2.0 * (ux * cx + uy * cy - uw * cw);
1224
- const asi = 2.0 * (vx * cx + vy * cy - vw * cw);
1208
+ const as = 2.0 * (vx * cx + vy * cy - vw * cw);
1225
1209
  const a = cx * cx + cy * cy - cw * cw;
1226
- const status = this.solveUnitCircleImplicitQuadricIntersection(acc, acs, ass, ac, asi, a, ellipseRadians);
1210
+ const status = this.solveUnitCircleImplicitQuadricIntersection(acc, acs, ass, ac, as, a, ellipseRadians);
1227
1211
  for (const radians of ellipseRadians) {
1228
1212
  const cc = Math.cos(radians);
1229
1213
  const ss = Math.sin(radians);
@@ -1237,25 +1221,26 @@ class TrigPolynomial {
1237
1221
  exports.TrigPolynomial = TrigPolynomial;
1238
1222
  // tolerance for small angle decision.
1239
1223
  TrigPolynomial._smallAngle = 1.0e-11;
1240
- /** Standard Basis coefficients for rational sine numerator. */
1224
+ // see core\geometry\internaldocs\unitCircleEllipseIntersection.md for derivation of these coefficients.
1225
+ /** Standard Basis coefficients for the numerator of the y-coordinate y(t) = S(t)/W(t) in the rational semicircle parameterization. */
1241
1226
  TrigPolynomial.S = Float64Array.from([0.0, 2.0, -2.0]);
1242
- /** Standard Basis coefficients for rational cosine numerator. */
1227
+ /** Standard Basis coefficients for the numerator of the x-coordinate x(t) = C(t)/W(t) in the rational semicircle parameterization. */
1243
1228
  TrigPolynomial.C = Float64Array.from([1.0, -2.0]);
1244
- /** Standard Basis coefficients for rational denominator. */
1229
+ /** Standard Basis coefficients for the denominator of x(t) and y(t) in the rational semicircle parameterization. */
1245
1230
  TrigPolynomial.W = Float64Array.from([1.0, -2.0, 2.0]);
1246
- /** Standard Basis coefficients for cosine*weight numerator */
1231
+ /** Standard Basis coefficients for C(t) * W(t). */
1247
1232
  TrigPolynomial.CW = Float64Array.from([1.0, -4.0, 6.0, -4.0]);
1248
- /** Standard Basis coefficients for sine*weight numerator */
1233
+ /** Standard Basis coefficients for S(t) * W(t). */
1249
1234
  TrigPolynomial.SW = Float64Array.from([0.0, 2.0, -6.0, 8.0, -4.0]);
1250
- /** Standard Basis coefficients for sine*cosine numerator */
1235
+ /** Standard Basis coefficients for S(t) * C(t). */
1251
1236
  TrigPolynomial.SC = Float64Array.from([0.0, 2.0, -6.0, 4.0]);
1252
- /** Standard Basis coefficients for sine^2 numerator */
1237
+ /** Standard Basis coefficients for S(t) * S(t). */
1253
1238
  TrigPolynomial.SS = Float64Array.from([0.0, 0.0, 4.0, -8.0, 4.0]);
1254
- /** Standard Basis coefficients for cosine^2 numerator */
1239
+ /** Standard Basis coefficients for C(t) * C(t). */
1255
1240
  TrigPolynomial.CC = Float64Array.from([1.0, -4.0, 4.0]);
1256
- /** Standard Basis coefficients for weight^2 */
1241
+ /** Standard Basis coefficients for W(t) * W(t). */
1257
1242
  TrigPolynomial.WW = Float64Array.from([1.0, -4.0, 8.0, -8.0, 4.0]);
1258
- /** Standard Basis coefficients for (Math.Cos^2 - sine^2) numerator */
1243
+ /** Standard Basis coefficients for C(t) * C(t) - S(t) * S(t). */
1259
1244
  TrigPolynomial.CCminusSS = Float64Array.from([1.0, -4.0, 0.0, 8.0, -4.0]);
1260
1245
  TrigPolynomial._coefficientRelTol = 1.0e-12;
1261
1246
  /**