This commit is contained in:
2026-10-21 19:32:02 -04:00
commit b74d278c8e
96 changed files with 54476 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
/** Error intended to be returned by the HTTP API. */
export class ServiceError extends Error {
constructor(code, message, status = 500, details = undefined) {
super(message);
this.name = 'ServiceError';
this.code = code;
this.status = status;
if (details !== undefined) this.details = details;
}
}
+41
View File
@@ -0,0 +1,41 @@
export const rad = (degrees) => (degrees * Math.PI) / 180;
export const deg = (radians) => (radians * 180) / Math.PI;
export const wrap360 = (degrees) => ((degrees % 360) + 360) % 360;
export const wrap180 = (degrees) => ((degrees + 180) % 360 + 360) % 360 - 180;
/** Convert azimuth clockwise from north and altitude above the horizon to a unit ENU vector. */
export function azAltToVec(az, alt) {
const a = rad(az), e = rad(alt), ce = Math.cos(e);
return [ce * Math.sin(a), ce * Math.cos(a), Math.sin(e)];
}
/** Convert an east/north/up vector to azimuth clockwise from north and altitude. */
export function vecToAzAlt(vector) {
const [east, north, up] = vector;
const horizontal = Math.hypot(east, north);
return { az: wrap360(deg(Math.atan2(east, north))), alt: deg(Math.atan2(up, horizontal)) };
}
/** Quaternion [x,y,z,w] conjugate. */
export function quatConj([x, y, z, w]) {
return [-x, -y, -z, w];
}
/** Rotate a 3D vector by quaternion [x,y,z,w]. */
export function quatRotate([x, y, z, w], [vx, vy, vz]) {
const tx = 2 * (y * vz - z * vy);
const ty = 2 * (z * vx - x * vz);
const tz = 2 * (x * vy - y * vx);
return [
vx + w * tx + (y * tz - z * ty),
vy + w * ty + (z * tx - x * tz),
vz + w * tz + (x * ty - y * tx),
];
}
/** Great-circle angular separation of two azimuth/altitude positions, in degrees. */
export function angularSeparation(az1, alt1, az2, alt2) {
const a1 = rad(alt1), a2 = rad(alt2), da = rad(wrap180(az2 - az1));
const cosSep = Math.sin(a1) * Math.sin(a2) + Math.cos(a1) * Math.cos(a2) * Math.cos(da);
return deg(Math.acos(Math.max(-1, Math.min(1, cosSep))));
}
+24
View File
@@ -0,0 +1,24 @@
// Bright-star catalogue: J2000 right ascension (hours) and declination (degrees).
// Values are approximate and intended for telescope target selection, not astrometry.
export const STARS = {
sirius: { label: 'Sirius', ra: 6.75248, dec: -16.7161 },
canopus: { label: 'Canopus', ra: 6.39920, dec: -52.6957 },
arcturus: { label: 'Arcturus', ra: 14.26102, dec: 19.1825 },
vega: { label: 'Vega', ra: 18.61565, dec: 38.7837 },
capella: { label: 'Capella', ra: 5.27816, dec: 45.9980 },
rigel: { label: 'Rigel', ra: 5.24230, dec: -8.2016 },
procyon: { label: 'Procyon', ra: 7.65503, dec: 5.2250 },
betelgeuse: { label: 'Betelgeuse', ra: 5.91953, dec: 7.4071 },
achernar: { label: 'Achernar', ra: 1.62857, dec: -57.2368 },
hadar: { label: 'Hadar', ra: 14.06373, dec: -60.3730 },
altair: { label: 'Altair', ra: 19.84639, dec: 8.8683 },
acrux: { label: 'Acrux', ra: 12.44330, dec: -63.0991 },
aldebaran: { label: 'Aldebaran', ra: 4.59868, dec: 16.5093 },
antares: { label: 'Antares', ra: 16.49013, dec: -26.4320 },
spica: { label: 'Spica', ra: 13.41988, dec: -11.1613 },
pollux: { label: 'Pollux', ra: 7.75526, dec: 28.0262 },
regulus: { label: 'Regulus', ra: 10.13953, dec: 11.9672 },
deneb: { label: 'Deneb', ra: 20.69053, dec: 45.2803 },
polaris: { label: 'Polaris', ra: 2.53030, dec: 89.2641 },
castor: { label: 'Castor', ra: 7.57667, dec: 31.8883 },
};