removed unused arc class

This commit is contained in:
bijx
2026-01-08 16:31:41 -05:00
parent 7653861167
commit b0d0178b08
@@ -110,110 +110,6 @@ export class FactoryRadiusLayer implements Layer {
});
}
private computeUncoveredArcIntervals(
a: FactoryRadius,
circles: FactoryRadius[],
) {
a.arcs = [];
const TWO_PI = Math.PI * 2;
const EPS = 1e-9;
const normalize = (angle: number) => {
while (angle < 0) angle += TWO_PI;
while (angle >= TWO_PI) angle -= TWO_PI;
return angle;
};
const mergeIntervals = (
intervals: Array<[number, number]>,
): Array<[number, number]> => {
if (intervals.length === 0) return [];
const flat: Array<[number, number]> = [];
for (const [s, e] of intervals) {
const ns = normalize(s);
const ne = normalize(e);
if (ne < ns) {
flat.push([ns, TWO_PI]);
flat.push([0, ne]);
} else {
flat.push([ns, ne]);
}
}
flat.sort((x, y) => x[0] - y[0]);
const merged: Array<[number, number]> = [];
let cur = flat[0].slice() as [number, number];
for (let i = 1; i < flat.length; i++) {
const it = flat[i];
if (it[0] <= cur[1] + EPS) {
cur[1] = Math.max(cur[1], it[1]);
} else {
merged.push([cur[0], cur[1]]);
cur = it.slice() as [number, number];
}
}
merged.push([cur[0], cur[1]]);
return merged;
};
const covered: Interval[] = [];
let fullyCovered = false;
for (const b of circles) {
if (a === b) continue;
const dx = b.x - a.x;
const dy = b.y - a.y;
const d = Math.hypot(dx, dy);
// a fully inside b
if (d + a.r <= b.r + EPS) {
fullyCovered = true;
break;
}
// no overlap
if (d >= a.r + b.r - EPS) continue;
// coincident centers
if (d <= EPS) {
if (b.r >= a.r) {
fullyCovered = true;
break;
}
continue;
}
// angular span on a covered by b
const theta = Math.atan2(dy, dx);
const cosPhi = (a.r * a.r + d * d - b.r * b.r) / (2 * a.r * d);
const phi = Math.acos(Math.max(-1, Math.min(1, cosPhi)));
covered.push([theta - phi, theta + phi]);
}
if (fullyCovered) return;
const merged = mergeIntervals(covered);
// subtract from [0, 2π)
const uncovered: Interval[] = [];
if (merged.length === 0) {
uncovered.push([0, TWO_PI]);
} else {
let cursor = 0;
for (const [s, e] of merged) {
if (s > cursor + EPS) {
uncovered.push([cursor, s]);
}
cursor = Math.max(cursor, e);
}
if (cursor < TWO_PI - EPS) {
uncovered.push([cursor, TWO_PI]);
}
}
a.arcs = uncovered;
}
private drawArcSegments(ctx: CanvasRenderingContext2D, a: FactoryRadius) {
const fillColor = "rgba(0, 255, 0, 0.15)";
const strokeColor = "rgba(0, 255, 0, 0.8)";