I have parsed ephemeris data in order to get the ECEF (or lat/long) positions of satellites visible above my current location. I would love to display those locations in a sky plot in my C# program.
I added a picture box to my GUI and attempted to scale the x/y values to display but i don't believe the locations that are being displayed are relative to my current location.
Does anyone have any examples or sample code on how to do this?
I'm doing it in a C# winform.
private const double CENTER = 110; //center of drawing (pixels)
private double SCALE_FACTOR = 89.0 / 90.0; //pixels from 90deg to 0 on drawing
.
.
.
private void drawSatellitePos(int svPrn, double elevation, double azimuth) //radians
{
double r = 90.0 - ConvertRadiansToDeg(elevation);
double theta = 90.0 - ConvertRadiansToDeg(azimuth);
theta = ConvertDegToRadians(theta);
double xLocation = CENTER + SCALE_FACTOR * r * Math.Cos(theta);
double yLocation = CENTER + SCALE_FACTOR * r * Math.Sin(theta);
Console.WriteLine("{0}: x: {1} Y: {2}", svPrn, xLocation, yLocation);
Point point = new Point((int)xLocation, (int)yLocation);
}
T.S. Kelso of celestrak.com has an excellent series of articles on satellite tracking and orbital coordinate systems. This article explains how to convert satellite positions to site-specific (topocentric) coordinates. (You'll probably need to convert your ephemeris from ECEF coordinates (lat/long, rotates with earth) to ECI (inertial coordinates, fixed with respect to the stars) to use Kelso's formulas.
The basic idea is to compute both the satellite and observer positions at a given instant in ECI coordinates, then define the "east", "north", and "up" basis vectors for the site-specific coordinate system at that instant (accounting for the earth's oblateness), then convert the satellite position into look angles (azimuth and elevation, or right ascension and declination) as seen from the observing site.