public function testall() { $jde = 2451545.5; $de = new Reader(); $de->jde($jde); $ssobjs = [SSObj::SolarBary(), SSObj::Sun(), SSObj::Mercury(), SSObj::Venus(), SSObj::Earth(), SSObj::EarthBary(), SSObj::Moon(), SSObj::Mars(), SSObj::Jupiter(), SSObj::Saturn(), SSObj::Uranus(), SSObj::Neptune(), SSObj::Pluto()]; foreach ($ssobjs as $t) { foreach ($ssobjs as $c) { $pv = $de->position($t, $c); $format = '%+0.15E'; continue; echo "\n\n{$jde}\n{$c} -> {$t}"; echo "\n[ " . sprintf($format, $pv[0]); echo " " . sprintf($format, $pv[1]); echo " " . sprintf($format, $pv[2]) . " ]"; echo "\n[ " . sprintf($format, $pv[3]); echo " " . sprintf($format, $pv[4]); echo " " . sprintf($format, $pv[5]) . " ]"; } } echo "\n"; }
/** * Interpolates the solar system barycentric position of an object * * @param SSObj $obj Object to interpolate * * @return array Position/Velocity vector */ protected function interpObject(SSObj $obj) { // Solar System barycenter is always a zero vector if ($obj == SSObj::SolarBary()) { return [0, 0, 0, 0, 0, 0]; } // Calculate Earth position if ($obj == SSObj::Earth()) { // Earth-Moon mass ratio $emrat = $this->header->const->EMRAT; // Get Earth-Moon barycenter and geocentric moon positions $emb = $this->interp(SSObj::EarthBary()->id, 6); $moon = $this->interp(SSObj::Moon()->id, 6); // PV of Earth with respect to Solar System barycenter return [$emb[0] - 1 / (1 + $emrat) * $moon[0], $emb[1] - 1 / (1 + $emrat) * $moon[1], $emb[2] - 1 / (1 + $emrat) * $moon[2], $emb[3] - 1 / (1 + $emrat) * $moon[3], $emb[4] - 1 / (1 + $emrat) * $moon[4], $emb[5] - 1 / (1 + $emrat) * $moon[5]]; } // Calculate Moon position if ($obj == SSObj::Moon()) { $moon = $this->interp(SSObj::Moon()->id, 6); $earth = $this->interpObject(SSObj::Earth()); return [$moon[0] + $earth[0], $moon[1] + $earth[1], $moon[2] + $earth[2], $moon[3] + $earth[3], $moon[4] + $earth[4], $moon[5] + $earth[5]]; } // Interpolate position return $this->interp($obj->id, 6); }