public static function Calculate_LatLonAlt($_time, Predict_Vector $pos, Predict_Geodetic $geodetic) { /* Reference: The 1992 Astronomical Almanac, page K12. */ /* double r,e2,phi,c; */ $geodetic->theta = Predict_Math::AcTan($pos->y, $pos->x); /*radians*/ $geodetic->lon = Predict_Math::FMod2p($geodetic->theta - Predict_Time::ThetaG_JD($_time)); /*radians*/ $r = sqrt($pos->x * $pos->x + $pos->y * $pos->y); $e2 = Predict::__f * (2 - Predict::__f); $geodetic->lat = Predict_Math::AcTan($pos->z, $r); /*radians*/ do { $phi = $geodetic->lat; $sinPhi = sin($phi); $c = 1 / sqrt(1 - $e2 * ($sinPhi * $sinPhi)); $geodetic->lat = Predict_Math::AcTan($pos->z + Predict::xkmper * $c * $e2 * $sinPhi, $r); } while (abs($geodetic->lat - $phi) >= 1.0E-10); $geodetic->alt = $r / cos($geodetic->lat) - Predict::xkmper * $c; /*kilometers*/ if ($geodetic->lat > Predict::pio2) { $geodetic->lat -= Predict::twopi; } }