libnova2 is a general purpose, double precision, Celestial Mechanics, Astrometry and Astrodynamics library. It is a successor to libnova with the significant change being use of radians instead of degrees.
- High Precision: 1 arc second or better.
- Ephemerides:
- Major Planets: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto.
- Sun & Moon (ELP82).
- Minor Bodies: Asteroids and Comets.
- Astrometry:
- Aberration, Nutation, Precession, Proper Motion.
- Refraction, Parallax, Airmass.
- Time Systems:
- Julian Day, Sidereal Time, Dynamical Time, Heliocentric Time.
- Coordinates:
- Transformations: Equatorial, Ecliptic, Horizontal, Galactic.
- Rise, Set, and Transit times.
- Angular Separation.
- C compiler (GCC, Clang, MSVC)
- CMake (3.25 or later)
- Optional:
kconfig-frontends(formenuconfigconfiguration)- Doxygen (for API documentation)
dpkg(for building Debian packages)rpm/rpmbuild(for building RPM packages)
libnova2 uses CMake for its build system.
mkdir build && cd build
cmake ..Common Options:
-DBUILD_SHARED_LIBS=OFF: Build static libraries (default isON).-DENABLE_SIMD=ON: Enable AVX SIMD optimizations (Linux/GCC only). Uses auto-vectorization andlibmvecfor fast math.-DCMAKE_BUILD_TYPE=Release: Optimized build.-DCMAKE_INSTALL_PREFIX=/usr: Installation destination.
You can enable or disable specific modules (e.g., planets, theories) using the Kconfig interface:
make menuconfig(Requires kconfig-frontends)
This creates a .config file that CMake will use to select source files.
makesudo make installYou can build .deb and .rpm packages using CPack (from the build directory):
make packageA Python wrapper is available. You can generate a source distribution and a .whl package ready for pip using the python-package target:
make python-packageThe output files will be created in the python/dist/ directory. You can then install the .whl file using pip:
pip install python/dist/libnova2-*.whllibnova2 supports cross-compilation for embedded targets (e.g., ESP32, ARM).
Create a CMake toolchain file for your target. A sample is provided in cmake/toolchain-xtensa-sample.cmake.
mkdir build-cross && cd build-cross
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-xtensa-sample.cmake \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
..Key Cross-Compilation Options:
-DBUILD_TESTING=OFF: Disable unit tests (they likely won't run on the build host).-DBUILD_EXAMPLES=OFF: Disable example programs.HAVE_LIBM: The build system automatically detects iflibmis needed/available, replacing hardcoded UNIX checks.
makeIf you built the tests (default on host builds):
ctest --output-on-failureOr run the test executable details:
./lntest/libnova2_test_execTo generate the HTML API documentation:
make docOutput is in doc/html/index.html.
Include the main header:
#include <libnova2/libnova2.h>Link against libnova2 (and libm if static/required):
cc my_program.c -lnova2 -lm -o my_programFor more examples, see the examples/ directory.
