@automovie/recovery 0.1.0 → 0.2.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 (41) hide show
  1. package/lib/curves/AutoMovieRecoveryCompactApproximation.d.ts +125 -0
  2. package/lib/curves/AutoMovieRecoveryCompactApproximation.js +62 -0
  3. package/lib/curves/AutoMovieRecoveryCompactApproximation.js.map +1 -0
  4. package/lib/curves/AutoMovieRecoveryConicApproximation.d.ts +218 -0
  5. package/lib/curves/AutoMovieRecoveryConicApproximation.js +113 -0
  6. package/lib/curves/AutoMovieRecoveryConicApproximation.js.map +1 -0
  7. package/lib/curves/approximateAutoMovieRecoveryCompactCurves.d.ts +30 -0
  8. package/lib/curves/approximateAutoMovieRecoveryCompactCurves.js +303 -0
  9. package/lib/curves/approximateAutoMovieRecoveryCompactCurves.js.map +1 -0
  10. package/lib/curves/approximateAutoMovieRecoveryConicsAhn.d.ts +39 -0
  11. package/lib/curves/approximateAutoMovieRecoveryConicsAhn.js +289 -0
  12. package/lib/curves/approximateAutoMovieRecoveryConicsAhn.js.map +1 -0
  13. package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.d.ts +32 -0
  14. package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.js +350 -0
  15. package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.js.map +1 -0
  16. package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.d.ts +29 -0
  17. package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.js +77 -0
  18. package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.js.map +1 -0
  19. package/lib/curves/index.d.ts +5 -0
  20. package/lib/curves/index.js +5 -0
  21. package/lib/curves/index.js.map +1 -1
  22. package/lib/internal/GhoshConicApproximationBalance.d.ts +25 -0
  23. package/lib/internal/GhoshConicApproximationBalance.js +177 -0
  24. package/lib/internal/GhoshConicApproximationBalance.js.map +1 -0
  25. package/lib/internal/GhoshConicApproximationDisplacement.d.ts +23 -0
  26. package/lib/internal/GhoshConicApproximationDisplacement.js +77 -0
  27. package/lib/internal/GhoshConicApproximationDisplacement.js.map +1 -0
  28. package/lib/internal/index.d.ts +2 -0
  29. package/lib/internal/index.js +2 -0
  30. package/lib/internal/index.js.map +1 -1
  31. package/package.json +6 -6
  32. package/src/curves/AutoMovieRecoveryCompactApproximation.ts +149 -0
  33. package/src/curves/AutoMovieRecoveryConicApproximation.ts +282 -0
  34. package/src/curves/approximateAutoMovieRecoveryCompactCurves.ts +285 -0
  35. package/src/curves/approximateAutoMovieRecoveryConicsAhn.ts +315 -0
  36. package/src/curves/approximateAutoMovieRecoveryConicsGhosh.ts +444 -0
  37. package/src/curves/findAutoMovieRecoveryCubicCriticalParameters.ts +76 -0
  38. package/src/curves/index.ts +5 -0
  39. package/src/internal/GhoshConicApproximationBalance.ts +184 -0
  40. package/src/internal/GhoshConicApproximationDisplacement.ts +83 -0
  41. package/src/internal/index.ts +2 -0
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GhoshConicApproximationBalance = GhoshConicApproximationBalance;
4
+ const GhoshConicApproximationDisplacement_1 = require("./GhoshConicApproximationDisplacement");
5
+ /**
6
+ * Balance a bitangent conic's signed normal extrema with numerical exchange.
7
+ * Initial source nodes bracket witnessed displacement peaks. Golden-section
8
+ * refinement locates each such peak between nodes, then its source coordinate
9
+ * joins the coefficient bisection and the two signed lobes are rebalanced.
10
+ * This implements the extrema/equioscillation criterion of Ghosh et al. (2007),
11
+ * sections 3.2–3.3 and 6, without treating a fixed grid maximum as a supremum.
12
+ *
13
+ * The returned tuple is [rho, refined maximum displacement in millimetres].
14
+ * Finite peak brackets still do not certify that an arbitrary callback has no
15
+ * unwitnessed extrema; exhausted exchange or an invalid normal returns absent.
16
+ * Source endpoints have displacement zero by exact endpoint interpolation.
17
+ *
18
+ * @evidence contracts/development/common.md#meaningful-documentation Explains extrema exchange, compactified weight, physical error, endpoint zeros, finite-bracket limits and absent-result effects.
19
+ * @evidence contracts/development/implementation.md#principled-implementation Ghosh's equioscillation minimizes opposing signed normal lobes; scalar bisection is alternated with bracketed extremum optimization instead of accepting sampled maxima. Golden-section convergence stops at binary64 parameter resolution and invalid normal graphs remain unsupported.
20
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The helper owns weight/extremum search while its caller owns differential admission, tangent geometry, independent validation and interval coverage.
21
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No sample-count increase, inflated fit tolerance, input smoothing, missing-domain bridge or fixture-specific coefficient is used. New fitting nodes are located extrema and a roundoff allowance only controls search convergence.
22
+ * @evidence contracts/development/implementation.md#efficient-algorithms For E bounded exchanges, N initial/located extrema and G golden iterations, time is O(E*(32*N+N*G)); the caller's depth bounds E and binary64 precision bounds G. Source-coordinate caching avoids repeated callbacks at identical parameters.
23
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work A call-local parameter map reuses source points/normals throughout weight iterations and peak refinement; source identity and interval are fixed for the call.
24
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Fit nodes and cached coordinates are bounded by exchanges and golden iterations, discarded on return, and never appear in the returned coefficients.
25
+ */
26
+ function GhoshConicApproximationBalance(sample, domain, bounds, maximumExchanges, roundoffMm) {
27
+ const cache = new Map();
28
+ const witnesses = [];
29
+ const ratio = (Math.sqrt(5) - 1) / 2;
30
+ const goldenIterations = Math.ceil(53 / Math.log2(1 / ratio));
31
+ const parameterRoundoff = 128 *
32
+ Number.EPSILON *
33
+ Math.max(Math.abs(domain[0]), Math.abs(domain[1]), domain[1] - domain[0]);
34
+ /** Reuse deterministic borrowed callbacks, retaining only call-local snapshots. */
35
+ function coordinate(t) {
36
+ const existing = cache.get(t);
37
+ if (existing !== undefined)
38
+ return existing;
39
+ const value = sample(t);
40
+ if (value !== undefined)
41
+ cache.set(t, value);
42
+ return value;
43
+ }
44
+ /** Every candidate uses the same normal graph and triangle-branch admission. */
45
+ function observe(t, rho) {
46
+ const value = coordinate(t);
47
+ return value === undefined ? undefined : (0, GhoshConicApproximationDisplacement_1.GhoshConicApproximationDisplacement)(value, rho);
48
+ }
49
+ /** A signed-lobe sum vanishes precisely at the witnessed equioscillation. */
50
+ function imbalance(rho) {
51
+ let positive = 0;
52
+ let negative = 0;
53
+ for (const witness of witnesses) {
54
+ const d = (0, GhoshConicApproximationDisplacement_1.GhoshConicApproximationDisplacement)(witness.coordinate, rho);
55
+ if (d === undefined)
56
+ return undefined;
57
+ positive = Math.max(positive, d);
58
+ negative = Math.min(negative, d);
59
+ }
60
+ return [positive + negative, Math.max(positive, -negative)];
61
+ }
62
+ /** Refine an observed local absolute maximum without increasing a fixed grid. */
63
+ function peak(a, center, b, rho) {
64
+ let left = a.t;
65
+ let right = b.t;
66
+ let x = right - ratio * (right - left);
67
+ let y = left + ratio * (right - left);
68
+ let dx = observe(x, rho);
69
+ let dy = observe(y, rho);
70
+ if (dx === undefined || dy === undefined)
71
+ return undefined;
72
+ let best = center;
73
+ for (let iteration = 0; iteration < goldenIterations; ++iteration) {
74
+ if (Math.abs(dx) > Math.abs(best.d))
75
+ best = { t: x, d: dx };
76
+ if (Math.abs(dy) > Math.abs(best.d))
77
+ best = { t: y, d: dy };
78
+ if (right - left <= parameterRoundoff)
79
+ break;
80
+ if (Math.abs(dx) < Math.abs(dy)) {
81
+ left = x;
82
+ x = y;
83
+ dx = dy;
84
+ y = left + ratio * (right - left);
85
+ dy = observe(y, rho);
86
+ if (dy === undefined)
87
+ return undefined;
88
+ }
89
+ else {
90
+ right = y;
91
+ y = x;
92
+ dy = dx;
93
+ x = right - ratio * (right - left);
94
+ dx = observe(x, rho);
95
+ if (dx === undefined)
96
+ return undefined;
97
+ }
98
+ }
99
+ return best;
100
+ }
101
+ for (let i = 1; i < 32; ++i) {
102
+ const t = domain[0] + ((domain[1] - domain[0]) * i) / 32;
103
+ const value = coordinate(t);
104
+ if (value === undefined)
105
+ return undefined;
106
+ witnesses.push({ t, coordinate: value });
107
+ }
108
+ for (let exchange = 0; exchange < maximumExchanges; ++exchange) {
109
+ let left = bounds[0];
110
+ let right = bounds[1];
111
+ const el = imbalance(left);
112
+ const er = imbalance(right);
113
+ if (el === undefined || er === undefined)
114
+ return undefined;
115
+ const numericalConic = Math.max(el[1], er[1]) <= roundoffMm;
116
+ if (!numericalConic && el[0] * er[0] > 0)
117
+ return undefined;
118
+ let rho = (left + right) / 2;
119
+ for (let iteration = 0; !numericalConic && iteration < 32; ++iteration) {
120
+ rho = (left + right) / 2;
121
+ const error = imbalance(rho);
122
+ if (error === undefined)
123
+ return undefined;
124
+ if (error[0] * el[0] > 0)
125
+ left = rho;
126
+ else
127
+ right = rho;
128
+ }
129
+ const measured = imbalance(rho);
130
+ if (measured === undefined)
131
+ return undefined;
132
+ if (measured[1] <= roundoffMm)
133
+ return [rho, measured[1]];
134
+ witnesses.sort((a, b) => a.t - b.t);
135
+ const observations = [{ t: domain[0], d: 0 }];
136
+ for (const witness of witnesses) {
137
+ const d = (0, GhoshConicApproximationDisplacement_1.GhoshConicApproximationDisplacement)(witness.coordinate, rho);
138
+ if (d === undefined)
139
+ return undefined;
140
+ observations.push({ t: witness.t, d });
141
+ }
142
+ observations.push({ t: domain[1], d: 0 });
143
+ let maximum = measured[1];
144
+ const located = [];
145
+ for (let i = 1; i + 1 < observations.length; ++i) {
146
+ const before = observations[i - 1];
147
+ const middle = observations[i];
148
+ const after = observations[i + 1];
149
+ if (Math.abs(middle.d) >= Math.abs(before.d) &&
150
+ Math.abs(middle.d) >= Math.abs(after.d) &&
151
+ (Math.abs(middle.d) > Math.abs(before.d) ||
152
+ Math.abs(middle.d) > Math.abs(after.d))) {
153
+ const found = peak(before, middle, after, rho);
154
+ if (found === undefined)
155
+ return undefined;
156
+ located.push(found);
157
+ maximum = Math.max(maximum, Math.abs(found.d));
158
+ }
159
+ }
160
+ if (maximum <= measured[1] + roundoffMm)
161
+ return [rho, maximum];
162
+ let added = false;
163
+ for (const found of located) {
164
+ if (witnesses.some((witness) => witness.t === found.t))
165
+ continue;
166
+ const value = coordinate(found.t);
167
+ if (value === undefined)
168
+ return undefined;
169
+ witnesses.push({ t: found.t, coordinate: value });
170
+ added = true;
171
+ }
172
+ if (!added)
173
+ return undefined;
174
+ }
175
+ return undefined;
176
+ }
177
+ //# sourceMappingURL=GhoshConicApproximationBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GhoshConicApproximationBalance.js","sourceRoot":"","sources":["../../src/internal/GhoshConicApproximationBalance.ts"],"names":[],"mappings":";;;AAAA,+FAA4G;AAE5G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wCACE,MAEwE,EACxE,MAAiC,EACjC,MAAiC,EACjC,gBAAwB,EACxB,UAAkB;IAclB,MAAM,KAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;IACjD,MAAM,SAAS,GAAc,EAAE,CAAC;IAChC,MAAM,KAAK,GAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,gBAAgB,GAAW,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACtE,MAAM,iBAAiB,GACrB,GAAG;QACH,MAAM,CAAC,OAAO;QACd,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5E,mFAAmF;IACnF,SAAS,UAAU,CAAC,CAAS;QAC3B,MAAM,QAAQ,GAA2B,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACtD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QAC5C,MAAM,KAAK,GAA2B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AC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACzC,CAAC;gBACD,MAAM,KAAK,GAA4B,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;gBACxE,IAAI,KAAK,KAAK,SAAS;oBAAE,OAAO,SAAS,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACpB,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QACD,IAAI,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU;YAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC/D,IAAI,KAAK,GAAY,KAAK,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAgB,EAAW,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;gBACtE,SAAS;YACX,MAAM,KAAK,GAA2B,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1D,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAC1C,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;YAClD,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QACD,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;IAC/B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Intersect a Euclidean unit normal with a compactified bitangent conic family.
3
+ * The barycentric point and normal use the endpoint tangent triangle; normal
4
+ * coordinates have inverse-millimetre units. For rho=w/(1+w), the implicit
5
+ * conic is (1-rho)^2*l1^2-4*rho^2*l0*l2=0. At rho=1 this is the union of the
6
+ * triangle's two tangent edges, used only as a boundary search limit.
7
+ *
8
+ * A finite normal displacement is returned only for a unique intersection in
9
+ * the positive tangent triangle. Two distinct valid roots remain unsupported;
10
+ * a double algebraic root is one geometric intersection. No shape is emitted.
11
+ *
12
+ * @evidence contracts/development/common.md#meaningful-documentation States barycentric units, compactified conic equation, degenerate search limit, unique-root contract and absent geometry output.
13
+ * @evidence contracts/development/implementation.md#principled-implementation The rational quadratic's barycentric implicit equation is divided by (1+w)^2 before taking its w-to-infinity limit. Stable quadratic roots and determinant-roundoff bounds evaluate the original normal intersection without moving source points.
14
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure This helper owns only normal/conic arithmetic so the public fitter owns differential admission, search and coverage.
15
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No source fallback, artificial displacement, tangent replacement or merged distinct normal intersections is used. Roundoff tolerances scale with their actual arithmetic terms.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms One quadratic, at most two candidate roots and three barycentric tests have constant time and space.
17
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Compactified factors and normalized coefficients are computed once and reused for root and triangle admission.
18
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The synchronous scalar operation retains no coordinates, callback, state or resources after return.
19
+ */
20
+ export declare function GhoshConicApproximationDisplacement(coordinate: {
21
+ value: readonly number[];
22
+ normal: readonly number[];
23
+ }, rho: number): number | undefined;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GhoshConicApproximationDisplacement = GhoshConicApproximationDisplacement;
4
+ /**
5
+ * Intersect a Euclidean unit normal with a compactified bitangent conic family.
6
+ * The barycentric point and normal use the endpoint tangent triangle; normal
7
+ * coordinates have inverse-millimetre units. For rho=w/(1+w), the implicit
8
+ * conic is (1-rho)^2*l1^2-4*rho^2*l0*l2=0. At rho=1 this is the union of the
9
+ * triangle's two tangent edges, used only as a boundary search limit.
10
+ *
11
+ * A finite normal displacement is returned only for a unique intersection in
12
+ * the positive tangent triangle. Two distinct valid roots remain unsupported;
13
+ * a double algebraic root is one geometric intersection. No shape is emitted.
14
+ *
15
+ * @evidence contracts/development/common.md#meaningful-documentation States barycentric units, compactified conic equation, degenerate search limit, unique-root contract and absent geometry output.
16
+ * @evidence contracts/development/implementation.md#principled-implementation The rational quadratic's barycentric implicit equation is divided by (1+w)^2 before taking its w-to-infinity limit. Stable quadratic roots and determinant-roundoff bounds evaluate the original normal intersection without moving source points.
17
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure This helper owns only normal/conic arithmetic so the public fitter owns differential admission, search and coverage.
18
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No source fallback, artificial displacement, tangent replacement or merged distinct normal intersections is used. Roundoff tolerances scale with their actual arithmetic terms.
19
+ * @evidence contracts/development/implementation.md#efficient-algorithms One quadratic, at most two candidate roots and three barycentric tests have constant time and space.
20
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Compactified factors and normalized coefficients are computed once and reused for root and triangle admission.
21
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The synchronous scalar operation retains no coordinates, callback, state or resources after return.
22
+ */
23
+ function GhoshConicApproximationDisplacement(coordinate, rho) {
24
+ const l = coordinate.value;
25
+ const n = coordinate.normal;
26
+ const conic = (1 - rho) ** 2;
27
+ const triangle = 4 * rho ** 2;
28
+ const normalScale = Math.max(Math.abs(n[0]), Math.abs(n[1]), Math.abs(n[2]));
29
+ if (normalScale === 0 || !Number.isFinite(normalScale))
30
+ return undefined;
31
+ // Scale d=L*t so all quadratic coefficients are dimensionless. This keeps
32
+ // coefficient admission unchanged when the caller changes physical units.
33
+ const length = 1 / normalScale;
34
+ const m0 = n[0] * length;
35
+ const m1 = n[1] * length;
36
+ const m2 = n[2] * length;
37
+ const a1 = conic * m1 ** 2;
38
+ const a2 = triangle * m0 * m2;
39
+ const b1 = 2 * conic * l[1] * m1;
40
+ const b2 = triangle * (l[0] * m2 + l[2] * m0);
41
+ const c1 = conic * l[1] ** 2;
42
+ const c2 = triangle * l[0] * l[2];
43
+ const a = a1 - a2;
44
+ const b = b1 - b2;
45
+ const c = c1 - c2;
46
+ const roundoff = 128 * Number.EPSILON;
47
+ let roots;
48
+ if (Math.abs(a) <= roundoff * (Math.abs(a1) + Math.abs(a2))) {
49
+ if (Math.abs(b) <= roundoff * (Math.abs(b1) + Math.abs(b2)))
50
+ return Math.abs(c) <= roundoff * (Math.abs(c1) + Math.abs(c2))
51
+ ? 0
52
+ : undefined;
53
+ roots = [-c / b];
54
+ }
55
+ else {
56
+ const discriminant = b * b - 4 * a * c;
57
+ const uncertainty = roundoff * (b * b + 4 * Math.abs(a * c));
58
+ if (discriminant < -uncertainty)
59
+ return undefined;
60
+ if (discriminant <= 0)
61
+ roots = [-b / (2 * a)];
62
+ else {
63
+ const stable = -0.5 * (b + (b < 0 ? -1 : 1) * Math.sqrt(discriminant));
64
+ roots = stable === 0 ? [-b / (2 * a)] : [stable / a, c / stable];
65
+ }
66
+ }
67
+ const valid = roots.filter((t) => Number.isFinite(t) &&
68
+ l.every((value, index) => {
69
+ const displacement = t * (index === 0 ? m0 : index === 1 ? m1 : m2);
70
+ return (value + displacement >=
71
+ -roundoff * (1 + Math.abs(value) + Math.abs(displacement)));
72
+ }));
73
+ if (valid.length === 2 && valid[0] === valid[1])
74
+ valid.pop();
75
+ return valid.length === 1 ? valid[0] * length : undefined;
76
+ }
77
+ //# sourceMappingURL=GhoshConicApproximationDisplacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GhoshConicApproximationDisplacement.js","sourceRoot":"","sources":["../../src/internal/GhoshConicApproximationDisplacement.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,6CACE,UAAmE,EACnE,GAAW;IAEX,MAAM,CAAC,GAAsB,UAAU,CAAC,KA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,CAAC,GAAG,EAAE,CAAC;IAC7D,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC"}
@@ -179,3 +179,5 @@ export * from "./updateRecoveryRegularization";
179
179
  export * from "./validateRecoveryContourResume";
180
180
  export * from "./validateRecoveryMapMetricRow";
181
181
  export * from "./validateRecoveryMapMetricScales";
182
+ export * from "./GhoshConicApproximationBalance";
183
+ export * from "./GhoshConicApproximationDisplacement";
@@ -195,4 +195,6 @@ __exportStar(require("./updateRecoveryRegularization"), exports);
195
195
  __exportStar(require("./validateRecoveryContourResume"), exports);
196
196
  __exportStar(require("./validateRecoveryMapMetricRow"), exports);
197
197
  __exportStar(require("./validateRecoveryMapMetricScales"), exports);
198
+ __exportStar(require("./GhoshConicApproximationBalance"), exports);
199
+ __exportStar(require("./GhoshConicApproximationDisplacement"), exports);
198
200
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,+DAA6C;AAC7C,0DAAwC;AACxC,uDAAqC;AACrC,gEAA8C;AAC9C,iEAA+C;AAC/C,2DAAyC;AACzC,yDAAuC;AACvC,kEAAgD;AAChD,oEAAkD;AAClD,qEAAmD;AACnD,oEAAkD;AAClD,oEAAkD;AAClD,mEAAiD;AACjD,kEAAgD;AAChD,sDAAoC;AACpC,kEAAgD;AAChD,0DAAwC;AACxC,uDAAqC;AACrC,0DAAwC;AACxC,iEAA+C;AAC/C,wEAAsD;AACtD,yEAAuD;AACvD,yEAAuD;AACvD,0DAAwC;AACxC,wDAAsC;AACtC,kEAAgD;AAChD,qDAAmC;AACnC,4DAA0C;AAC1C,2DAAyC;AACzC,yDAAuC;AACvC,0DAAwC;AACxC,2DAAyC;AACzC,8DAA4C;A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DAA2C;AAC3C,mEAAiD;AACjD,kEAAgD;AAChD,iEAA+C;AAC/C,kEAAgD;AAChD,iEAA+C;AAC/C,oEAAkD;AAClD,mEAAiD;AACjD,wEAAsD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automovie/recovery",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Source-independent recovery workflows and Node artifact commands",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -28,16 +28,16 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@automovie/engine": "^0.1.0",
32
- "@automovie/interface": "^0.1.0"
31
+ "@automovie/engine": "^0.2.0",
32
+ "@automovie/interface": "^0.2.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "rimraf": "^6.0.1",
36
- "ttsc": "^0.36.3",
36
+ "ttsc": "^0.37.0",
37
37
  "typescript": "^7.0.2",
38
- "@ttsc/lint": "^0.36.3",
38
+ "@ttsc/lint": "^0.37.0",
39
39
  "@wrtnlabs/evidence": "^0.8.2",
40
- "@ttsc/evidence": "^0.36.3",
40
+ "@ttsc/evidence": "^0.37.0",
41
41
  "@types/node": "^22.19.17"
42
42
  },
43
43
  "engines": {
@@ -0,0 +1,149 @@
1
+ import { AutoMovieBernstein64 as B } from "@automovie/engine";
2
+
3
+ import { AutoMovieRecoveryConicApproximation as Conic } from "./AutoMovieRecoveryConicApproximation";
4
+
5
+ /**
6
+ * Planar coefficient-reduction experiment, independent of source meshes.
7
+ *
8
+ * @evidence contracts/development/common.md#meaningful-documentation Defines physical units, source observation knots, coefficient charts and sampled evidence limits.
9
+ * @evidence contracts/development/design.md#principled-representation Discriminated polynomial and positive rational coefficients retain domains and millimetre coordinates.
10
+ * @evidence contracts/development/design.md#minimal-and-owned-surface Recovery owns the fitter contract used by the experiment and portable tests; the existing planar source contract is reused.
11
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No specimen, baked observation, mesh fallback or global-minimum claim is represented.
12
+ */
13
+ export namespace AutoMovieRecoveryCompactApproximation {
14
+ /**
15
+ * Source knots are observation locations, not mandatory output boundaries.
16
+ * The inherited breaks alone identify actual corners that cannot be crossed.
17
+ *
18
+ * @evidence contracts/development/common.md#meaningful-documentation Separates source sampling support from immutable feature boundaries and inherits millimetre callback units.
19
+ * @evidence contracts/development/design.md#principled-representation A readonly interior knot list records piecewise source support without forcing its old representation into the result.
20
+ * @evidence contracts/development/design.md#minimal-and-owned-surface Extends the existing planar callback owner only with support needed by fitting and independent checks.
21
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No source controls or anatomy-specific measurements enter this generic contract.
22
+ */
23
+ export interface ICurve extends Conic.ICurve {
24
+ /** Every source piece boundary, strictly inside domain, for observation coverage. */
25
+ knots: readonly number[];
26
+ }
27
+
28
+ /**
29
+ * Error and finite work controls for a fixed-degree or storage-selected fit.
30
+ *
31
+ * @evidence contracts/development/common.md#meaningful-documentation States geometric tolerance, candidate degrees and distinct output, subdivision and callback budgets.
32
+ * @evidence contracts/development/design.md#principled-representation Closed degree choices prevent unsupported fitting modes; positive finite limits require runtime admission.
33
+ * @evidence contracts/development/design.md#minimal-and-owned-surface These controls are read by the current fitter and comparison consumer.
34
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No specimen preset, hidden quality mode or tolerance relaxation is supplied.
35
+ */
36
+ export interface IOptions {
37
+ /** Maximum admitted held-out correspondence discrepancy, millimetres. */
38
+ toleranceMm: number;
39
+ /** Mixed admits one conic and polynomial degrees three through five. */
40
+ degree: 3 | 4 | 5 | "mixed";
41
+ /** Maximum accepted plus unresolved leaf pieces. */
42
+ maximumPieces: number;
43
+ /** Maximum binary subdivision depth per initial chart. */
44
+ maximumDepth: number;
45
+ /** Maximum source evaluate/derivative invocations, including conic fitting. */
46
+ maximumQueries: number;
47
+ }
48
+
49
+ /**
50
+ * Source-registered polynomial or bitangent conic coefficient record.
51
+ * Polynomial u=(t-a)/(b-a); a conic's u is its own rational parameter.
52
+ *
53
+ * @evidence contracts/development/common.md#meaningful-documentation Distinguishes source registration from rational speed and identifies sampled error and millimetre controls.
54
+ * @evidence contracts/development/design.md#principled-representation The closed union requires exactly the fields for polynomial or normalized rational evaluation.
55
+ * @evidence contracts/development/design.md#minimal-and-owned-surface One union supports fitting, coefficient-only generation and storage comparison.
56
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No source evaluator or dense sample table is retained in output.
57
+ */
58
+ export type IPiece = {
59
+ /** Selects polynomial Bernstein evaluation and linear source registration. */
60
+ kind: "polynomial";
61
+ /** Actual polynomial degree; there are degree plus one planar controls. */
62
+ degree: 3 | 4 | 5;
63
+ /** Ordered original source interval, in the callback's parameter unit. */
64
+ domain: readonly [number, number];
65
+ /** Bernstein controls in the source's planar millimetre coordinate frame. */
66
+ controls: readonly Conic.Point[];
67
+ /** Largest observed fitting/held-out correspondence discrepancy, millimetres. */
68
+ maximumSampleErrorMm: number;
69
+ } | {
70
+ /** Selects rational quadratic evaluation with independent local speed. */
71
+ kind: "conic";
72
+ /** Source interval represented by this conic, without equal-speed implication. */
73
+ domain: readonly [number, number];
74
+ /** Planar millimetre endpoint, tangent intersection, endpoint coefficients. */
75
+ controls: readonly [Conic.Point, Conic.Point, Conic.Point];
76
+ /** Positive dimensionless middle weight; both endpoint weights are one. */
77
+ weight: number;
78
+ /** Largest fitting/held-out radial correspondence discrepancy, millimetres. */
79
+ maximumSampleErrorMm: number;
80
+ };
81
+
82
+ /**
83
+ * Admitted coefficients, omitted-domain status and explicit evidence scope.
84
+ *
85
+ * @evidence contracts/development/common.md#meaningful-documentation Defines completion as sampled fit coverage, not continuous error, topology or likeness certification.
86
+ * @evidence contracts/development/design.md#principled-representation The status union and immutable coefficients distinguish complete, incomplete and empty refused outputs.
87
+ * @evidence contracts/development/design.md#minimal-and-owned-surface The comparison consumes every reported measurement, including numeric storage and callback cost.
88
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts certified is always false because held-out samples do not establish continuous Hausdorff bounds.
89
+ */
90
+ export interface IResult {
91
+ /** Whether sampled fitting covered the entire requested domain, only part, or none. */
92
+ status: "complete" | "partial" | "refused";
93
+ /** Ordered admitted coefficient records; omitted domains have no fabricated piece. */
94
+ pieces: readonly IPiece[];
95
+ /** Maximum sampled discrepancy across retained pieces, millimetres; zero when empty. */
96
+ maximumSampleErrorMm: number;
97
+ /** Numeric coefficient/chart count under storedScalars' planar seam-sharing convention. */
98
+ storedScalars: number;
99
+ /** Actual source position and derivative callback invocations, including nested conic fitting. */
100
+ queries: number;
101
+ /** Representation limitations, numerical admission failures and omitted-domain reasons. */
102
+ diagnostics: readonly string[];
103
+ /** Always false: finite fitting/held-out observations are not continuous error certificates. */
104
+ certified: false;
105
+ }
106
+
107
+ /**
108
+ * Evaluate only saved coefficients at the piece's own normalized parameter.
109
+ *
110
+ * @evidence contracts/development/common.md#meaningful-documentation States normalized parameter and millimetre output, and does not borrow a source evaluator.
111
+ * @evidence contracts/development/implementation.md#principled-implementation Existing engine Bernstein evaluation and the existing rational conic quotient implement the two admitted representations.
112
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One dispatch keeps generation and fitter coefficient semantics identical.
113
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No resampling, source interpolation or fallback curve changes stored coefficients.
114
+ * @evidence contracts/development/implementation.md#efficient-algorithms Degree is at most five; two scalar Bernstein evaluations use constant bounded work and storage.
115
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Rational evaluation reuses the existing conic owner; polynomial evaluation reuses engine algebra.
116
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Temporary scalar arrays expire after each pure call; no input or handle is retained.
117
+ */
118
+ export function evaluate(piece: IPiece, u: number): Conic.Point {
119
+ if (piece.kind === "conic") return Conic.evaluate(piece, u);
120
+ return [
121
+ B.scalar(piece.controls.map((p: Conic.Point): number => p[0]), u),
122
+ B.scalar(piece.controls.map((p: Conic.Point): number => p[1]), u),
123
+ ];
124
+ }
125
+
126
+ /**
127
+ * Count the actual planar numeric representation, including chart metadata.
128
+ * Adjacent equal endpoints are counted once; corners may share position.
129
+ *
130
+ * @evidence contracts/development/common.md#meaningful-documentation Defines two coordinates per control, one degree or weight, two interval endpoints and exact shared-endpoint accounting.
131
+ * @evidence contracts/development/implementation.md#principled-implementation Direct coefficient cardinality measures stored numbers rather than output tessellation or source observation counts.
132
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The same owner supplies candidate and final representation cost.
133
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Coordinate plane reduction is not attributed to polynomial degree, and no approximate endpoint equality hides a gap.
134
+ * @evidence contracts/development/implementation.md#efficient-algorithms One pass over P pieces costs O(P) with scalar scratch only.
135
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Adjacent controls are read once per seam; no sample generation is needed.
136
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The function borrows the immutable coefficient array and retains no data after return.
137
+ */
138
+ export function storedScalars(pieces: readonly IPiece[]): number {
139
+ let total: number = 0;
140
+ let previous: Conic.Point | undefined;
141
+ for (const piece of pieces) {
142
+ total += 2 * piece.controls.length + 3;
143
+ const first: Conic.Point = piece.controls[0]!;
144
+ if (previous !== undefined && previous[0] === first[0] && previous[1] === first[1]) total -= 2;
145
+ previous = piece.controls.at(-1)!;
146
+ }
147
+ return total;
148
+ }
149
+ }