@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.
44 lines (43 loc) • 1.19 kB
JavaScript
// @license Copyright © 2021-2024 observerly
const M = (e, a, o) => {
const t = [], [n, s] = e, [r, l] = a, p = Math.hypot(r - n, l - s), d = Math.ceil(p / o);
for (let c = 0; c <= d; c++) {
const i = c / d, u = n + i * (r - n), h = s + i * (l - s);
t.push([u, h]);
}
return t;
}, y = (e, a, o) => {
const t = [], [n, s] = e, [r, l] = a;
let p = r;
Math.abs(r - n) > 180 && (p = r > n ? r - 360 : r + 360);
const d = Math.hypot(p - n, l - s), c = Math.ceil(d / o);
for (let i = 0; i <= c; i++) {
const u = i / c;
let h = n + u * (p - n), f = s + u * (l - s);
h = (h + 360) % 360, f = Math.max(-90, Math.min(90, f)), t.push([h, f]);
}
return t;
};
function X(e, a = 1) {
const o = [];
for (let t = 0; t < e.length - 1; t++) {
const n = e[t], s = e[t + 1];
o.push(...M(n, s, a));
}
return o;
}
function x(e, a = 1) {
const o = [];
for (let t = 0; t < e.length - 1; t++) {
const n = e[t], s = e[t + 1];
o.push(...y(n, s, a));
}
return o;
}
export {
M as interpolate,
y as interpolateGeodesic,
X as interpolateRank2DArray,
x as interpolateRank2DGeodesicCoordinateArray
};
//# sourceMappingURL=maths.js.map