@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.
101 lines (100 loc) • 3.04 kB
JavaScript
import { isEquatorialCoordinate as L, isHorizontalCoordinate as C } from "./common.js";
import { convertEquatorialToHorizontal as D } from "./coordinates.js";
import { getNight as w } from "./night.js";
import { convertLocalSiderealTimeToGreenwhichSiderealTime as M, convertGreenwhichSiderealTimeToUniversalTime as h } from "./temporal.js";
import { c as f, e as d } from "./utilities-BM-rBPno.js";
// @license Copyright © 2021-2023 observerly
const g = (e) => {
if (typeof e == "boolean" || typeof e != "object" || e === null)
return !1;
const { datetime: n, LST: t, GST: s, az: o } = e;
return !(!(n instanceof Date) || typeof t != "number" || typeof s != "number" || typeof o != "number");
}, l = (e, n, t = 0) => {
const { latitude: s } = e, { dec: o } = n;
return s >= t ? s + o > 90 : s + o < -90;
}, S = (e, n, t = 0) => {
const { latitude: s } = e, { dec: o } = n;
return 90 - Math.abs(s - o) > t;
}, U = (e, n, t, s = 0) => {
let o = Number.NEGATIVE_INFINITY;
return L(t) && (o = D(e, n, t).alt), C(t) && (o = t.alt), o > s;
}, B = (e, n) => {
const { latitude: t } = e, { dec: s } = n, o = Math.sin(f(s)) / Math.cos(f(t));
if (Math.abs(o) > 1)
return !1;
const r = Math.tan(f(t)) * Math.tan(f(s));
return Math.abs(r) > 1 ? !1 : {
Ar: o,
H1: r
};
}, p = (e, n) => {
const t = n.ra / 15, s = B(e, n);
if (!s)
return;
const { H1: o, Ar: r } = s, a = d(Math.acos(-o)) / 15, i = d(Math.acos(r)), c = 360 - i;
let u = 24 + t - a;
u > 24 && (u -= 24);
let T = t + a;
return T > 24 && (T -= 24), {
LSTr: u,
LSTs: T,
R: i,
S: c
};
}, m = (e, n, t, s = 0) => {
const o = new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate() + 1, 0, 0, 0, 0));
if (l(n, t, s) || !S(n, t, s))
return !1;
const r = p(n, t);
if (!r)
return m(o, n, t, s);
const a = r.LSTr, i = M(a, n), c = h(i, e);
return c.getTime() < e.getTime() ? m(o, n, t, s) : {
datetime: c,
LST: r.LSTr,
GST: i,
az: r.R
};
}, y = (e, n, t, s = 0) => {
const o = new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate() + 1, 0, 0, 0, 0));
if (l(n, t, s))
return !0;
if (!S(n, t, s))
return !1;
const r = p(n, t);
if (!r)
return y(o, n, t, s);
const a = r.LSTs, i = M(a, n), c = h(i, e);
return c < e ? y(o, n, t, s) : {
datetime: c,
LST: r.LSTs,
GST: i,
az: r.S
};
}, A = (e, n, t, s = 0) => {
if (e = new Date(new Date(e.setHours(0, 0, 0, 0)).getTime()), !S(n, t, s))
return !1;
if (l(n, t, s))
return !0;
const { start: o, end: r } = w(e, n);
if (!o || !r)
return !1;
for (; o <= r; ) {
if (U(o, n, t, s))
return !0;
o.setMinutes(o.getMinutes() + 1);
}
return !1;
};
export {
B as doesBodyRiseOrSet,
m as getBodyNextRise,
y as getBodyNextSet,
p as getBodyTransit,
U as isBodyAboveHorizon,
l as isBodyCircumpolar,
S as isBodyVisible,
A as isBodyVisibleForNight,
g as isTransitInstance
};
//# sourceMappingURL=transit.js.map