✨ astronomy.js 독립 사용 가이드

별자리판 UI 없이 천문학 계산 로직만 필요하신가요? `astronomy.js`는 순수 자바스크립트(ESM)로 작성되어 어떤 프로젝트에서도 독립적으로 사용할 수 있습니다.

📦 설치 및 불러오기

NPM 또는 CDN을 통해 간편하게 시작하세요.

// NPM 사용 시
import { AstroTime, AstroMath, AstroVector } from 'planisphere-js/astronomy';

// CDN 사용 시
import { AstroTime, AstroMath, AstroVector } from 'https://cdn.jsdelivr.net/npm/planisphere-js/js/core/astronomy.js';

1. 시간 및 날짜 계산 (AstroTime)

율리우스일(JD) 및 항성시(LST)를 계산합니다.
const year = 2024, month = 6, day = 21, h = 12, m = 0, s = 0;

// 1. 율리우스일(JD) 계산
const jd = AstroTime.jd(year, month, day, h, m, s);
console.log('JD:', jd); // 

// 2. 지방시(LCT) → 항성시(LST) 변환 (서울 기준)
const astroTime = new AstroTime(9, 126.98, 37.57); // GMT+9, 경도, 위도
const lst = astroTime.LCT2LST(jd);
console.log('LST (Deg):', lst); // 

2. 태양 고도 및 남중 시각

특정 날짜의 태양 남중 시각(진정오)을 계산합니다.
const solarNoon = astroTime.lasn(2024, 6, 21);
console.log('서울 남중 시각:', solarNoon.toFixed(2) + '시'); // 

3. 좌표계 변환 (AstroVector)

적도 좌표(RA/Dec)를 지평 좌표(Alt/Az)로 변환하거나 그 반대를 수행합니다.
import { AstroVector, AstroMatrix } from '...';

const star = new AstroVector();
// 적경 2.5h, 적위 89.26도 (북극성 근처) 설정
star.setSphe(2.5 * AstroMath.H2R, 89.26 * AstroMath.D2R);

// 변환 행렬 생성 (LST와 위도 필요)
const matrix = new AstroMatrix();
matrix.equ2hor(lst * AstroMath.D2R, 37.57 * AstroMath.D2R);

const horVector = new AstroVector();
horVector.multiply(matrix, star);

console.log('방위각:', (horVector.lon() * AstroMath.R2D).toFixed(2)); // 
console.log('고도:', (horVector.lat() * AstroMath.R2D).toFixed(2));   // 

4. 2D 투영 (EquiDistanceProjection)

천구의 3D 좌표를 별자리판과 같은 2D 평면에 투영합니다.
import { EquiDistanceProjection } from '...';

const radius = 300; // 별자리판 반경
const proj = new EquiDistanceProjection(radius, 37.57 * AstroMath.D2R);

const { x, y } = proj.project(2.5 * AstroMath.H2R, 89.26 * AstroMath.D2R);
console.log('SVG 좌표:', x.toFixed(1), y.toFixed(1)); //