Orbits
This will be a multi part series about Orbits and the GPS system.
- Part 1: Satellite Orbits (This Post)
Part 2: GPS Satellites and Distances [WIP]Part 3: Correcting for non-precise time [WIP]
Before getting into the GPS part of this series we first need to know some simple things about GPS.
There are many different GPS Satellites but they operate on the same principal. They have multiple atomic clocks which are used to get a precise time. Then send that time in a RF signal to earth so that devices can retrieve that time and use it to calculate how long it took to get there. Using the time distance and knowing that the RF signal will be traveling at the Speed of light you can get the distance from the satellite to the receiver(You). Using at least 3 (when you also have a atomic clock) or 4 you can figure out where in space you are located. Then you can convert this to latitude, longitude and height on the earth.
The USA-132 GPS Satellite has 4 atomic clocks. 2 Cesium atomic clocks that operate at 9.192GHz and 2 Rubidium atomic clocks that operate at 6.835GHz.
GPS Satellites are satellites not in geosynchronous orbit(Travel at the same speed as the earths rotation). They actually orbit the earth a bit over 2 times a day. You can see this in the [Getting the Satellite Parameters](#Getting the Satellite Parameters) Section.
So the first step is knowing where the GPS satellites were/are at a specific time. So here is a quick crash corse on Orbital Mechanics.
Introduction to 2D Orbital Mechanics
Lets break this into
2D Ellipse Vocabulary:
- Perigee: The point where the satellite is the nearest to the earth. It is also when the satellite has the greatest velocity and acceleration.
- Apogee: The point where the satellite is the farthest from the earth. It is also when the satellite has the least velocity and acceleration.
- Periapsis: The distance from the earth to the
perigee
point. - Apoapsis: The distance from the earth to the
apogee
point. - Focus (Foci): The points in an ellipse where the mass must reside so that the orbit is periodic. One of these spots is where the Earth is.
- Semi-minor Axis: The shortest radius of the ellipse. Measured from the
Perigee
to the center of the ellipse. - Semi-major Axis (a): The longest radius of the ellipse. Measured from the
Apogee
to the center of the ellipse. - Eccentricity (e): The ratio of the
Perigee
andApogee
radius. Describes how circular the orbit is. - Mean Motion: The average rate of speed measured in rotations per day.
Now that we have the vocabulary lets look at the Math the connects this together.
Using Mean Motion to find the Semi-major Axis:
Calculating the Semi-minor Axis from the Semi-major Axis :
Calculating the Focus/Earth Position:
Calculating the Position of the Satellite
The Mean Anomaly
is the value given to us as a parameter from the satellite equation. Since this is the average anomaly it is easy to advance this parameter forwards or backwards using a constant. This allows us to not have to account for the change in velocity and acceleration depending how close it is to earth.
Using both the Mean Anomaly
and Eccentricity
you can calculate the Eccentric Anomaly
. This is an intermediary calculation that is used to calculate the location of the satellite. The way to calculate this is done in a infinite series but since each change approaches zero you can set a limit. This intermediate step is the angle from the center to where the satellite would be if the orbit was a circle.
True Anomaly
is the angle from the earth to the satellite’s position. If this is 0 degrees then the satellite is at the Apogee. This is calculated using the Eccentric Anomaly
and Eccentricity
using Trigonometry.
Defining the position along an orbit:
- True Anomaly: The angle from the
perigee
to the satellite position. This is centered on earth. - Mean Anomaly: The average motion of the satellite throughout its orbit. Is computed from the earth gravitational constant and the semi-major axis. This is centered on the center of the ellipse orbit.
- Eccentric Anomaly: This is the location where the satellite would be if the orbit was a circle. This is used to calcualte the true anomaly. This is centered on the center of the ellipse orbit.
This interactive will show you the relationship between each of the Anomalies. You can change the settings so that you get a better feel how each of the parameters influence each other.
Using Math
Eccentric Anomaly is calculated using steps to approach the correct value. This is done by nudging the value closer to the real value. So you have to use a cutoff value of some small number.
Use Mean Anomaly to calculate Eccentric Anomaly:
Since True Anomaly has the same x value using some Trigonometry equations you can get the angle from the orbit perigee.
Eccentric to True Anomaly:
Now you have the true angle from the earth and can use that to calculate the distance from the earth with the equation below.
The Distance from the earth to the satellite:
3D Elliptical Satellite Orbits
As you transition from 2D to 3D there is more vocab that we need to define. So we can get in to the orbital parameters.
3D Elliptical Vocabulary:
- Ascending Node: The point where the orbit passes through the XY axis going from negative Z value to positive Z value. This is the point where the Yellow and Teal arcs meet.
- Descending Node: The point where the orbit passes through the XY axis going from positive Z value to negative Z value
- Line of Nodes: The line on the XY plane that goes through the
Ascending
andDescending Nodes
.
To define the 3D part of the elliptical orbit three parameters must be given. Where Inclination
, Argument of periapsis
, and RANN
are rotations of the 2D elliptical orbit in the X, Y and Z axis.
- Inclination: The angle that the orbit is tilted from the equator towards the north pole.
- RAAN: Is the angle from the x axis to where the orbit intersects the
xy
plane where the satellite came from below the xy plane to above the xy plane. AkaRight Ascension of the Ascending Node
orLongitude of the Ascending Node
- Argument of periapsis: Is the angle from the
Ascending Node
to thePerigee
.
Here is a 3d Representation of the Orbit. Have fun modifying the orbital parameters and using the mouse to change the camera.
Getting the Satellite Parameters
There is a website that you can use to get the parameters. Its called CelesTrak which is a 501(c)(3) non-profit that tracks this information.
Here are the information for the GPS satellite NAVSTAR 43 (USA 132)(ID=24876).
curl https://celestrak.org/NORAD/elements/gp.php?CATNR=24876&FORMAT=TLE
NAVSTAR 43 (USA 132)
1 24876U 97035A 24345.27731839 .00000058 00000+0 00000+0 0 9990
2 24876 55.7327 120.2454 0086137 54.9413 305.8431 2.00561901200849
Parsing the Information
The way the TLE data is formatted it is a strict standard with constant width information with fixed decimal places. You can see how the data is parsed below. The data we are looking for is in the second line which contains
- Inclination in degrees (55.7327°)
- Right Ascension of the Ascending Node (RAAN) in degrees (120.2454°)
- Eccentricity but only containing the decimal part (0086137 = 0.0086137)
- Argument of periapsis in degrees (54.9413°)
- Mean Anomaly in degrees (305.8431°)
- Mean Motion in revolutions per day (2.00561901200849)
Parsing the Parameter Information:
function setParametersFromTLE(lines) {
const line2 = lines[2];
//2 24876 55.7327 120.2454 0086137 54.9413 305.8431 2.00561901200849
// Parse line 2 for the orbital parameters
let inclination = parseFloat(line2.substring(8, 16)).toFixed(4); // 55.7327 Degrees
let raan = parseFloat(line2.substring(17, 25)).toFixed(4); // 120.2454 Degrees
let eccentricityStr = line2.substring(26, 33).trim(); // "0086137"
let eccentricity = parseFloat('0.' + eccentricityStr).toFixed(6); // Convert to decimal 0.0086137
let argument = parseFloat(line2.substring(34, 42)).toFixed(4); // 54.9413 Degrees
let manomaly = parseFloat(line2.substring(43, 51)).toFixed(4); // 305.8431 Degrees
let mmotion = parseFloat(line2.substring(52, 63)).toFixed(10); // 2.00561901200849 Revolutions per day
return {
inclination,
raan,
eccentricity,
argument,
manomaly,
mmotion
};
}
3D Location of the Satellite
Using the same EQs from before you can find out the location of the satellite on the 2D plane. Adter that you can use the inclination, raan and argument variables to rotate the X,Y and Z axis.
Putting it all together:
function keplerToECI(semiMajorAxis, eccentricity, i, raan, omega, M) {
// Solve Kepler's equation to find Eccentric Anomaly (E)
let ecc_anomaly = mean2eccentric(M, eccentricity);
// Compute True Anomaly (nu) from ecc_anomaly
const trueAnomaly = eccToTrueAnomaly(ecc_anomaly, eccentricity);
// Compute orbital radius (r)
const radius = getOrbitalRadius(trueAnomaly, semiMajorAxis, eccentricity);
// Position in the orbital plane
const xPrime = radius * Math.cos(trueAnomaly);
const yPrime = radius * Math.sin(trueAnomaly);
// Rotate to ECI coordinates
const cosOmega = Math.cos(THREE.MathUtils.degToRad(raan));
const sinOmega = Math.sin(THREE.MathUtils.degToRad(raan));
const cosInclination = Math.cos(THREE.MathUtils.degToRad(i));
const sinInclination = Math.sin(THREE.MathUtils.degToRad(i));
const cosArgPerigee = Math.cos(THREE.MathUtils.degToRad(omega));
const sinArgPerigee = Math.sin(THREE.MathUtils.degToRad(omega));
const x1 = xPrime * cosArgPerigee - yPrime * sinArgPerigee;
const y1 = xPrime * sinArgPerigee + yPrime * cosArgPerigee;
const z1 = 0;
const x2 = x1;
const y2 = y1 * cosInclination - z1 * sinInclination;
const z2 = y1 * sinInclination + z1 * cosInclination;
const xECI = x2 * cosOmega - y2 * sinOmega;
const yECI = x2 * sinOmega + y2 * cosOmega;
const zECI = z2;
return new THREE.Vector3(xECI / scale, yECI / scale, zECI / scale); // Scale down for visualization
}