/* * od_iod.h -- Initial orbit determination (Gibbs method) * * Given 3 position vectors and their times, recover a velocity * at the middle observation using Gibbs' vector cross-product * approach (Vallado Algorithm 54). The resulting (r, v) pair * provides a seed orbit for the DC solver. * * Uses WGS-72 mu (398600.8 km^3/s^2) for SGP4 consistency. */ #ifndef PG_ORRERY_OD_IOD_H #define PG_ORRERY_OD_IOD_H #include "od_math.h" /* * IOD result: Keplerian elements at the middle observation epoch. */ typedef struct { od_keplerian_t kep; double epoch_jd; int valid; /* 1 if physically valid orbit */ } od_iod_result_t; /* * Gibbs method: recover velocity at r2 from 3 coplanar positions. * * pos1, pos2, pos3: TEME position vectors (km) * jd1, jd2, jd3: Julian dates of each observation * result: output Keplerian elements at epoch jd2 * * Returns 0 on success, -1 if vectors are not coplanar (within * tolerance) or orbit is degenerate. * * Coplanarity check: |r1 . (r2 x r3)| / (|r1| * |r2 x r3|) < 0.05 * (about 3 degrees -- generous to handle noise). */ int od_gibbs(const double pos1[3], const double pos2[3], const double pos3[3], double jd1, double jd2, double jd3, od_iod_result_t *result); /* * Gauss method: recover orbit from 3 angles-only (RA/Dec) observations. * * ra[3], dec[3]: right ascension and declination in radians * jd[3]: Julian dates of each observation * obs_ecef[3][3]: observer ECEF positions (km) at each epoch * result: output Keplerian elements at epoch jd[1] (middle obs) * * Returns 0 on success, -1 on failure (non-convergence, degenerate). * * Implements Vallado Algorithm 52 with iterative refinement of the * slant range at the middle observation. */ int od_gauss(const double ra[3], const double dec[3], const double jd[3], const double obs_ecef[3][3], od_iod_result_t *result); #endif /* PG_ORRERY_OD_IOD_H */