Skip to content

Commit

Permalink
fixed wrong height and latitude
Browse files Browse the repository at this point in the history
  • Loading branch information
reed committed Dec 2, 2018
1 parent 539e427 commit 889cf88
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
Binary file modified .vs/One_Sgp4/v15/.suo
Binary file not shown.
Binary file modified .vs/One_Sgp4/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified .vs/One_Sgp4/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
35 changes: 35 additions & 0 deletions OneSGP4_Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ static void Main(string[] args)
//Get Local SiderealTime for Observer
double localSiderealTime = startTime.getLocalSiderealTime(observer.getLongitude());

//TESTING MIR

//TEST ECI
EpochTime T_eciTime= new EpochTime(09, 00, 00, 1995, 10, 1);
//Test GMST
if (T_eciTime.getLocalSiderealTime() == 2.524218)
{

}
Coordinate T_eciCoo = new Coordinate(40, -75);
var t_eci = T_eciCoo.toECI(T_eciTime.getLocalSiderealTime());
//Coordinate equals x' = 1703.295 km, y' = 4586.650 km, z' = 4077.984 km.


EpochTime t_time = new EpochTime(12, 46, 0, 1995, 11, 18);
Coordinate t_cord = new Coordinate(45.0, -93);
Sgp4Data mirPos = new Sgp4Data();
Expand All @@ -72,6 +86,27 @@ static void Main(string[] args)
var onGround = SatFunctions.calcSatSubPoint(t_time, mirPos, Sgp4.wgsConstant.WGS_72);
var r = t_cord.toECI(t_time.getLocalSiderealTime());


//TESTING


//Calculate SubPoint of Satellite on ground
while (true)
{
One_Sgp4.EpochTime time = new EpochTime(DateTime.UtcNow);
var test = time.getEpoch();
Console.Out.WriteLine(test);

var satpos = One_Sgp4.SatFunctions.getSatPositionAtTime(tleISS, time, Sgp4.wgsConstant.WGS_72);

Coordinate newC = new Coordinate(48.853333, 2.348611);
var look = SatFunctions.calcSphericalCoordinate(newC, time, satpos);
One_Sgp4.Coordinate satOnGround = One_Sgp4.SatFunctions.calcSatSubPoint(time, satpos, Sgp4.wgsConstant.WGS_72);
Console.Out.WriteLine(satOnGround.toString() + " - Azimuth: " + look.y + " Elevation: " + look.z );
Thread.Sleep(1000);
}


//Calculate if Satellite is Visible for a certain Observer on ground at certain timePoint
bool satelliteIsVisible = One_Sgp4.SatFunctions.isSatVisible(observer, 0.0, startTime, resultDataList[0]);

Expand Down
2 changes: 1 addition & 1 deletion One_Sgp4/One_Sgp4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net40;net45</TargetFrameworks>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<PackageReleaseNotes>Included Net 4.0 and Net 4.5 as TargetFrameworks</PackageReleaseNotes>
</PropertyGroup>

Expand Down
24 changes: 11 additions & 13 deletions One_Sgp4/SatFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,36 +217,34 @@ public static Coordinate calcSatSubPoint(EpochTime time, Sgp4Data satPosData,
double sat_X = satPosData.getX();
double sat_Y = satPosData.getY();
double sat_Z = satPosData.getZ();


double f = WGS_72.f;
double wgs_R = WGS_72.radiusEarthKM;
if (wgs == Sgp4.wgsConstant.WGS_84) {
f = WGS_84.f;
wgs_R = WGS_84.radiusEarthKM;
}


}
double delta = 1.0e-07;
double f_2 = f * f;
double e = 2 * f - f_2;

double e = 2 * f - f_2;

double r = Math.Sqrt( (sat_X * sat_X) + (sat_Y * sat_Y) );
double latitude = AcTan(sat_Z , r);
double c = 1.0;
double height = 0.0;
double R = wgs_R * c * Math.Cos(latitude);

for (int i = 0; i< 20; i++)
double phi;

do
{
//R = wgs_R * c * Math.Cos(latitude);
c = 1.0 / (Math. Sqrt(1.0 - e * (Math.Sin(latitude) * Math.Sin(latitude))));
latitude = AcTan(sat_Z + (wgs_R * c * e * Math.Sin(latitude)), R);
phi = latitude;
c = 1.0 / (Math.Sqrt(1.0 - e * (Math.Sin(latitude) * Math.Sin(latitude))));
latitude = AcTan(sat_Z + (wgs_R * c * e * Math.Sin(latitude)), r);
}
while (Math.Abs(latitude - phi) > delta);

double longitude = AcTan(sat_Y, sat_X) - time.getLocalSiderealTime();
height = (R / Math.Cos(latitude)) - (wgs_R * c);
//height = Math.Sqrt(sat_X * sat_X + sat_Y * sat_Y + sat_Z * sat_Z) - wgs_R*c;
height = (r / Math.Cos(latitude)) - (wgs_R * c);

if (longitude < pi)
{
Expand Down

0 comments on commit 889cf88

Please sign in to comment.