@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.
- package/lib/curves/AutoMovieRecoveryCompactApproximation.d.ts +125 -0
- package/lib/curves/AutoMovieRecoveryCompactApproximation.js +62 -0
- package/lib/curves/AutoMovieRecoveryCompactApproximation.js.map +1 -0
- package/lib/curves/AutoMovieRecoveryConicApproximation.d.ts +218 -0
- package/lib/curves/AutoMovieRecoveryConicApproximation.js +113 -0
- package/lib/curves/AutoMovieRecoveryConicApproximation.js.map +1 -0
- package/lib/curves/approximateAutoMovieRecoveryCompactCurves.d.ts +30 -0
- package/lib/curves/approximateAutoMovieRecoveryCompactCurves.js +303 -0
- package/lib/curves/approximateAutoMovieRecoveryCompactCurves.js.map +1 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsAhn.d.ts +39 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsAhn.js +289 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsAhn.js.map +1 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.d.ts +32 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.js +350 -0
- package/lib/curves/approximateAutoMovieRecoveryConicsGhosh.js.map +1 -0
- package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.d.ts +29 -0
- package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.js +77 -0
- package/lib/curves/findAutoMovieRecoveryCubicCriticalParameters.js.map +1 -0
- package/lib/curves/index.d.ts +5 -0
- package/lib/curves/index.js +5 -0
- package/lib/curves/index.js.map +1 -1
- package/lib/internal/GhoshConicApproximationBalance.d.ts +25 -0
- package/lib/internal/GhoshConicApproximationBalance.js +177 -0
- package/lib/internal/GhoshConicApproximationBalance.js.map +1 -0
- package/lib/internal/GhoshConicApproximationDisplacement.d.ts +23 -0
- package/lib/internal/GhoshConicApproximationDisplacement.js +77 -0
- package/lib/internal/GhoshConicApproximationDisplacement.js.map +1 -0
- package/lib/internal/index.d.ts +2 -0
- package/lib/internal/index.js +2 -0
- package/lib/internal/index.js.map +1 -1
- package/package.json +6 -6
- package/src/curves/AutoMovieRecoveryCompactApproximation.ts +149 -0
- package/src/curves/AutoMovieRecoveryConicApproximation.ts +282 -0
- package/src/curves/approximateAutoMovieRecoveryCompactCurves.ts +285 -0
- package/src/curves/approximateAutoMovieRecoveryConicsAhn.ts +315 -0
- package/src/curves/approximateAutoMovieRecoveryConicsGhosh.ts +444 -0
- package/src/curves/findAutoMovieRecoveryCubicCriticalParameters.ts +76 -0
- package/src/curves/index.ts +5 -0
- package/src/internal/GhoshConicApproximationBalance.ts +184 -0
- package/src/internal/GhoshConicApproximationDisplacement.ts +83 -0
- package/src/internal/index.ts +2 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.approximateAutoMovieRecoveryConicsAhn = approximateAutoMovieRecoveryConicsAhn;
|
|
4
|
+
const AutoMovieRecoveryConicApproximation_1 = require("./AutoMovieRecoveryConicApproximation");
|
|
5
|
+
/**
|
|
6
|
+
* Construct G1 bitangent conics using Ahn's control-triangle subdivision scheme.
|
|
7
|
+
*
|
|
8
|
+
* Basis: Y. J. Ahn, Conic approximation of planar curves, CAD 33 (2001),
|
|
9
|
+
* 867-872, doi:10.1016/S0010-4485(00)00110-X. The public primary abstract and
|
|
10
|
+
* section preview establish endpoint tangent interpolation, positive fullness
|
|
11
|
+
* factor and subdivision into a containing tangent triangle. The inaccessible
|
|
12
|
+
* characterization theorem and its specific error function are NOT reproduced.
|
|
13
|
+
* This explicitly labelled adaptation minimizes a sampled radial-correspondence
|
|
14
|
+
* maximum distance instead: each source point and conic point lie on the same
|
|
15
|
+
* ray from the tangent intersection. Its signed displacement increases with the
|
|
16
|
+
* weight, so bisection balances positive and negative extreme discrepancies.
|
|
17
|
+
*
|
|
18
|
+
* Samples at odd 1/32 intervals validate weights fitted on even intervals.
|
|
19
|
+
* Their distance is an observable discrepancy, never a continuous Hausdorff
|
|
20
|
+
* bound. A complete result only covers the supplied chart within this sampled
|
|
21
|
+
* criterion. Inflections and inadmissible triangles cause bisection; exhausted
|
|
22
|
+
* budgets omit unresolved intervals and return partial. Finite straight charts
|
|
23
|
+
* admit an explicit collinear quadratic, the conic's degenerate case: exactly
|
|
24
|
+
* collinear to roundoff, or, where the control triangle refuses a chart whose
|
|
25
|
+
* curvature keeps its sign, when its samples advance along its chord within
|
|
26
|
+
* toleranceMm of it (a bend below its coordinates' roundoff, between close
|
|
27
|
+
* inflections, refused at every depth otherwise). Such a primitive's end
|
|
28
|
+
* tangents are its chord's, so G1 holds there only to that tolerance's bend.
|
|
29
|
+
* Source callbacks are borrowed and must
|
|
30
|
+
* be deterministic; callback failures or nonfinite data refuse the whole call.
|
|
31
|
+
* Incident endpoint jets request exact right/left limits so supplied breaks
|
|
32
|
+
* preserve genuine source corners without finite-difference displacements.
|
|
33
|
+
*
|
|
34
|
+
* @evidence contracts/development/common.md#meaningful-documentation Documents the paper and inaccessible theorem, alternative error objective, parameterization, sampled validation, straight degeneracy within roundoff or the caller's tolerance with its G1 limit, and refusal/budget effects.
|
|
35
|
+
* @evidence contracts/development/implementation.md#principled-implementation Endpoint tangent intersection fixes the rational quadratic control triangle. Ahn's published triangle subdivision supplies the construction; this declared adaptation uses monotone radial displacement rather than claiming the unavailable characterization or certified bound. A line is the conic's degenerate case (weight one, collinear controls), admitted only where the triangle construction refuses a chart of one curvature sign whose samples lie within the approximation's own tolerance of the chord, so the result stays inside the sampled contract; its end tangents follow the chord, a stated G1 limitation.
|
|
36
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One pure operation owns admission, coefficient fitting and bounded interval subdivision, using the shared recovery contract and no source format or renderer.
|
|
37
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No source file, specimen coordinates, fallback mesh, least-squares replacement or unlabelled theorem claim enters the computation. Binary64 roundoff thresholds depend on local scale; tolerance and work budgets come from the caller, and the line admission uses that same tolerance, no constant of its own.
|
|
38
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms With L visited leaves, constant 33-point observation, 48-step scalar bisection and fixed-size validation cost O(L) time; the arc and interval population is bounded by maximumArcs and depth by maximumDepth.
|
|
39
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Each interval's points and derivatives are observed once and reused during all weight iterations; no cross-call cache assumes callback equivalence.
|
|
40
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Source callbacks and temporary arrays remain call-local; the returned coefficients contain no source samples, and no file, task or process is acquired.
|
|
41
|
+
*/
|
|
42
|
+
function approximateAutoMovieRecoveryConicsAhn(curve, options) {
|
|
43
|
+
const method = "Ahn 2001 triangle construction / sampled radial-minimax adaptation";
|
|
44
|
+
const diagnostics = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.validate(curve, options);
|
|
45
|
+
const arcs = [];
|
|
46
|
+
let queries = 0;
|
|
47
|
+
let unresolved = 0;
|
|
48
|
+
const reasons = new Map();
|
|
49
|
+
/** Assemble evidence without retaining callback closures or observed samples. */
|
|
50
|
+
const result = (status) => ({
|
|
51
|
+
method,
|
|
52
|
+
status,
|
|
53
|
+
arcs: status === "refused" ? [] : arcs,
|
|
54
|
+
diagnostics,
|
|
55
|
+
maximumSampleErrorMm: status === "refused" ? 0 : arcs.reduce((maximum, arc) => Math.max(maximum, arc.maximumSampleErrorMm), 0),
|
|
56
|
+
certified: false,
|
|
57
|
+
queries,
|
|
58
|
+
});
|
|
59
|
+
if (diagnostics.length !== 0)
|
|
60
|
+
return result("refused");
|
|
61
|
+
diagnostics.push("Numerical adaptation: Ahn's full characterization theorem/error function was unavailable; radial-correspondence samples do not certify Hausdorff distance or global minimality.");
|
|
62
|
+
/** Reject corrupt observations rather than creating substitute coordinates. */
|
|
63
|
+
const observe = (t, order, side) => {
|
|
64
|
+
++queries;
|
|
65
|
+
const p = order === undefined ? curve.evaluate(t) : curve.derivative(t, order, side);
|
|
66
|
+
if (p.length !== 2 || !Number.isFinite(p[0]) || !Number.isFinite(p[1]))
|
|
67
|
+
throw new Error(`Nonfinite source ${order === undefined ? "point" : "derivative"} at parameter ${t}.`);
|
|
68
|
+
// A source evaluator may reuse a scratch tuple. Snapshot the value now so
|
|
69
|
+
// later source queries cannot change observed points or returned controls.
|
|
70
|
+
return [p[0], p[1]];
|
|
71
|
+
};
|
|
72
|
+
/** Source-minus-origin vectors keep determinants translation invariant. */
|
|
73
|
+
const minus = (a, b) => [a[0] - b[0], a[1] - b[1]];
|
|
74
|
+
/**
|
|
75
|
+
* Attempt one admissible triangle. Undefined requests source subdivision;
|
|
76
|
+
* nonfinite observations throw and are reported at the operation boundary.
|
|
77
|
+
*/
|
|
78
|
+
const fit = (interval) => {
|
|
79
|
+
const points = [];
|
|
80
|
+
const first = observe(interval.a, 1, "right");
|
|
81
|
+
const last = observe(interval.b, 1, "left");
|
|
82
|
+
const firstNorm = Math.hypot(...first);
|
|
83
|
+
const lastNorm = Math.hypot(...last);
|
|
84
|
+
if (firstNorm === 0 || lastNorm === 0)
|
|
85
|
+
return undefined;
|
|
86
|
+
let curvatureSign = 0;
|
|
87
|
+
for (let i = 0; i <= 32; ++i) {
|
|
88
|
+
const t = interval.a + (interval.b - interval.a) * (i / 32);
|
|
89
|
+
points.push(observe(t));
|
|
90
|
+
if (i % 4 === 0) {
|
|
91
|
+
const d1 = i === 0 ? first : i === 32 ? last : observe(t, 1);
|
|
92
|
+
const d2 = observe(t, 2, i === 0 ? "right" : i === 32 ? "left" : undefined);
|
|
93
|
+
const turn = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(d1, d2);
|
|
94
|
+
const endpoint = i === 0 || i === 32;
|
|
95
|
+
const jerk = endpoint ? observe(t, 3, i === 0 ? "right" : "left") : undefined;
|
|
96
|
+
// A numerical critical root can leave a one-ulp parameter residual at
|
|
97
|
+
// the endpoint. The jerk term bounds the resulting acceleration error,
|
|
98
|
+
// including a large original parameter origin; source jets stay intact.
|
|
99
|
+
const allowance = endpoint ? 128 * Number.EPSILON * Math.hypot(...d1) *
|
|
100
|
+
(Math.hypot(...d2) + Math.max(Math.abs(t), curve.domain[1] - curve.domain[0]) * Math.hypot(...jerk))
|
|
101
|
+
: 64 * Number.EPSILON * (Math.abs(d1[0] * d2[1]) + Math.abs(d1[1] * d2[0]));
|
|
102
|
+
if (Math.abs(turn) > allowance) {
|
|
103
|
+
const sign = Math.sign(turn);
|
|
104
|
+
if (curvatureSign !== 0 && sign !== curvatureSign)
|
|
105
|
+
return undefined;
|
|
106
|
+
curvatureSign = sign;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const p0 = points[0];
|
|
111
|
+
const p2 = points[32];
|
|
112
|
+
const chord = minus(p2, p0);
|
|
113
|
+
const chordSquared = chord[0] * chord[0] + chord[1] * chord[1];
|
|
114
|
+
const length = Math.hypot(...chord);
|
|
115
|
+
if (length === 0)
|
|
116
|
+
return undefined;
|
|
117
|
+
const determinant = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(first, last);
|
|
118
|
+
const relativeRoundoff = 64 * Number.EPSILON;
|
|
119
|
+
// A conic's degenerate case, the line, within the caller's tolerance:
|
|
120
|
+
// the chart is admitted as the collinear primitive when both endpoint
|
|
121
|
+
// tangents point forward along its chord, its samples advance along the
|
|
122
|
+
// chord, and each lies within toleranceMm of it. It is tried only where
|
|
123
|
+
// the conic construction refuses, so no conic admitted otherwise changes.
|
|
124
|
+
// A chart that bends by less than its coordinates' roundoff, such as a
|
|
125
|
+
// near-flat stretch between two close inflections far from the origin,
|
|
126
|
+
// has samples either side of its chord by roundoff, outside every control
|
|
127
|
+
// triangle at every depth, while its end tangents still differ by more
|
|
128
|
+
// than roundoff; without this it was refused and bisected until the arc
|
|
129
|
+
// budget ran out. The primitive's end tangents are the chord's: they
|
|
130
|
+
// differ from the source's by its bend, which the tolerance bounds through
|
|
131
|
+
// the samples' distance from the chord, not by an angle.
|
|
132
|
+
const straight = () => {
|
|
133
|
+
if (first[0] * chord[0] + first[1] * chord[1] <= 0 || last[0] * chord[0] + last[1] * chord[1] <= 0)
|
|
134
|
+
return undefined;
|
|
135
|
+
let previous = -Infinity;
|
|
136
|
+
let maximum = 0;
|
|
137
|
+
for (const p of points) {
|
|
138
|
+
const offset = minus(p, p0);
|
|
139
|
+
const along = (offset[0] * chord[0] + offset[1] * chord[1]) / chordSquared;
|
|
140
|
+
maximum = Math.max(maximum, Math.abs(AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(offset, chord)) / length);
|
|
141
|
+
if (along < previous || along < 0 || along > 1 || maximum > options.toleranceMm)
|
|
142
|
+
return undefined;
|
|
143
|
+
previous = along;
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
domain: [interval.a, interval.b],
|
|
147
|
+
controls: [p0, [(p0[0] + p2[0]) / 2, (p0[1] + p2[1]) / 2], p2],
|
|
148
|
+
weight: 1,
|
|
149
|
+
maximumSampleErrorMm: maximum,
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
// Parallel tangents admit a line only when the entire sampled chart and
|
|
153
|
+
// both forward endpoint tangents are collinear to binary64 roundoff, or
|
|
154
|
+
// within the tolerance of its chord (`straight`).
|
|
155
|
+
if (Math.abs(determinant) <= relativeRoundoff * firstNorm * lastNorm) {
|
|
156
|
+
const scale = Math.max(length, ...points.map((p) => AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.distance(p, p0)));
|
|
157
|
+
const allowance = relativeRoundoff * scale;
|
|
158
|
+
if (first[0] * chord[0] + first[1] * chord[1] <= 0 ||
|
|
159
|
+
last[0] * chord[0] + last[1] * chord[1] <= 0 ||
|
|
160
|
+
Math.abs(AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(first, chord)) > relativeRoundoff * firstNorm * length ||
|
|
161
|
+
Math.abs(AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(last, chord)) > relativeRoundoff * lastNorm * length)
|
|
162
|
+
return straight();
|
|
163
|
+
let previous = -Infinity;
|
|
164
|
+
let maximum = 0;
|
|
165
|
+
for (const p of points) {
|
|
166
|
+
const offset = minus(p, p0);
|
|
167
|
+
const along = (offset[0] * chord[0] + offset[1] * chord[1]) / chordSquared;
|
|
168
|
+
maximum = Math.max(maximum, Math.abs(AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(offset, chord)) / length);
|
|
169
|
+
if (along < previous || along < 0 || along > 1 || maximum > allowance)
|
|
170
|
+
return straight();
|
|
171
|
+
previous = along;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
domain: [interval.a, interval.b],
|
|
175
|
+
controls: [p0, [(p0[0] + p2[0]) / 2, (p0[1] + p2[1]) / 2], p2],
|
|
176
|
+
weight: 1,
|
|
177
|
+
maximumSampleErrorMm: maximum,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// Endpoint tangents must meet forward from the start and backward from
|
|
181
|
+
// the end, otherwise positive-weight coefficients cannot follow the arc.
|
|
182
|
+
const startScale = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(chord, last) / determinant;
|
|
183
|
+
const endScale = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(chord, first) / determinant;
|
|
184
|
+
if (startScale <= 0 || endScale >= 0)
|
|
185
|
+
return straight();
|
|
186
|
+
const p1 = [p0[0] + startScale * first[0], p0[1] + startScale * first[1]];
|
|
187
|
+
if (!p1.every(Number.isFinite))
|
|
188
|
+
return straight();
|
|
189
|
+
const side = minus(p1, p0);
|
|
190
|
+
const area = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(side, chord);
|
|
191
|
+
if (area === 0 || !Number.isFinite(area))
|
|
192
|
+
return straight();
|
|
193
|
+
const samples = [];
|
|
194
|
+
let previousU = 0;
|
|
195
|
+
for (let i = 1; i < 32; ++i) {
|
|
196
|
+
const offset = minus(points[i], p0);
|
|
197
|
+
const b1 = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(offset, chord) / area;
|
|
198
|
+
const b2 = AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.cross(side, offset) / area;
|
|
199
|
+
const b0 = 1 - b1 - b2;
|
|
200
|
+
if (b0 <= 0 || b1 <= 0 || b2 <= 0)
|
|
201
|
+
return straight();
|
|
202
|
+
const root0 = Math.sqrt(b0);
|
|
203
|
+
const root2 = Math.sqrt(b2);
|
|
204
|
+
const u = root2 / (root0 + root2);
|
|
205
|
+
if (u <= previousU)
|
|
206
|
+
return straight();
|
|
207
|
+
previousU = u;
|
|
208
|
+
const base = [
|
|
209
|
+
(b0 * p0[0] + b2 * p2[0]) / (b0 + b2),
|
|
210
|
+
(b0 * p0[1] + b2 * p2[1]) / (b0 + b2),
|
|
211
|
+
];
|
|
212
|
+
const idealWeight = b1 / (2 * root0 * root2);
|
|
213
|
+
if (!(idealWeight > 0) || !Number.isFinite(idealWeight))
|
|
214
|
+
return straight();
|
|
215
|
+
samples.push({ u, apex: b1, scale: AutoMovieRecoveryConicApproximation_1.AutoMovieRecoveryConicApproximation.distance(p1, base), idealWeight });
|
|
216
|
+
}
|
|
217
|
+
/** Signed distance along a fixed apex ray is monotone in positive weight. */
|
|
218
|
+
const residual = (sample, weight) => {
|
|
219
|
+
const middle = 2 * weight * sample.u * (1 - sample.u);
|
|
220
|
+
const denominator = (1 - sample.u) ** 2 + middle + sample.u ** 2;
|
|
221
|
+
return (middle / denominator - sample.apex) * sample.scale;
|
|
222
|
+
};
|
|
223
|
+
const fitting = samples.filter((_sample, i) => i % 2 === 1);
|
|
224
|
+
let low = Math.min(...fitting.map((sample) => Math.log(sample.idealWeight)));
|
|
225
|
+
let high = Math.max(...fitting.map((sample) => Math.log(sample.idealWeight)));
|
|
226
|
+
for (let iteration = 0; iteration < 48 && low < high; ++iteration) {
|
|
227
|
+
const middle = (low + high) / 2;
|
|
228
|
+
const weight = Math.exp(middle);
|
|
229
|
+
let minimum = 0;
|
|
230
|
+
let maximum = 0;
|
|
231
|
+
for (const sample of fitting) {
|
|
232
|
+
const error = residual(sample, weight);
|
|
233
|
+
minimum = Math.min(minimum, error);
|
|
234
|
+
maximum = Math.max(maximum, error);
|
|
235
|
+
}
|
|
236
|
+
if (minimum + maximum > 0)
|
|
237
|
+
high = middle;
|
|
238
|
+
else
|
|
239
|
+
low = middle;
|
|
240
|
+
}
|
|
241
|
+
const weight = Math.exp((low + high) / 2);
|
|
242
|
+
const maximum = samples.reduce((error, sample) => Math.max(error, Math.abs(residual(sample, weight))), 0);
|
|
243
|
+
if (!Number.isFinite(maximum) || !Number.isFinite(weight) || weight <= 0)
|
|
244
|
+
return straight();
|
|
245
|
+
return {
|
|
246
|
+
domain: [interval.a, interval.b],
|
|
247
|
+
controls: [p0, p1, p2],
|
|
248
|
+
weight,
|
|
249
|
+
maximumSampleErrorMm: maximum,
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
const boundaries = [curve.domain[0], ...new Set(curve.breaks), curve.domain[1]].sort((a, b) => a - b);
|
|
253
|
+
if (boundaries.length - 1 > options.maximumArcs) {
|
|
254
|
+
diagnostics.push("The supplied source intervals already exceed maximumArcs.");
|
|
255
|
+
return result("refused");
|
|
256
|
+
}
|
|
257
|
+
const pending = [];
|
|
258
|
+
for (let i = boundaries.length - 2; i >= 0; --i)
|
|
259
|
+
pending.push({ a: boundaries[i], b: boundaries[i + 1], depth: 0 });
|
|
260
|
+
let leaves = pending.length;
|
|
261
|
+
try {
|
|
262
|
+
while (pending.length !== 0) {
|
|
263
|
+
const interval = pending.pop();
|
|
264
|
+
const arc = fit(interval);
|
|
265
|
+
if (arc !== undefined && arc.maximumSampleErrorMm <= options.toleranceMm) {
|
|
266
|
+
arcs.push(arc);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const midpoint = (interval.a + interval.b) / 2;
|
|
270
|
+
const reason = arc === undefined ? "inadmissible or nonregular tangent triangle" : "held-out radial discrepancy exceeds tolerance";
|
|
271
|
+
if (interval.depth >= options.maximumDepth || leaves >= options.maximumArcs || midpoint === interval.a || midpoint === interval.b) {
|
|
272
|
+
++unresolved;
|
|
273
|
+
reasons.set(reason, (reasons.get(reason) ?? 0) + 1);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
++leaves;
|
|
277
|
+
pending.push({ a: midpoint, b: interval.b, depth: interval.depth + 1 });
|
|
278
|
+
pending.push({ a: interval.a, b: midpoint, depth: interval.depth + 1 });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
diagnostics.push(error instanceof Error ? error.message : String(error));
|
|
283
|
+
return result("refused");
|
|
284
|
+
}
|
|
285
|
+
for (const [reason, count] of reasons)
|
|
286
|
+
diagnostics.push(`${count} unresolved source interval(s): ${reason}; subdivision budget exhausted.`);
|
|
287
|
+
return result(unresolved === 0 ? "complete" : arcs.length === 0 ? "refused" : "partial");
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=approximateAutoMovieRecoveryConicsAhn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approximateAutoMovieRecoveryConicsAhn.js","sourceRoot":"","sources":["../../src/curves/approximateAutoMovieRecoveryConicsAhn.ts"],"names":[],"mappings":";;;AAAA,+FAAiG;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,+CACE,KAAe,EACf,OAAmB;IAEnB,MAAM,MAAM,GAAW,oEAAoE,CAAC;IAC5F,MAAM,WAAW,GAAa,yEAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,OAAO,GAAW,CAAC,CAAC;IACxB,IAAI,UAAU,GAAW,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|
2
|
+
/**
|
|
3
|
+
* Numerically reproduce the endpoint-bitangent equioscillation construction of
|
|
4
|
+
* Ghosh, Petitjean and Vegter, Approximation by Conic Splines (2007), sections
|
|
5
|
+
* 3.2–3.4 and 6, DOI 10.1007/s11786-007-0004-8.
|
|
6
|
+
*
|
|
7
|
+
* Source breaks are hard boundaries: piecewise Hermite input does not acquire
|
|
8
|
+
* the paper's smoothness merely by supplying derivatives. On each smooth chart
|
|
9
|
+
* we sample nonzero curvature and monotone affine curvature, construct the
|
|
10
|
+
* endpoint triple-contact limits of the positive-weight bitangent family, and
|
|
11
|
+
* bisect its weight until refined positive and negative normal extrema balance.
|
|
12
|
+
* Located extrema are exchanged into the fitting nodes; independent held-out
|
|
13
|
+
* nodes then validate the selected coefficient rather than driving its fit.
|
|
14
|
+
* Endpoint bisection then selects an interval meeting the requested tolerance.
|
|
15
|
+
* Unlike the paper's symbolic implementation, this experiment uses finite
|
|
16
|
+
* admission/extremum samples, so neither Hausdorff certification nor global
|
|
17
|
+
* minimum arc count is claimed. Collinear charts are an explicit line extension.
|
|
18
|
+
* A zero-curvature chart endpoint uses the compactified infinite-weight limit
|
|
19
|
+
* only to bracket finite positive weights. This is an explicit numerical
|
|
20
|
+
* boundary extension, not a proof that the paper's theorem admits that endpoint.
|
|
21
|
+
* Source callback failures refuse the whole call and discard all coefficients;
|
|
22
|
+
* sampled mathematical admission failures may leave explicitly partial coverage.
|
|
23
|
+
*
|
|
24
|
+
* @evidence contracts/development/common.md#meaningful-documentation States provenance, source-parameter units, preserved breaks, numerical admission, sampled errors, line extension and explicit refusal/partial coverage.
|
|
25
|
+
* @evidence contracts/development/implementation.md#principled-implementation Sections 3.2–3.4 and 6 supply bitangent normal-displacement equioscillation and endpoint bisection; proposition 2.3 supplies affine curvature. Finite samples replace symbolic extrema and cannot certify the continuous premises.
|
|
26
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Local helpers own source queries, differential admission, tangent-triangle algebra, displacement and the two nested bisections; no Human-specific data enters recovery.
|
|
27
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No source samples become output coefficients, no input smoothing or fixture branch is used, and unsupported intervals remain omitted with diagnostics.
|
|
28
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Chart count, accepted arcs and caller depth bound interval visits. Each candidate alternates 32-step weight bisection with at most depth extremum exchanges; the balance helper bounds its witness/golden-search cost, and 64 independent nodes validate the result. A separate visit budget bounds unsuccessful subdivision.
|
|
29
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Each candidate caches its source points, normals and barycentric coordinates across coefficient bisection; accepted coefficients and measured error are reused when the endpoint search advances.
|
|
30
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The synchronous pure call retains only its bounded interval stack, result arcs and one candidate's samples; no callback, handle or source array survives return.
|
|
31
|
+
*/
|
|
32
|
+
export declare function approximateAutoMovieRecoveryConicsGhosh(curve: C.ICurve, options: C.IOptions): C.IResult;
|