This commit is contained in:
2026-06-07 21:44:49 +02:00
parent 3dd9620cca
commit 6542504a4b
14 changed files with 585 additions and 139 deletions
+15
View File
@@ -174,3 +174,18 @@ export function greatCirclePoints(
function toRad(d: number): number { return (d * Math.PI) / 180; }
function toDeg(r: number): number { return (r * 180) / Math.PI; }
// destinationPoint returns the lat/lon reached from (lat,lon) by travelling
// distanceKm along the great circle at the given initial bearing. Used to draw
// the antenna beam lobe (a sector of bearings) on the world map.
export function destinationPoint(lat: number, lon: number, bearingDeg: number, distanceKm: number): { lat: number; lon: number } {
const delta = distanceKm / EARTH_KM;
const theta = toRad(bearingDeg);
const phi1 = toRad(lat), lam1 = toRad(lon);
const sinPhi2 = Math.sin(phi1) * Math.cos(delta) + Math.cos(phi1) * Math.sin(delta) * Math.cos(theta);
const phi2 = Math.asin(Math.max(-1, Math.min(1, sinPhi2)));
const y = Math.sin(theta) * Math.sin(delta) * Math.cos(phi1);
const x = Math.cos(delta) - Math.sin(phi1) * sinPhi2;
const lam2 = lam1 + Math.atan2(y, x);
return { lat: toDeg(phi2), lon: ((toDeg(lam2) + 540) % 360) - 180 };
}