From 9cf2335e2d14bac133b8a60c8b4e27cf86747961 Mon Sep 17 00:00:00 2001 From: Ivan Stanojevic Date: Mon, 16 Mar 2015 22:36:26 +0100 Subject: [PATCH] Untested stuff moved to integration branch --- TLE/Constant.php | 7 --- TLE/LatLng.php | 17 ------- TLE/Parser.php | 112 ----------------------------------------------- 3 files changed, 136 deletions(-) delete mode 100644 TLE/LatLng.php diff --git a/TLE/Constant.php b/TLE/Constant.php index 14f7e0b..ffe14e6 100644 --- a/TLE/Constant.php +++ b/TLE/Constant.php @@ -12,12 +12,5 @@ abstract class Constant { */ const SIDERAL_DAY_SEC = 86164.0984; - const eg_4pi = 10096.66709265246; - - const Tropical_year = 365.242197; - - const date_of_GHAA = "1/1/1990 00:00"; - - const ghaa_deg = 99.4033; } \ No newline at end of file diff --git a/TLE/LatLng.php b/TLE/LatLng.php deleted file mode 100644 index 2b8513b..0000000 --- a/TLE/LatLng.php +++ /dev/null @@ -1,17 +0,0 @@ -latitude = $latitude; - $this->longitude = $longitude; - } -} \ No newline at end of file diff --git a/TLE/Parser.php b/TLE/Parser.php index 8eed356..f0e630c 100644 --- a/TLE/Parser.php +++ b/TLE/Parser.php @@ -10,7 +10,6 @@ namespace TLE; use \TLE\Constant; -use \TLE\LatLng; /** * Class Parser. @@ -232,13 +231,6 @@ class Parser */ public $meanMotion; - /** - * Mean Motion expressed in radians per second. - * - * @var float - */ - public $meanMotionRadSec; - /** * Time of one revolution expressed in seconds. * @@ -246,31 +238,6 @@ class Parser */ public $revTime; - /** - * Calculated Semi-Major Axis based on Mean Motion. - * - * @var float - */ - public $semiMajorAxis; - - /** - * Calculated Semi-Minor Axis. - * - * @var float - */ - public $semiMinorAxis; - - /** - * Orbit number the satellite has finished from deployment to orbit until the specified TLE epoch. - * - * @var float - */ - public $revolutionNumber; - - private $eccentricAnomaly; - private $cosEccentricAnomaly; - private $sinEccentricAnomaly; - /** * Class Constructor. * @@ -335,7 +302,6 @@ public function __construct($tleString, $dateTime = null) { $this->epochDay = (int)$epoch[0]; $this->epochFraction = '0.' . $epoch[1]; $this->epochUnixTimestamp = $this->getEpochUnixTimestamp(); - $this->deltaSec = $this->getDeltaSec(); $this->meanMotionFirstDerivative = trim(substr($this->firstLine, 33, 10)); $this->meanMotionSecondDerivative = trim(substr($this->firstLine, 44, 8)); $this->bStarDragTerm = trim(substr($this->firstLine, 53, 8)); @@ -347,14 +313,7 @@ public function __construct($tleString, $dateTime = null) { $this->argumentPerigee = (float)trim(substr($this->secondLine, 34, 8)); $this->meanAnomaly = (float)trim(substr($this->secondLine, 43, 8)); $this->meanMotion = (float)trim(substr($this->secondLine, 52, 11)); - $this->meanMotionRadSec = ($this->meanMotion * 2 * M_PI) / 86400; $this->revTime = $this->meanMotion * \Constant::SIDERAL_DAY_SEC; - $this->semiMajorAxis = pow((\Constant::eg_4pi * pow($this->revTime, 2)), (1 / 3)); - $this->semiMinorAxis = $this->semiMajorAxis * sqrt(1 - pow($this->eccentricity, 2)); - $this->revolutionNumber = (int)trim(substr($this->secondLine, 63, 5)); - $this->satelliteRange = $this->getSatelliteRange(); - $satellitePoint = $this->getSatellitePoint(); - $this->satelliteLatLng = new \LatLng($satellitePoint['latitude'], $satellitePoint['longitude']); } /** @@ -406,22 +365,6 @@ public function calculateChecksum($line) { return $sum % 10; } - private function getSatelliteRange() { - $radsSinceEpoch = ($this->meanMotionRadSec * $this->deltaSec) + deg2rad($this->meanAnomaly); // (Mean Motion * Elapsed time) + Mean Anomaly - $fractionRevolution = $radsSinceEpoch - (2 * M_PI * (floor($radsSinceEpoch / (2 * M_PI)))); - - $this->eccentricAnomaly = $fractionRevolution; - do { - $this->cosEccentricAnomaly = cos($this->eccentricAnomaly); - $this->sinEccentricAnomaly = sin($this->eccentricAnomaly); - $denom = 1 - ($this->cosEccentricAnomaly * $this->eccentricity); - $iter = ($this->eccentricAnomaly - ($this->eccentricity * $this->sinEccentricAnomaly) - $radsSinceEpoch) / $denom; - $this->eccentricAnomaly = $this->eccentricAnomaly - $iter; - } while(abs($iter) > 0.0001); - - return $this->semiMajorAxis * $denom; - } - /** * Calculate Unix timestamp from TLE Epoch. * @@ -437,59 +380,4 @@ private function getEpochUnixTimestamp() { return $date->format('U') + (86400 * $this->epochDay) + $seconds - 86400; } - /** - * Calculate Delta Sec. - * - * @return mixed - */ - private function getDeltaSec() { - return $this->currentDateTime[0] - $this->epochUnixTimestamp; - } - - private function getSatellitePoint() { - // Calculating Satellite position vector on the Orbital Plane - $satOrbitalPlaneX = $this->semiMajorAxis * ($this->cosEccentricAnomaly - $this->eccentricity); - $satOrbitalPlaneY = $this->semiMinorAxis * $this->sinEccentricAnomaly; - - // Partial Rotation Matrix to transform from the Orbital Plane to Inertial (Celestial) Coordinates - $cosArgumentPerigee = cos(deg2rad($this->argumentPerigee)); - $sinArgumentPerigee = sin(deg2rad($this->argumentPerigee)); - $cosRaan = cos(deg2rad($this->rightAscensionAscendingNode)); - $sinRaan = sin(deg2rad($this->rightAscensionAscendingNode)); - $cosInclination = cos(deg2rad($this->inclination)); - $sinInclination = sin(deg2rad($this->inclination)); - - $cel_x_x = ($cosArgumentPerigee * $cosRaan) - ($sinArgumentPerigee * $sinRaan * $cosInclination); - $cel_x_y = (-$sinArgumentPerigee * $cosRaan) - ($cosArgumentPerigee * $sinRaan * $cosInclination); - $cel_y_x = ($cosArgumentPerigee * $sinRaan) + ($sinArgumentPerigee * $cosRaan * $cosInclination); - $cel_y_y = (-$sinArgumentPerigee * $sinRaan) + ($cosArgumentPerigee * $cosRaan * $cosInclination); - $cel_z_x = ($sinArgumentPerigee * $sinInclination); - $cel_z_y = ($cosArgumentPerigee * $sinInclination); - - // Calculations Satellite position vector in Celestial Coordinates - $satCelestialX = ($satOrbitalPlaneX * $cel_x_x) + ($satOrbitalPlaneY * $cel_x_y); - $satCelestialY = ($satOrbitalPlaneX * $cel_y_x) + ($satOrbitalPlaneY * $cel_y_y); - $satCelestialZ = ($satOrbitalPlaneX * $cel_z_x) + ($satOrbitalPlaneY * $cel_z_y); - - $extraEarthRotationPerDay = (2 * M_PI) / \Constant::Tropical_year; - // The total earth rotation in one Solar Day = 1 sideral day + the above figure - $earthRotRadSec = ($extraEarthRotationPerDay + (2 * M_PI)) / 86400; - - $deltaGhaaSec = $this->epochUnixTimestamp[0] - (strtotime(\Constant::date_of_GHAA)); - $currentGhaaRad = deg2rad(\Constant::ghaa_deg) + ($deltaGhaaSec * $earthRotRadSec); - $cosGhaa = cos(-$currentGhaaRad); - $sinGhaa = sin(-$currentGhaaRad); - - // Satellite Coordinates in Geocentric Equatorial Coordinates (from RA to LONG, etc.) - $satGeoCX = ($satCelestialX * $cosGhaa) - ($satCelestialX * $sinGhaa); - $satGeoCY = ($satCelestialX * $sinGhaa) + ($satCelestialX * $cosGhaa); - $satGeoCZ = $satCelestialZ; - - $satelliteLongitude = rad2deg(atan2($satGeoCY, $satGeoCX)); - $satelliteLatitude = rad2deg(asin($satGeoCZ / $this->satelliteRange)); - - return array( - 'latitude' => $satelliteLongitude, 'longitude' => $satelliteLatitude, - ); - } }