SGP4

July 26, 2026 ยท View on GitHub

C++17 implementation of the SGP4 satellite orbit propagation algorithm.

Requirements

  • C++17 compiler
  • CMake 3.14+
  • Google Test (fetched automatically)

Building

mkdir build && cd build
cmake ..
cmake --build .

Default install prefix is build/install/. Override with:

cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local

Build options

OptionDefaultDescription
BUILD_EXAMPLESONBuild example programs
BUILD_TESTSONBuild unit tests

Tests

cd build
ctest --output-on-failure

Examples

AppDescription
runtestVerification against SGP4-VER.TLE
sattrackTrack a satellite from a ground observer
passpredictPredict satellite passes over a location
csvpropPropagate satellites from a CelesTrak CSV file

Usage

#include <libsgp4/Tle.h>
#include <libsgp4/SGP4.h>
#include <libsgp4/Eci.h>

libsgp4::Tle tle("SAT NAME",
    "1 35683U 09041C   12289.23158813  .00000484  00000-0  89219-4 0  5863",
    "2 35683  98.0221 185.3682 0001499 100.5295 259.6088 14.69819587172294");
libsgp4::SGP4 sgp4(tle);

libsgp4::Eci eci = sgp4.FindPosition(tle.Epoch());
libsgp4::Vector pos = eci.Position();

Loading from CelesTrak CSV

#include <libsgp4/CsvTleLoader.h>

auto tles = libsgp4::LoadCsvTleFile("path/to/celestrak.csv");
libsgp4::SGP4 sgp4(tles[0]);

Library classes

ClassDescription
SGP4Core propagator
TleTwo-line element set parser
EciPosition/velocity in TEME frame
DateTimeDate/time with microsecond precision
TimeSpanDuration
ObserverGround station observer
CoordGeodeticLat/lon/alt
CoordTopocentricAzimuth/elevation/range
Vector3D/4D vector
OrbitalElementsKeplerian elements

Data

data/geodetic.csv contains a snapshot of CelesTrak geodetic satellites.