Skip to content

Commit

Permalink
Untested stuff moved to integration branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Stanojevic committed Mar 16, 2015
1 parent 8de00e0 commit 9cf2335
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 136 deletions.
7 changes: 0 additions & 7 deletions TLE/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
17 changes: 0 additions & 17 deletions TLE/LatLng.php

This file was deleted.

112 changes: 0 additions & 112 deletions TLE/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace TLE;

use \TLE\Constant;
use \TLE\LatLng;

/**
* Class Parser.
Expand Down Expand Up @@ -232,45 +231,13 @@ class Parser
*/
public $meanMotion;

/**
* Mean Motion expressed in radians per second.
*
* @var float
*/
public $meanMotionRadSec;

/**
* Time of one revolution expressed in seconds.
*
* @var float
*/
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.
*
Expand Down Expand Up @@ -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));
Expand All @@ -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']);
}

/**
Expand Down Expand Up @@ -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.
*
Expand All @@ -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,
);
}
}

0 comments on commit 9cf2335

Please sign in to comment.