Build aircraft shapes

This commit is contained in:
2026-06-25 21:43:56 -04:00
parent f6f8a252dc
commit b87bcbabb7
5 changed files with 1322 additions and 44 deletions

View File

@@ -22,47 +22,41 @@ const arc = computed(() => {
const start = noon - 12 * 3600 * 1000;
const end = noon + 12 * 3600 * 1000;
const pct = Math.max(0, Math.min(1, (now - start) / (end - start)));
const riseT = (rise - start) / (end - start);
const setT = (set - start) / (end - start);
const dayPct = Math.max(0, Math.min(1, (now - rise) / dayLen));
const x1 = 0, x2 = W;
const totalW = x2 - x1;
// Sine curve: below horizon at edges, peaks above at noon
const getPoint = (t: number) => ({
x: x1 + totalW * t,
y: HORIZON - Math.sin(t * Math.PI * 2 - Math.PI / 2) * (HORIZON) + (HORIZON)
// Simpler: just a single-hump arc above horizon + dip below
});
// Generate points along full sine path
const pts = Array.from({ length: 201 }, (_, i) => {
const t = i / 200;
const x = x1 + totalW * t;
// Single smooth S: -sin gives us below->above->below
const amplitude = (HORIZON);
const y = HORIZON - Math.sin(t * Math.PI * 2 - Math.PI / 2) * amplitude;
// Remap t so the arc peaks between riseT and setT only
const arcT = (t - riseT) / (setT - riseT);
const y = arcT >= 0 && arcT <= 1
? HORIZON - Math.sin(arcT * Math.PI) * HORIZON
: HORIZON + Math.abs(Math.sin(arcT * Math.PI)) * (HORIZON * 0.3); // subtle below-horizon dip
return { x, y };
});
const splitIdx = Math.round(pct * 200);
const { x: cx, y: cy } = <any>pts[splitIdx];
const sunT = riseT + dayPct * (setT - riseT);
const splitIdx = Math.round(sunT * 200);
const { x: cx, y: cy } = pts[splitIdx];
// Filled traveled path: close down to horizon baseline for fill
const traveledPts = pts.slice(0, splitIdx + 1);
const filledPath = traveledPts.map((p, i) => `${i === 0 ? 'M' : 'L'}${p.x.toFixed(1)},${p.y.toFixed(1)}`).join(' ')
+ ` L${(<any>traveledPts[traveledPts.length - 1]).x.toFixed(1)},${HORIZON}`
+ ` L${traveledPts[traveledPts.length - 1].x.toFixed(1)},${HORIZON}`
+ ` L${x1},${HORIZON} Z`;
// Remaining path stroke only
const remainPts = pts.slice(splitIdx);
const remainPath = remainPts.map((p, i) => `${i === 0 ? 'M' : 'L'}${p.x.toFixed(1)},${p.y.toFixed(1)}`).join(' ');
// Sunrise / sunset x positions
const riseX = x1 + totalW * ((rise - start) / (end - start));
const setX = x1 + totalW * ((set - start) / (end - start));
const riseX = x1 + totalW * riseT;
const setX = x1 + totalW * setT;
const noonX = x1 + totalW * 0.5;
return { filledPath, remainPath, cx, cy, pct, riseX, setX, noonX };
return { filledPath, remainPath, cx, cy, pct: dayPct, riseX, setX, noonX };
});
</script>