@observerly/astrometry
Version:
observerly's lightweight, zero-dependency, type safe astrometry library written in Typescript for calculating the position of celestial objects in the sky.
48 lines (47 loc) • 2.13 kB
JavaScript
import { getObliquityOfTheEcliptic as d, getHourAngle as m, getLocalSiderealTime as T } from "./astrometry.js";
import { c as t, e as M } from "./utilities-BM-rBPno.js";
// @license Copyright © 2021-2023 observerly
const v = (e, i) => {
const o = t(d(e)), a = t(i.λ), c = t(i.β), s = Math.atan2(Math.sin(a) * Math.cos(o) - Math.tan(c) * Math.sin(o), Math.cos(a)), n = Math.asin(Math.sin(c) * Math.cos(o) + Math.cos(c) * Math.sin(o) * Math.sin(a));
return {
ra: M(s) < 0 ? M(s) + 360 : M(s),
dec: M(n)
};
}, E = (e) => {
let { ra: i, dec: o } = { ra: 0, dec: 0 };
const a = t(192.8598), c = t(27.128027), s = t(32.9319), n = t(e.b), h = t(e.l);
o = M(Math.asin(Math.cos(n) * Math.cos(c) * Math.sin(h - s) + Math.sin(n) * Math.sin(c)));
const r = Math.cos(n) * Math.cos(h - s), u = Math.sin(n) * Math.cos(c) - Math.cos(n) * Math.sin(c) * Math.sin(h - s);
return i = M(Math.atan2(r, u) + a) % 360, i < 0 && (i += 360), {
ra: i,
dec: o
};
}, p = (e, i, o) => {
const { latitude: a, longitude: c } = i, s = t(o.dec);
if (Math.cos(t(a)) === 0)
return {
alt: -1,
az: -1
};
const n = t(m(e, c, o.ra)), h = Math.asin(Math.max(-1, Math.min(1, Math.sin(s) * Math.sin(t(a)) + Math.cos(s) * Math.cos(t(a)) * Math.cos(n)))), r = Math.acos(Math.max(-1, Math.min(1, (Math.sin(s) - Math.sin(t(a)) * Math.sin(h)) / (Math.cos(t(a)) * Math.cos(h)))));
return {
alt: M(h),
az: Math.sin(n) > 0 ? 360 - M(r) : M(r)
};
}, q = (e, i, o) => {
const { latitude: a, longitude: c } = i, s = t(o.alt), n = t(o.az), h = Math.asin(Math.sin(t(a)) * Math.sin(s) + Math.cos(t(a)) * Math.cos(s) * Math.cos(n));
let r = Math.atan2(-Math.sin(n) * Math.cos(s) / Math.cos(h), (Math.sin(s) - Math.sin(t(a)) * Math.sin(h)) / (Math.cos(t(a)) * Math.cos(h)));
r < 0 && (r += 2 * Math.PI);
let l = T(e, c) * 15 - M(r);
return l < 0 && (l += 360), {
ra: l % 360,
dec: M(h)
};
};
export {
v as convertEclipticToEquatorial,
p as convertEquatorialToHorizontal,
E as convertGalacticToEquatorial,
q as convertHorizontalToEquatorial
};
//# sourceMappingURL=coordinates.js.map