@ccpc/math 0.1.0

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 (177) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/dist/constants/geom_type.d.ts +13 -0
  4. package/dist/constants/geom_type.d.ts.map +1 -0
  5. package/dist/constants/geom_type.js +17 -0
  6. package/dist/constants/math_const.d.ts +9 -0
  7. package/dist/constants/math_const.d.ts.map +1 -0
  8. package/dist/constants/math_const.js +12 -0
  9. package/dist/core/box2.d.ts +71 -0
  10. package/dist/core/box2.d.ts.map +1 -0
  11. package/dist/core/box2.js +243 -0
  12. package/dist/core/coord2d.d.ts +62 -0
  13. package/dist/core/coord2d.d.ts.map +1 -0
  14. package/dist/core/coord2d.js +155 -0
  15. package/dist/core/geom_base.d.ts +19 -0
  16. package/dist/core/geom_base.d.ts.map +1 -0
  17. package/dist/core/geom_base.js +18 -0
  18. package/dist/core/mat3.d.ts +101 -0
  19. package/dist/core/mat3.d.ts.map +1 -0
  20. package/dist/core/mat3.js +290 -0
  21. package/dist/core/vec2.d.ts +138 -0
  22. package/dist/core/vec2.d.ts.map +1 -0
  23. package/dist/core/vec2.js +297 -0
  24. package/dist/curves/arc2.d.ts +49 -0
  25. package/dist/curves/arc2.d.ts.map +1 -0
  26. package/dist/curves/arc2.js +265 -0
  27. package/dist/curves/bspline2.d.ts +150 -0
  28. package/dist/curves/bspline2.d.ts.map +1 -0
  29. package/dist/curves/bspline2.js +793 -0
  30. package/dist/curves/circle2.d.ts +42 -0
  31. package/dist/curves/circle2.d.ts.map +1 -0
  32. package/dist/curves/circle2.js +135 -0
  33. package/dist/curves/circle_curve2.d.ts +38 -0
  34. package/dist/curves/circle_curve2.d.ts.map +1 -0
  35. package/dist/curves/circle_curve2.js +112 -0
  36. package/dist/curves/curve2.d.ts +214 -0
  37. package/dist/curves/curve2.d.ts.map +1 -0
  38. package/dist/curves/curve2.js +238 -0
  39. package/dist/curves/ellipse2.d.ts +42 -0
  40. package/dist/curves/ellipse2.d.ts.map +1 -0
  41. package/dist/curves/ellipse2.js +125 -0
  42. package/dist/curves/ellipse_arc2.d.ts +49 -0
  43. package/dist/curves/ellipse_arc2.d.ts.map +1 -0
  44. package/dist/curves/ellipse_arc2.js +184 -0
  45. package/dist/curves/ellipse_curve2.d.ts +56 -0
  46. package/dist/curves/ellipse_curve2.d.ts.map +1 -0
  47. package/dist/curves/ellipse_curve2.js +262 -0
  48. package/dist/curves/interval.d.ts +112 -0
  49. package/dist/curves/interval.d.ts.map +1 -0
  50. package/dist/curves/interval.js +200 -0
  51. package/dist/curves/line2.d.ts +64 -0
  52. package/dist/curves/line2.d.ts.map +1 -0
  53. package/dist/curves/line2.js +193 -0
  54. package/dist/curves/period_interval.d.ts +129 -0
  55. package/dist/curves/period_interval.d.ts.map +1 -0
  56. package/dist/curves/period_interval.js +240 -0
  57. package/dist/discretize/discretize_defaults.d.ts +12 -0
  58. package/dist/discretize/discretize_defaults.d.ts.map +1 -0
  59. package/dist/discretize/discretize_defaults.js +12 -0
  60. package/dist/discretize/discretize_engine.d.ts +33 -0
  61. package/dist/discretize/discretize_engine.d.ts.map +1 -0
  62. package/dist/discretize/discretize_engine.js +347 -0
  63. package/dist/discretize/discretize_errors.d.ts +15 -0
  64. package/dist/discretize/discretize_errors.d.ts.map +1 -0
  65. package/dist/discretize/discretize_errors.js +30 -0
  66. package/dist/discretize/discretize_options.d.ts +18 -0
  67. package/dist/discretize/discretize_options.d.ts.map +1 -0
  68. package/dist/discretize/discretize_options.js +19 -0
  69. package/dist/discretize/discretize_types.d.ts +36 -0
  70. package/dist/discretize/discretize_types.d.ts.map +1 -0
  71. package/dist/discretize/discretize_types.js +1 -0
  72. package/dist/discretize/internal/curve_guards.d.ts +35 -0
  73. package/dist/discretize/internal/curve_guards.d.ts.map +1 -0
  74. package/dist/discretize/internal/curve_guards.js +62 -0
  75. package/dist/discretize/internal/postprocess.d.ts +5 -0
  76. package/dist/discretize/internal/postprocess.d.ts.map +1 -0
  77. package/dist/discretize/internal/postprocess.js +109 -0
  78. package/dist/discretize/internal/sampling_utils.d.ts +8 -0
  79. package/dist/discretize/internal/sampling_utils.d.ts.map +1 -0
  80. package/dist/discretize/internal/sampling_utils.js +36 -0
  81. package/dist/discretize/register_builtin_strategies.d.ts +3 -0
  82. package/dist/discretize/register_builtin_strategies.d.ts.map +1 -0
  83. package/dist/discretize/register_builtin_strategies.js +10 -0
  84. package/dist/discretize/strategies/bspline_strategy.d.ts +4 -0
  85. package/dist/discretize/strategies/bspline_strategy.d.ts.map +1 -0
  86. package/dist/discretize/strategies/bspline_strategy.js +115 -0
  87. package/dist/discretize/strategies/circle_strategy.d.ts +7 -0
  88. package/dist/discretize/strategies/circle_strategy.d.ts.map +1 -0
  89. package/dist/discretize/strategies/circle_strategy.js +55 -0
  90. package/dist/discretize/strategies/ellipse_strategy.d.ts +7 -0
  91. package/dist/discretize/strategies/ellipse_strategy.d.ts.map +1 -0
  92. package/dist/discretize/strategies/ellipse_strategy.js +86 -0
  93. package/dist/discretize/strategies/line_strategy.d.ts +4 -0
  94. package/dist/discretize/strategies/line_strategy.d.ts.map +1 -0
  95. package/dist/discretize/strategies/line_strategy.js +40 -0
  96. package/dist/discretize/strategy_registry.d.ts +9 -0
  97. package/dist/discretize/strategy_registry.d.ts.map +1 -0
  98. package/dist/discretize/strategy_registry.js +34 -0
  99. package/dist/index.d.ts +30 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +24 -0
  102. package/dist/intersections/analytic_x_algorithm.d.ts +10 -0
  103. package/dist/intersections/analytic_x_algorithm.d.ts.map +1 -0
  104. package/dist/intersections/analytic_x_algorithm.js +83 -0
  105. package/dist/intersections/curve_x_engine.d.ts +9 -0
  106. package/dist/intersections/curve_x_engine.d.ts.map +1 -0
  107. package/dist/intersections/curve_x_engine.js +27 -0
  108. package/dist/intersections/index.d.ts +5 -0
  109. package/dist/intersections/index.d.ts.map +1 -0
  110. package/dist/intersections/index.js +11 -0
  111. package/dist/intersections/internal/certification.d.ts +34 -0
  112. package/dist/intersections/internal/certification.d.ts.map +1 -0
  113. package/dist/intersections/internal/certification.js +238 -0
  114. package/dist/intersections/internal/interval_clipping.d.ts +29 -0
  115. package/dist/intersections/internal/interval_clipping.d.ts.map +1 -0
  116. package/dist/intersections/internal/interval_clipping.js +123 -0
  117. package/dist/intersections/internal/kind.d.ts +4 -0
  118. package/dist/intersections/internal/kind.d.ts.map +1 -0
  119. package/dist/intersections/internal/kind.js +16 -0
  120. package/dist/intersections/internal/pair.d.ts +9 -0
  121. package/dist/intersections/internal/pair.d.ts.map +1 -0
  122. package/dist/intersections/internal/pair.js +14 -0
  123. package/dist/intersections/internal/result.d.ts +20 -0
  124. package/dist/intersections/internal/result.d.ts.map +1 -0
  125. package/dist/intersections/internal/result.js +125 -0
  126. package/dist/intersections/internal/sampling.d.ts +15 -0
  127. package/dist/intersections/internal/sampling.d.ts.map +1 -0
  128. package/dist/intersections/internal/sampling.js +131 -0
  129. package/dist/intersections/internal/segment.d.ts +32 -0
  130. package/dist/intersections/internal/segment.d.ts.map +1 -0
  131. package/dist/intersections/internal/segment.js +137 -0
  132. package/dist/intersections/internal/tolerance.d.ts +10 -0
  133. package/dist/intersections/internal/tolerance.d.ts.map +1 -0
  134. package/dist/intersections/internal/tolerance.js +20 -0
  135. package/dist/intersections/intersector.d.ts +6 -0
  136. package/dist/intersections/intersector.d.ts.map +1 -0
  137. package/dist/intersections/intersector.js +1 -0
  138. package/dist/intersections/numeric_x_algorithm.d.ts +10 -0
  139. package/dist/intersections/numeric_x_algorithm.d.ts.map +1 -0
  140. package/dist/intersections/numeric_x_algorithm.js +73 -0
  141. package/dist/intersections/solvers/bspline_self_solver.d.ts +7 -0
  142. package/dist/intersections/solvers/bspline_self_solver.d.ts.map +1 -0
  143. package/dist/intersections/solvers/bspline_self_solver.js +308 -0
  144. package/dist/intersections/solvers/line_line_pair_solver.d.ts +7 -0
  145. package/dist/intersections/solvers/line_line_pair_solver.d.ts.map +1 -0
  146. package/dist/intersections/solvers/line_line_pair_solver.js +35 -0
  147. package/dist/intersections/solvers/pair_solvers.d.ts +94 -0
  148. package/dist/intersections/solvers/pair_solvers.d.ts.map +1 -0
  149. package/dist/intersections/solvers/pair_solvers.js +1078 -0
  150. package/dist/intersections/solvers/polyline_pair_intersector.d.ts +51 -0
  151. package/dist/intersections/solvers/polyline_pair_intersector.d.ts.map +1 -0
  152. package/dist/intersections/solvers/polyline_pair_intersector.js +731 -0
  153. package/dist/intersections/types.d.ts +11 -0
  154. package/dist/intersections/types.d.ts.map +1 -0
  155. package/dist/intersections/types.js +1 -0
  156. package/dist/serialize/dump_types.d.ts +101 -0
  157. package/dist/serialize/dump_types.d.ts.map +1 -0
  158. package/dist/serialize/dump_types.js +5 -0
  159. package/dist/serialize/geom_mgr.d.ts +24 -0
  160. package/dist/serialize/geom_mgr.d.ts.map +1 -0
  161. package/dist/serialize/geom_mgr.js +30 -0
  162. package/dist/types/type_define.d.ts +29 -0
  163. package/dist/types/type_define.d.ts.map +1 -0
  164. package/dist/types/type_define.js +10 -0
  165. package/dist/types/type_guard.d.ts +46 -0
  166. package/dist/types/type_guard.d.ts.map +1 -0
  167. package/dist/types/type_guard.js +5 -0
  168. package/dist/utils/math_error.d.ts +16 -0
  169. package/dist/utils/math_error.d.ts.map +1 -0
  170. package/dist/utils/math_error.js +35 -0
  171. package/dist/utils/math_utils.d.ts +9 -0
  172. package/dist/utils/math_utils.d.ts.map +1 -0
  173. package/dist/utils/math_utils.js +25 -0
  174. package/dist/utils/precision.d.ts +29 -0
  175. package/dist/utils/precision.d.ts.map +1 -0
  176. package/dist/utils/precision.js +44 -0
  177. package/package.json +38 -0
@@ -0,0 +1,83 @@
1
+ import { MathError } from '../utils/math_error';
2
+ import { getCurveKind } from './internal/kind';
3
+ import { normalizePair } from './internal/pair';
4
+ import { analyzeCurveXInfosQuality, postprocessCurveXInfos, swapCurveXInfos } from './internal/result';
5
+ import { makeIntersectionTolerance } from './internal/tolerance';
6
+ import { ArcArcPairSolver, ArcEllipseArcPairSolver, ArcEllipsePairSolver, CircleArcPairSolver, CircleCirclePairSolver, CircleEllipseArcPairSolver, CircleEllipsePairSolver, EllipseArcEllipseArcPairSolver, EllipseEllipseArcPairSolver, EllipseEllipsePairSolver, LineArcPairSolver, LineCirclePairSolver, LineEllipseArcPairSolver, LineEllipsePairSolver, LineLinePairSolver, } from './solvers/pair_solvers';
7
+ import { PolylinePairIntersector } from './solvers/polyline_pair_intersector';
8
+ export class AnalyticXAlgorithm {
9
+ constructor() {
10
+ this.map = {
11
+ 'line|line': new LineLinePairSolver(),
12
+ 'line|circle': new LineCirclePairSolver(),
13
+ 'line|arc': new LineArcPairSolver(),
14
+ 'line|ellipse': new LineEllipsePairSolver(),
15
+ 'line|ellipseArc': new LineEllipseArcPairSolver(),
16
+ 'circle|circle': new CircleCirclePairSolver(),
17
+ 'circle|arc': new CircleArcPairSolver(),
18
+ 'circle|ellipse': new CircleEllipsePairSolver(),
19
+ 'circle|ellipseArc': new CircleEllipseArcPairSolver(),
20
+ 'arc|arc': new ArcArcPairSolver(),
21
+ 'arc|ellipse': new ArcEllipsePairSolver(),
22
+ 'arc|ellipseArc': new ArcEllipseArcPairSolver(),
23
+ 'ellipse|ellipse': new EllipseEllipsePairSolver(),
24
+ 'ellipse|ellipseArc': new EllipseEllipseArcPairSolver(),
25
+ 'ellipseArc|ellipseArc': new EllipseArcEllipseArcPairSolver(),
26
+ };
27
+ this.retryMap = {
28
+ 'circle|ellipse': new PolylinePairIntersector(320, 96),
29
+ 'circle|ellipseArc': new PolylinePairIntersector(320, 96),
30
+ 'arc|ellipse': new PolylinePairIntersector(320, 96),
31
+ 'arc|ellipseArc': new PolylinePairIntersector(320, 96),
32
+ 'ellipse|ellipse': new PolylinePairIntersector(352, 96),
33
+ 'ellipse|ellipseArc': new PolylinePairIntersector(352, 96),
34
+ 'ellipseArc|ellipseArc': new PolylinePairIntersector(352, 96),
35
+ };
36
+ }
37
+ intersect(c1, c2) {
38
+ const k1 = getCurveKind(c1);
39
+ const k2 = getCurveKind(c2);
40
+ const pair = normalizePair(k1, k2);
41
+ const solver = this.map[pair.key];
42
+ if (!solver) {
43
+ MathError.throw(`AnalyticXAlgorithm: unsupported pair ${c1.getType()}|${c2.getType()}`);
44
+ }
45
+ const tol = makeIntersectionTolerance(c1, c2);
46
+ const diagBefore = PolylinePairIntersector.getDiagnostics();
47
+ const raw = pair.swapped ? solver.intersect(c2, c1) : solver.intersect(c1, c2);
48
+ const ordered = pair.swapped ? swapCurveXInfos(raw) : raw;
49
+ const primary = postprocessCurveXInfos(ordered, tol.pointTol);
50
+ const quality = analyzeCurveXInfosQuality(ordered, tol.pointTol);
51
+ if (!this.shouldRetry(pair.key, c1, c2, quality, diagBefore, PolylinePairIntersector.getDiagnostics())) {
52
+ return primary;
53
+ }
54
+ const retrySolver = this.retryMap[pair.key];
55
+ if (!retrySolver)
56
+ return primary;
57
+ const retryRaw = pair.swapped ? retrySolver.intersect(c2, c1) : retrySolver.intersect(c1, c2);
58
+ if (retryRaw.length === 0)
59
+ return primary;
60
+ const retryOrdered = pair.swapped ? swapCurveXInfos(retryRaw) : retryRaw;
61
+ return postprocessCurveXInfos([...ordered, ...retryOrdered], tol.pointTol);
62
+ }
63
+ shouldRetry(key, c1, c2, quality, before, after) {
64
+ if (!this.retryMap[key])
65
+ return false;
66
+ if (!this.boxesLikelyIntersect(c1, c2))
67
+ return false;
68
+ if (quality.rawCount === 0)
69
+ return true;
70
+ if (quality.duplicatePointCount > 0)
71
+ return true;
72
+ const certificationMissDelta = after.certificationMissCount - before.certificationMissCount;
73
+ const refineFailDelta = after.refineFailureCount - before.refineFailureCount;
74
+ const rejectDelta = after.certificationRejectCount - before.certificationRejectCount;
75
+ return certificationMissDelta > 0 || refineFailDelta > 0 || rejectDelta > 0;
76
+ }
77
+ boxesLikelyIntersect(c1, c2) {
78
+ const t = makeIntersectionTolerance(c1, c2);
79
+ const b1 = c1.boundingBox().expandByScalar(t.pointTol * 2);
80
+ const b2 = c2.boundingBox().expandByScalar(t.pointTol * 2);
81
+ return b1.intersects(b2);
82
+ }
83
+ }
@@ -0,0 +1,9 @@
1
+ import type { Curve2 } from '../curves/curve2';
2
+ import type { CurveXInfo } from './types';
3
+ export declare class CurveXEngine {
4
+ private readonly analytic;
5
+ private readonly numeric;
6
+ intersect(c1: Curve2, c2: Curve2): CurveXInfo[];
7
+ private shouldUseNumeric;
8
+ }
9
+ //# sourceMappingURL=curve_x_engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curve_x_engine.d.ts","sourceRoot":"","sources":["../../src/intersections/curve_x_engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAI9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAE3C,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,EAAE;IAkBtD,OAAO,CAAC,gBAAgB;CAG3B"}
@@ -0,0 +1,27 @@
1
+ import { MathError } from '../utils/math_error';
2
+ import { AnalyticXAlgorithm } from './analytic_x_algorithm';
3
+ import { NumericXAlgorithm } from './numeric_x_algorithm';
4
+ export class CurveXEngine {
5
+ constructor() {
6
+ this.analytic = new AnalyticXAlgorithm();
7
+ this.numeric = new NumericXAlgorithm();
8
+ }
9
+ intersect(c1, c2) {
10
+ if (this.shouldUseNumeric(c1, c2)) {
11
+ return this.numeric.intersect(c1, c2);
12
+ }
13
+ try {
14
+ return this.analytic.intersect(c1, c2);
15
+ }
16
+ catch (error) {
17
+ if (error instanceof MathError &&
18
+ error.message.startsWith('AnalyticXAlgorithm: unsupported pair')) {
19
+ return this.numeric.intersect(c1, c2);
20
+ }
21
+ throw error;
22
+ }
23
+ }
24
+ shouldUseNumeric(c1, c2) {
25
+ return c1.isBSpline() || c2.isBSpline();
26
+ }
27
+ }
@@ -0,0 +1,5 @@
1
+ import type { Curve2 } from '../curves/curve2';
2
+ export type { CurveXInfo } from './types';
3
+ export declare function intersectCurveCurve(c1: Curve2, c2: Curve2): import("./types").CurveXInfo[];
4
+ export declare function intersectCurveSelf(curve: Curve2): import("./types").CurveXInfo[];
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intersections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAI9C,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIzC,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kCAEzD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,kCAG/C"}
@@ -0,0 +1,11 @@
1
+ import { CurveXEngine } from './curve_x_engine';
2
+ import { intersectBSplineSelf } from './solvers/bspline_self_solver';
3
+ const curveXEngine = new CurveXEngine();
4
+ export function intersectCurveCurve(c1, c2) {
5
+ return curveXEngine.intersect(c1, c2);
6
+ }
7
+ export function intersectCurveSelf(curve) {
8
+ if (!curve.isBSpline())
9
+ return [];
10
+ return intersectBSplineSelf(curve);
11
+ }
@@ -0,0 +1,34 @@
1
+ import { Interval } from '../../curves/interval';
2
+ import type { Curve2 } from '../../curves/curve2';
3
+ import type { Vec2 } from '../../core/vec2';
4
+ export type ClosestPointLike = {
5
+ param: number;
6
+ distance: number;
7
+ };
8
+ export type ClosestPointProvider = (curve: Curve2, p: Vec2, tol: number) => ClosestPointLike | undefined;
9
+ export type ParamPairCandidate = {
10
+ u1: number;
11
+ u2: number;
12
+ residual: number;
13
+ };
14
+ export type CertifiedParamPair = {
15
+ point: Vec2;
16
+ u1: number;
17
+ u2: number;
18
+ residual: number;
19
+ };
20
+ export type ResidualEnvelope = {
21
+ lowerBound: number;
22
+ upperBound: number;
23
+ minSample: number;
24
+ maxSample: number;
25
+ };
26
+ export type CertificationOutcome = {
27
+ pair: CertifiedParamPair;
28
+ usedDegenerateRescue: boolean;
29
+ envelopeUpperBound: number;
30
+ };
31
+ export declare function certifyParamPair(c1: Curve2, c2: Curve2, candidate: ParamPairCandidate, tol: number, closestPoint: ClosestPointProvider): CertificationOutcome | undefined;
32
+ export declare function projectRangeToCurve(baseCurve: Curve2, otherCurve: Curve2, rangeOnBase: Interval, tol: number, closestPoint: ClosestPointProvider): Interval | undefined;
33
+ export declare function certifyOverlapMonotone(baseCurve: Curve2, otherCurve: Curve2, rangeOnBase: Interval, tol: number, paramTol: number, closestPoint: ClosestPointProvider): boolean;
34
+ //# sourceMappingURL=certification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certification.d.ts","sourceRoot":"","sources":["../../../src/intersections/internal/certification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,MAAM,gBAAgB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS,CAAA;AAExG,MAAM,MAAM,kBAAkB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,IAAI,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,kBAAkB,CAAA;IACxB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,kBAAkB,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED,wBAAgB,gBAAgB,CAC5B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,kBAAkB,EAC7B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,oBAAoB,GACnC,oBAAoB,GAAG,SAAS,CAwBlC;AAED,wBAAgB,mBAAmB,CAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,QAAQ,EACrB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,oBAAoB,GACnC,QAAQ,GAAG,SAAS,CAOtB;AAED,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,QAAQ,EACrB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,oBAAoB,WAuBrC"}
@@ -0,0 +1,238 @@
1
+ import { Interval } from '../../curves/interval';
2
+ import { Precision } from '../../utils/precision';
3
+ export function certifyParamPair(c1, c2, candidate, tol, closestPoint) {
4
+ const cp2 = closestPoint(c2, c1.pointAt(candidate.u1), tol * 2);
5
+ const cp1 = closestPoint(c1, c2.pointAt(candidate.u2), tol * 2);
6
+ if (!cp1 || !cp2)
7
+ return undefined;
8
+ if (cp1.distance > tol * 3 || cp2.distance > tol * 3)
9
+ return undefined;
10
+ const measured = measureParamPair(c1, c2, cp1.param, cp2.param);
11
+ if (measured.residual > tol * 3)
12
+ return undefined;
13
+ const envelope = estimateResidualEnvelopeAdaptive(c1, c2, measured.u1, measured.u2, 4);
14
+ if (envelope.upperBound <= tol * 6) {
15
+ return {
16
+ pair: measured,
17
+ usedDegenerateRescue: false,
18
+ envelopeUpperBound: envelope.upperBound,
19
+ };
20
+ }
21
+ if (!isNearDegenerate(c1, c2, measured.u1, measured.u2))
22
+ return undefined;
23
+ const rescued = tryDegenerateRescue(c1, c2, measured, tol, closestPoint);
24
+ if (!rescued)
25
+ return undefined;
26
+ return {
27
+ pair: rescued.pair,
28
+ usedDegenerateRescue: true,
29
+ envelopeUpperBound: rescued.envelope.upperBound,
30
+ };
31
+ }
32
+ export function projectRangeToCurve(baseCurve, otherCurve, rangeOnBase, tol, closestPoint) {
33
+ const startOnBase = baseCurve.pointAt(rangeOnBase.start);
34
+ const endOnBase = baseCurve.pointAt(rangeOnBase.end);
35
+ const cpStart = closestPoint(otherCurve, startOnBase, tol);
36
+ const cpEnd = closestPoint(otherCurve, endOnBase, tol);
37
+ if (!cpStart || !cpEnd)
38
+ return undefined;
39
+ return new Interval(Math.min(cpStart.param, cpEnd.param), Math.max(cpStart.param, cpEnd.param));
40
+ }
41
+ export function certifyOverlapMonotone(baseCurve, otherCurve, rangeOnBase, tol, paramTol, closestPoint) {
42
+ const samples = [0, 0.25, 0.5, 0.75, 1];
43
+ let pass = 0;
44
+ const paramsOnOther = [];
45
+ for (const t of samples) {
46
+ const u = rangeOnBase.start + (rangeOnBase.end - rangeOnBase.start) * t;
47
+ const p = baseCurve.pointAt(u);
48
+ const cp = closestPoint(otherCurve, p, tol);
49
+ if (!cp)
50
+ continue;
51
+ paramsOnOther.push(cp.param);
52
+ if (cp.distance <= tol * 2.5)
53
+ pass++;
54
+ }
55
+ if (pass < 4 || paramsOnOther.length < 4)
56
+ return false;
57
+ let nonDecreasing = true;
58
+ let nonIncreasing = true;
59
+ for (let i = 1; i < paramsOnOther.length; i++) {
60
+ if (paramsOnOther[i] < paramsOnOther[i - 1] - paramTol)
61
+ nonDecreasing = false;
62
+ if (paramsOnOther[i] > paramsOnOther[i - 1] + paramTol)
63
+ nonIncreasing = false;
64
+ }
65
+ return nonDecreasing || nonIncreasing;
66
+ }
67
+ function measureParamPair(c1, c2, u1, u2) {
68
+ const p1 = c1.pointAt(u1);
69
+ const p2 = c2.pointAt(u2);
70
+ return {
71
+ u1,
72
+ u2,
73
+ point: p1.added(p2).scale(0.5),
74
+ residual: p1.distanceTo(p2),
75
+ };
76
+ }
77
+ function estimateResidualEnvelopeAdaptive(c1, c2, u1, u2, maxDepth) {
78
+ let w1 = buildCertificationWindow(c1, u1, 1);
79
+ let w2 = buildCertificationWindow(c2, u2, 1);
80
+ let upper = Number.POSITIVE_INFINITY;
81
+ let lower = 0;
82
+ let minSample = Number.POSITIVE_INFINITY;
83
+ let maxSample = 0;
84
+ for (let depth = 0; depth <= maxDepth; depth++) {
85
+ const env = evaluateWindowEnvelope(c1, c2, w1, w2);
86
+ lower = Math.max(lower, env.lowerBound);
87
+ upper = Math.min(upper, env.upperBound);
88
+ minSample = Math.min(minSample, env.minSample);
89
+ maxSample = Math.max(maxSample, env.maxSample);
90
+ if (w1.length() <= Precision.CURVE_PARAM_EPS * 32 && w2.length() <= Precision.CURVE_PARAM_EPS * 32) {
91
+ break;
92
+ }
93
+ w1 = shrinkWindowAroundParam(c1, w1, u1, 0.5);
94
+ w2 = shrinkWindowAroundParam(c2, w2, u2, 0.5);
95
+ }
96
+ const half1 = 0.5 * (w1.end - w1.start);
97
+ const half2 = 0.5 * (w2.end - w2.start);
98
+ const l1 = maxTangentNorm(c1, w1);
99
+ const l2 = maxTangentNorm(c2, w2);
100
+ const drift = l1 * half1 + l2 * half2;
101
+ const conservativeUpper = Number.isFinite(upper) ? upper + drift * 0.25 : maxSample + drift;
102
+ const conservativeLower = Math.max(0, lower - drift * 0.25);
103
+ return {
104
+ lowerBound: conservativeLower,
105
+ upperBound: Math.max(conservativeUpper, maxSample),
106
+ minSample,
107
+ maxSample,
108
+ };
109
+ }
110
+ function tryDegenerateRescue(c1, c2, measured, tol, closestPoint) {
111
+ const w1 = buildCertificationWindow(c1, measured.u1, 2);
112
+ const w2 = buildCertificationWindow(c2, measured.u2, 2);
113
+ const grid = sampleInterval5(w1);
114
+ const grid2 = sampleInterval5(w2);
115
+ let best = measured;
116
+ for (const u of grid) {
117
+ const p1 = c1.pointAt(u);
118
+ for (const v of grid2) {
119
+ const p2 = c2.pointAt(v);
120
+ const d = p1.distanceTo(p2);
121
+ if (d >= best.residual)
122
+ continue;
123
+ best = {
124
+ u1: u,
125
+ u2: v,
126
+ point: p1.added(p2).scale(0.5),
127
+ residual: d,
128
+ };
129
+ }
130
+ }
131
+ const cp2 = closestPoint(c2, c1.pointAt(best.u1), tol * 3);
132
+ if (cp2) {
133
+ const cp1 = closestPoint(c1, c2.pointAt(cp2.param), tol * 3);
134
+ if (cp1) {
135
+ best = measureParamPair(c1, c2, cp1.param, cp2.param);
136
+ }
137
+ }
138
+ if (best.residual > tol * 2.8)
139
+ return undefined;
140
+ const envelope = evaluateWindowEnvelope(c1, c2, buildCertificationWindow(c1, best.u1, 1), buildCertificationWindow(c2, best.u2, 1));
141
+ if (envelope.upperBound > tol * 8)
142
+ return undefined;
143
+ return {
144
+ pair: best,
145
+ envelope,
146
+ };
147
+ }
148
+ function evaluateWindowEnvelope(c1, c2, w1, w2) {
149
+ const uSamples = sampleInterval5(w1);
150
+ const vSamples = sampleInterval5(w2);
151
+ let minSample = Number.POSITIVE_INFINITY;
152
+ let maxSample = 0;
153
+ for (const a of uSamples) {
154
+ const p1 = c1.pointAt(a);
155
+ for (const b of vSamples) {
156
+ const p2 = c2.pointAt(b);
157
+ const r = p1.distanceTo(p2);
158
+ if (r < minSample)
159
+ minSample = r;
160
+ if (r > maxSample)
161
+ maxSample = r;
162
+ }
163
+ }
164
+ const half1 = 0.5 * (w1.end - w1.start);
165
+ const half2 = 0.5 * (w2.end - w2.start);
166
+ const l1 = maxTangentNorm(c1, w1);
167
+ const l2 = maxTangentNorm(c2, w2);
168
+ const drift = l1 * half1 + l2 * half2;
169
+ return {
170
+ lowerBound: Math.max(0, minSample - drift),
171
+ upperBound: maxSample + drift,
172
+ minSample,
173
+ maxSample,
174
+ };
175
+ }
176
+ function buildCertificationWindow(curve, u, scale) {
177
+ const range = curve.getRange();
178
+ const span = Math.max(range.length(), Precision.CURVE_PARAM_EPS);
179
+ const half = Math.max(Precision.CURVE_PARAM_EPS * 16, span * 1e-4 * scale);
180
+ const start = Math.max(range.start, u - half);
181
+ const end = Math.min(range.end, u + half);
182
+ if (end <= start + Precision.CURVE_PARAM_EPS) {
183
+ const clamped = range.clamp(u);
184
+ return new Interval(clamped, clamped);
185
+ }
186
+ return new Interval(start, end);
187
+ }
188
+ function sampleInterval3(x) {
189
+ if (x.end - x.start <= Precision.CURVE_PARAM_EPS) {
190
+ return [x.start];
191
+ }
192
+ return [x.start, 0.5 * (x.start + x.end), x.end];
193
+ }
194
+ function sampleInterval5(x) {
195
+ if (x.end - x.start <= Precision.CURVE_PARAM_EPS) {
196
+ return [x.start];
197
+ }
198
+ const a = x.start;
199
+ const b = x.end;
200
+ return [
201
+ a,
202
+ a + 0.25 * (b - a),
203
+ a + 0.5 * (b - a),
204
+ a + 0.75 * (b - a),
205
+ b,
206
+ ];
207
+ }
208
+ function maxTangentNorm(curve, x) {
209
+ const samples = sampleInterval3(x);
210
+ let ret = Precision.CURVE_NEWTON_EPS;
211
+ for (const u of samples) {
212
+ const n = curve.tangentAt(u).len();
213
+ if (Number.isFinite(n))
214
+ ret = Math.max(ret, n);
215
+ }
216
+ return ret;
217
+ }
218
+ function isNearDegenerate(c1, c2, u1, u2) {
219
+ const t1 = c1.tangentAt(u1);
220
+ const t2 = c2.tangentAt(u2);
221
+ const n1 = t1.len();
222
+ const n2 = t2.len();
223
+ if (n1 <= Precision.CURVE_NEWTON_EPS || n2 <= Precision.CURVE_NEWTON_EPS)
224
+ return true;
225
+ const sin = Math.abs(t1.cross(t2)) / (n1 * n2);
226
+ return sin <= 1e-3;
227
+ }
228
+ function shrinkWindowAroundParam(curve, window, center, factor) {
229
+ const range = curve.getRange();
230
+ const half = Math.max(Precision.CURVE_PARAM_EPS * 8, 0.5 * window.length() * factor);
231
+ const u = range.clamp(center);
232
+ const start = Math.max(range.start, u - half);
233
+ const end = Math.min(range.end, u + half);
234
+ if (end <= start + Precision.CURVE_PARAM_EPS) {
235
+ return new Interval(u, u);
236
+ }
237
+ return new Interval(start, end);
238
+ }
@@ -0,0 +1,29 @@
1
+ import { Interval } from '../../curves/interval';
2
+ import type { Curve2 } from '../../curves/curve2';
3
+ export type ClipPointSeed = {
4
+ u1: number;
5
+ u2: number;
6
+ };
7
+ export type ClipOverlapSeed = {
8
+ range1: Interval;
9
+ range2: Interval;
10
+ };
11
+ export type IntervalClipOptions = {
12
+ pointTol: number;
13
+ seedParamTol: number;
14
+ maxDepth: number;
15
+ maxNodes: number;
16
+ pointSeedLimit: number;
17
+ overlapSeedLimit: number;
18
+ };
19
+ export type IntervalClipDiagnostics = {
20
+ nodesVisited: number;
21
+ aborted: boolean;
22
+ };
23
+ export type IntervalClipResult = {
24
+ pointSeeds: ClipPointSeed[];
25
+ overlapSeeds: ClipOverlapSeed[];
26
+ diagnostics: IntervalClipDiagnostics;
27
+ };
28
+ export declare function collectIntervalClipSeeds(c1: Curve2, c2: Curve2, options: IntervalClipOptions): IntervalClipResult;
29
+ //# sourceMappingURL=interval_clipping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interval_clipping.d.ts","sourceRoot":"","sources":["../../../src/intersections/internal/interval_clipping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAKjD,MAAM,MAAM,aAAa,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,MAAM,EAAE,QAAQ,CAAA;IAChB,MAAM,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,YAAY,EAAE,eAAe,EAAE,CAAA;IAC/B,WAAW,EAAE,uBAAuB,CAAA;CACvC,CAAA;AAOD,wBAAgB,wBAAwB,CACpC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,mBAAmB,GAC7B,kBAAkB,CAoHpB"}
@@ -0,0 +1,123 @@
1
+ import { Interval } from '../../curves/interval';
2
+ import { Precision } from '../../utils/precision';
3
+ import { intersectSegments, lerp, makeSegment, segmentBoxesMayIntersect, segmentDistance } from './segment';
4
+ export function collectIntervalClipSeeds(c1, c2, options) {
5
+ const r1 = c1.getRange();
6
+ const r2 = c2.getRange();
7
+ if (r1.length() <= Precision.CURVE_PARAM_EPS || r2.length() <= Precision.CURVE_PARAM_EPS) {
8
+ return {
9
+ pointSeeds: [],
10
+ overlapSeeds: [],
11
+ diagnostics: { nodesVisited: 0, aborted: false },
12
+ };
13
+ }
14
+ const pointSeeds = [];
15
+ const overlapSeeds = [];
16
+ const state = {
17
+ nodes: 0,
18
+ aborted: false,
19
+ };
20
+ const cache1 = new Map();
21
+ const cache2 = new Map();
22
+ const getPoint = (curve, cache, u) => {
23
+ const key = u.toPrecision(15);
24
+ const found = cache.get(key);
25
+ if (found)
26
+ return found;
27
+ const p = curve.pointAt(u);
28
+ cache.set(key, p);
29
+ return p;
30
+ };
31
+ const recurse = (u0, u1, v0, v1, depth) => {
32
+ if (state.aborted)
33
+ return;
34
+ if (state.nodes++ > options.maxNodes) {
35
+ state.aborted = true;
36
+ return;
37
+ }
38
+ if (u1 - u0 <= Precision.CURVE_PARAM_EPS && v1 - v0 <= Precision.CURVE_PARAM_EPS)
39
+ return;
40
+ const p10 = getPoint(c1, cache1, u0);
41
+ const p11 = getPoint(c1, cache1, u1);
42
+ const p20 = getPoint(c2, cache2, v0);
43
+ const p21 = getPoint(c2, cache2, v1);
44
+ const s1 = makeSegment(p10, p11);
45
+ const s2 = makeSegment(p20, p21);
46
+ if (!segmentBoxesMayIntersect(s1, s2, options.pointTol))
47
+ return;
48
+ const hit = intersectSegments(s1, s2);
49
+ if (hit.kind === 'point') {
50
+ addPointSeed(pointSeeds, lerp(u0, u1, hit.t1), lerp(v0, v1, hit.t2), options.seedParamTol, options.pointSeedLimit);
51
+ }
52
+ else if (hit.kind === 'overlap') {
53
+ addOverlapSeed(overlapSeeds, {
54
+ range1: new Interval(lerp(u0, u1, hit.t1s), lerp(u0, u1, hit.t1e)),
55
+ range2: new Interval(lerp(v0, v1, hit.t2s), lerp(v0, v1, hit.t2e)),
56
+ }, options.overlapSeedLimit);
57
+ addPointSeed(pointSeeds, 0.5 * (lerp(u0, u1, hit.t1s) + lerp(u0, u1, hit.t1e)), 0.5 * (lerp(v0, v1, hit.t2s) + lerp(v0, v1, hit.t2e)), options.seedParamTol, options.pointSeedLimit);
58
+ }
59
+ const dist = segmentDistance(s1, s2);
60
+ const uSpan = u1 - u0;
61
+ const vSpan = v1 - v0;
62
+ const paramTiny = uSpan <= Precision.CURVE_PARAM_EPS * 32 && vSpan <= Precision.CURVE_PARAM_EPS * 32;
63
+ const geomTiny = Math.max(s1.len, s2.len) <= options.pointTol * 1.25;
64
+ if (depth >= options.maxDepth || paramTiny || geomTiny) {
65
+ if (dist <= options.pointTol * 1.75) {
66
+ addPointSeed(pointSeeds, 0.5 * (u0 + u1), 0.5 * (v0 + v1), options.seedParamTol, options.pointSeedLimit);
67
+ }
68
+ return;
69
+ }
70
+ if (dist > Math.max(s1.len, s2.len) + options.pointTol * 3)
71
+ return;
72
+ const splitU = s1.len >= s2.len;
73
+ if (splitU) {
74
+ const um = 0.5 * (u0 + u1);
75
+ if (um <= u0 + Precision.CURVE_PARAM_EPS || um >= u1 - Precision.CURVE_PARAM_EPS)
76
+ return;
77
+ recurse(u0, um, v0, v1, depth + 1);
78
+ recurse(um, u1, v0, v1, depth + 1);
79
+ return;
80
+ }
81
+ const vm = 0.5 * (v0 + v1);
82
+ if (vm <= v0 + Precision.CURVE_PARAM_EPS || vm >= v1 - Precision.CURVE_PARAM_EPS)
83
+ return;
84
+ recurse(u0, u1, v0, vm, depth + 1);
85
+ recurse(u0, u1, vm, v1, depth + 1);
86
+ };
87
+ recurse(r1.start, r1.end, r2.start, r2.end, 0);
88
+ return {
89
+ pointSeeds,
90
+ overlapSeeds,
91
+ diagnostics: {
92
+ nodesVisited: state.nodes,
93
+ aborted: state.aborted,
94
+ },
95
+ };
96
+ }
97
+ function addPointSeed(seeds, u1, u2, paramTol, limit) {
98
+ if (limit > 0 && seeds.length >= limit)
99
+ return;
100
+ for (const seed of seeds) {
101
+ if (Math.abs(seed.u1 - u1) <= paramTol && Math.abs(seed.u2 - u2) <= paramTol) {
102
+ return;
103
+ }
104
+ }
105
+ seeds.push({ u1, u2 });
106
+ }
107
+ function addOverlapSeed(seeds, next, limit) {
108
+ for (let i = 0; i < seeds.length; i++) {
109
+ const cur = seeds[i];
110
+ const overlap1 = next.range1.intersect(cur.range1, Precision.CURVE_PARAM_EPS * 8);
111
+ const overlap2 = next.range2.intersect(cur.range2, Precision.CURVE_PARAM_EPS * 8);
112
+ if (overlap1.length === 0 || overlap2.length === 0)
113
+ continue;
114
+ seeds[i] = {
115
+ range1: new Interval(Math.min(cur.range1.start, next.range1.start), Math.max(cur.range1.end, next.range1.end)),
116
+ range2: new Interval(Math.min(cur.range2.start, next.range2.start), Math.max(cur.range2.end, next.range2.end)),
117
+ };
118
+ return;
119
+ }
120
+ if (limit > 0 && seeds.length >= limit)
121
+ return;
122
+ seeds.push(next);
123
+ }
@@ -0,0 +1,4 @@
1
+ import type { Curve2 } from '../../curves/curve2';
2
+ import type { CurveKind } from './pair';
3
+ export declare function getCurveKind(curve: Curve2): CurveKind;
4
+ //# sourceMappingURL=kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../../../src/intersections/internal/kind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAQrD"}
@@ -0,0 +1,16 @@
1
+ import { MathError } from '../../utils/math_error';
2
+ export function getCurveKind(curve) {
3
+ if (curve.isLine())
4
+ return 'line';
5
+ if (curve.isCircle())
6
+ return 'circle';
7
+ if (curve.isArc())
8
+ return 'arc';
9
+ if (curve.isEllipse())
10
+ return 'ellipse';
11
+ if (curve.isEllipseArc())
12
+ return 'ellipseArc';
13
+ if (curve.isBSpline())
14
+ return 'bspline';
15
+ MathError.throw(`CurveX: unsupported curve type ${curve.getType()}`);
16
+ }
@@ -0,0 +1,9 @@
1
+ export type CurveKind = 'line' | 'circle' | 'arc' | 'ellipse' | 'ellipseArc' | 'bspline';
2
+ export type PairKey = `${CurveKind}|${CurveKind}`;
3
+ type PairNormalizeResult = {
4
+ key: PairKey;
5
+ swapped: boolean;
6
+ };
7
+ export declare function normalizePair(k1: CurveKind, k2: CurveKind): PairNormalizeResult;
8
+ export {};
9
+ //# sourceMappingURL=pair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pair.d.ts","sourceRoot":"","sources":["../../../src/intersections/internal/pair.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAA;AAExF,MAAM,MAAM,OAAO,GAAG,GAAG,SAAS,IAAI,SAAS,EAAE,CAAA;AAEjD,KAAK,mBAAmB,GAAG;IACvB,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAWD,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,GAAG,mBAAmB,CAK/E"}
@@ -0,0 +1,14 @@
1
+ const kindOrder = {
2
+ line: 0,
3
+ circle: 1,
4
+ arc: 2,
5
+ ellipse: 3,
6
+ ellipseArc: 4,
7
+ bspline: 5,
8
+ };
9
+ export function normalizePair(k1, k2) {
10
+ if (kindOrder[k1] <= kindOrder[k2]) {
11
+ return { key: `${k1}|${k2}`, swapped: false };
12
+ }
13
+ return { key: `${k2}|${k1}`, swapped: true };
14
+ }
@@ -0,0 +1,20 @@
1
+ import { Interval } from '../../curves/interval';
2
+ import type { CurveXInfo } from '../types';
3
+ export type CurveXQuality = {
4
+ rawCount: number;
5
+ uniqueCount: number;
6
+ overlapCount: number;
7
+ uniquePointCount: number;
8
+ duplicatePointCount: number;
9
+ };
10
+ export declare function swapCurveXInfos(items: CurveXInfo[]): {
11
+ point: import("../..").Vec2;
12
+ u1: number;
13
+ u2: number;
14
+ isOverlap: boolean;
15
+ range1: Interval | undefined;
16
+ range2: Interval | undefined;
17
+ }[];
18
+ export declare function postprocessCurveXInfos(items: CurveXInfo[], pointTol?: number): CurveXInfo[];
19
+ export declare function analyzeCurveXInfosQuality(items: CurveXInfo[], pointTol?: number): CurveXQuality;
20
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../src/intersections/internal/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;IACxB,mBAAmB,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE;;;;;;;IASlD;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,QAAQ,SAAiC,gBAIpG;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,QAAQ,SAAiC,GAAG,aAAa,CAmBvH"}