
I wanted to add a feature to my vSky (night sky) program which started as a simple display of night stars. It was updated last year to include the planetary system, and I thought it would be neat if it can display other objects such as meteors and satellites. While silly since satellites would not be visually visible, the program can include it as a list of objects within the visual view.

In order to do that, I need to be able to calculate satellites orbital parameters, so I need SGP math. The SGP module should be an stand-alone include that can just be dropped in any program and re-used. Enter Vallado SGP4.

SGP4 stands for Simplified General Perturbations No. 4, a mathematical algorithm used to predict the position and velocity of satellites and space debris orbiting the Earth. Originally developed by NORAD ~1970, it serves as de facto standard for "orbital propagator". While originally a US military space surveillance effort, it has morphed into a more comprehensive algorithm to include deep-space algorithms.

Fast forward to 2006, a team consisting of David Vallado, Paul Crawford, Richard Hujsak, and T.S. Kelso cleaned up the old FORTRAN code and provided standard implementation using C++, MATLAB, and Pascal. This became de facto standard until today for satellite propagation.

This SGP4 include, is a port of the C code from Vallado and as far as I know, probably the first one on the Mac using the BASIC language. 

Instead of meaningless random satellite tests, I decided to make something useful such as a Navigational Satellite tracker. There are over 130 in orbit at any given moment so I thought it would be neat to display what is within visual range.

Most Mac applications involving GPS Satellite tracking, utilize a hardware like a serial GNSS device.

This program approaches this task in a slightly unique way. Since my Mac has no GPS hardware, it is a challenge to display satellites overhead.

However, because the data including orbital parameters of navigation satellites is published, using SGP4, we can calculate the position of any satellite from anywhere in the world. So even without GPS hardware, your Mac can do this!

A note about satellite data.

This program initial fetch includes ALL orbiting Navigational Satellites tracked by NORAD having a unique NORAD catalog number.

Because of this, it doesn't matter where you are on earth, the SGP4 will calculate the satellites positions to determine which are visible from your location providing that your latitude and longitude are correct (the program fills this up automatically using location service).

The accuracy is very good. I was shocked after conducting initial test to discover that it is only off never more than 10 km. While this sounds like a big number, in term of its position in the sky, if you use a Sextant to locate this object, it is less than 0.02 degrees of arc in deviation. So, from a visual point of view, you can't see it being off.

Because of this, there is never a need to get the satellite data more than twice a day. 

Orbiting Satellites have a very exact orbit that can be calculated reliably. Their position in orbit is controlled by time. The SGP4 calculates this and includes drag coefficient that would make the satellite’s path accurate.

This program automatically refreshes the local data file after a new fetch. So technically, after running it once, you can switch to local data source.

The SGP4 automatically recalculates the satellites position. If you fetch every 5 minutes or so (using local data), you can see the orbital movements of the satellites. While your local data has not changed, the calculation knows where the satellite has moved.
This is the beauty of SGP4 propagator engine.

You can skip this part if you are familiar with astronomy.
Since this is a "visibility location" calculator, how do I pinpoint a location in the sky when the program just returns a list with azimuth and elevation degrees? Very simple.

Picture the earth as a hollow glass sphere and you are standing INSIDE the earth at the center.
- From this position, if you look to the front at your eye level, this is the horizon. On the earth surface, that will be the equator line (the direction you are facing is the azimuth).
- If you look straight up, you'd be looking at the North Pole between the north pole and horizon you have "latitude lines" (this is the elevation).
 
So, if you draw an imaginary line from the horizon the zenith on top of your head, you are basically "extending" the earth's longitude
from the horizon to your zenith.
 
Now you draw imaginary lines horizontally as you look up to your zenith, in effect you are drawing "latitude" lines from the equator to the North Pole.
 
For example, given an azimuth of 40 degrees and elevation of 30 degrees for an object:
 
Start by facing the horizon in the correct direction. 40 degrees is approximately Northeast.

Point your left index finger to the horizon and your right index finger straight up. The space between your two fingers is 90 degrees.

Now picture dividing that space into 3 since you need 30 degrees (1/3 of 90). At this point move your top finger straight down to the imaginary spot of 30 degrees "latitude". Your sky object is around there.

June 2026, Raoul Watson
