Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9603c7c
Add azimuth and lunar phase computations, enhance target handling
Feb 24, 2026
7054e73
feat: implement BodyTarget and StarTarget classes for celestial objec…
Feb 24, 2026
ebbc59b
Enhance documentation and examples for siderust-cpp
Feb 24, 2026
2617f9c
refactor: streamline output for crossing direction and culmination ki…
Feb 24, 2026
346ca20
Refactor target handling and streamline output formatting
Feb 25, 2026
716d734
Refactor test cases for consistency and readability
Feb 25, 2026
8209368
refactor: unify Target interface for celestial objects and update rel…
Feb 25, 2026
443f7f4
refactor: update .gitignore and add CI script for Docker integration
Feb 25, 2026
48acce3
Add body-centric transformations and Mars example
Feb 25, 2026
fcd72ba
feat: add basic_coordinates_example and update CMake configuration
Feb 25, 2026
bd35926
Add examples for serialization, Kepler orbits, root finding, moon pha…
Feb 26, 2026
54db5bc
refactor: simplify output formatting and improve Position constructor…
Feb 26, 2026
4beb428
feat: add frame transformation methods for cartesian and spherical co…
Feb 26, 2026
179de19
Remove deprecated example files and enhance azimuth and position tran…
Feb 28, 2026
da4cb14
refactor: streamline output formatting in examples for better readabi…
Feb 28, 2026
6c686ab
Refactor serialization examples in C++ and enhance ephemeris function…
Feb 28, 2026
1dedecd
refactor: update examples and tests to use quantity literals for bett…
Feb 28, 2026
322f27e
Add Subject API and related tests
Feb 28, 2026
c439416
refactor: update below_threshold method to use target handling for im…
Feb 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 4
ContinuationIndentWidth: 4
ColumnLimit: 0
PointerAlignment: Left
ReferenceAlignment: Left
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
...
IndentWidth: 2
ColumnLimit: 80
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: All
AllowShortEnumsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AlwaysBreakTemplateDeclarations: MultiLine

6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
build/
cmake-build-*/
out/
build-make/
build-verify/
build-ci-config-check/
build-*
coverage_html/
coverage.xml

# IDE files
.vscode/
Expand Down
100 changes: 46 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ endif()
# Build siderust-ffi (depends on tempoch-ffi via tempoch-cpp subdirectory)
add_custom_target(
build_siderust_ffi
COMMAND ${CARGO_BIN} build --release ${_SIDERUST_FEATURES_ARGS}
# Use `cargo rustc --crate-type cdylib` so that the shared library is
# produced even though Cargo.toml only lists rlib (which keeps coverage
# instrumentation clean during `cargo test`/`cargo llvm-cov`).
COMMAND ${CARGO_BIN} rustc --release --crate-type cdylib ${_SIDERUST_FEATURES_ARGS}
WORKING_DIRECTORY ${SIDERUST_FFI_DIR}
BYPRODUCTS ${SIDERUST_LIBRARY_PATH}
DEPENDS build_tempoch_ffi
COMMENT "Building siderust-ffi via Cargo"
COMMENT "Building siderust-ffi via Cargo (cdylib override)"
VERBATIM
)

Expand Down Expand Up @@ -101,23 +104,27 @@ if(SIDERUST_BUILD_DOCS)
set(SIDERUST_DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.siderust_cpp)
configure_file(${SIDERUST_DOXYFILE_IN} ${SIDERUST_DOXYFILE_OUT} @ONLY)

add_custom_target(docs
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen
COMMAND ${DOXYGEN_EXECUTABLE} ${SIDERUST_DOXYFILE_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
if(NOT TARGET docs)
add_custom_target(docs
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen
COMMAND ${DOXYGEN_EXECUTABLE} ${SIDERUST_DOXYFILE_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
else()
message(STATUS "Top-level 'docs' target already exists; skipping creation to avoid conflict with subprojects")
endif()
else()
message(STATUS "Doxygen not found; 'docs' target will not be available")
endif()
endif()

# RPATH for shared library lookup at runtime
if(APPLE)
set(_siderust_rpath "@loader_path/../siderust/target/release;@loader_path/../tempoch-cpp/tempoch/tempoch-ffi/target/release;@loader_path/../qtty-cpp/qtty/target/release")
set(_siderust_rpath "@loader_path/../siderust/siderust-ffi/target/release;@loader_path/../tempoch-cpp/tempoch/tempoch-ffi/target/release;@loader_path/../qtty-cpp/qtty/target/release")
elseif(UNIX)
set(_siderust_rpath "$ORIGIN/../siderust/target/release:$ORIGIN/../tempoch-cpp/tempoch/tempoch-ffi/target/release:$ORIGIN/../qtty-cpp/qtty/target/release")
set(_siderust_rpath "$ORIGIN/../siderust/siderust-ffi/target/release:$ORIGIN/../tempoch-cpp/tempoch/tempoch-ffi/target/release:$ORIGIN/../qtty-cpp/qtty/target/release")
endif()

# ---------------------------------------------------------------------------
Expand All @@ -135,52 +142,35 @@ FetchContent_MakeAvailable(googletest)
enable_testing()

# ---------------------------------------------------------------------------
# Example
# Example helper: add an example only if its source file exists.
# ---------------------------------------------------------------------------
add_executable(siderust_demo examples/demo.cpp)
target_link_libraries(siderust_demo PRIVATE siderust_cpp)
if(DEFINED _siderust_rpath)
set_target_properties(siderust_demo PROPERTIES
BUILD_RPATH ${_siderust_rpath}
INSTALL_RPATH ${_siderust_rpath}
)
endif()

add_executable(coordinates_examples examples/coordinates_examples.cpp)
target_link_libraries(coordinates_examples PRIVATE siderust_cpp)
if(DEFINED _siderust_rpath)
set_target_properties(coordinates_examples PROPERTIES
BUILD_RPATH ${_siderust_rpath}
INSTALL_RPATH ${_siderust_rpath}
)
endif()

add_executable(coordinate_systems_example examples/coordinate_systems_example.cpp)
target_link_libraries(coordinate_systems_example PRIVATE siderust_cpp)
if(DEFINED _siderust_rpath)
set_target_properties(coordinate_systems_example PROPERTIES
BUILD_RPATH ${_siderust_rpath}
INSTALL_RPATH ${_siderust_rpath}
)
endif()
macro(siderust_add_example target_name source_file)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${source_file}")
add_executable(${target_name} ${source_file})
target_link_libraries(${target_name} PRIVATE siderust_cpp)
if(DEFINED _siderust_rpath)
set_target_properties(${target_name} PROPERTIES
BUILD_RPATH ${_siderust_rpath}
INSTALL_RPATH ${_siderust_rpath}
)
endif()
endif()
endmacro()

add_executable(solar_system_bodies_example examples/solar_system_bodies_example.cpp)
target_link_libraries(solar_system_bodies_example PRIVATE siderust_cpp)
if(DEFINED _siderust_rpath)
set_target_properties(solar_system_bodies_example PROPERTIES
BUILD_RPATH ${_siderust_rpath}
INSTALL_RPATH ${_siderust_rpath}
)
endif()
# ---------------------------------------------------------------------------
# Examples
# ---------------------------------------------------------------------------

add_executable(altitude_events_example examples/altitude_events_example.cpp)
target_link_libraries(altitude_events_example PRIVATE siderust_cpp)
if(DEFINED _siderust_rpath)
set_target_properties(altitude_events_example PROPERTIES
BUILD_RPATH ${_siderust_rpath}
INSTALL_RPATH ${_siderust_rpath}
)
endif()
# Numbered mirror examples (03–21, mirroring siderust Rust examples)
siderust_add_example(03_all_frame_conversions_example examples/03_all_frames_conversions.cpp)
siderust_add_example(04_all_center_conversions_example examples/04_all_center_conversions.cpp)
siderust_add_example(05_target_tracking_example examples/05_target_tracking.cpp)
siderust_add_example(06_night_events_example examples/06_night_events.cpp)
siderust_add_example(07_moon_properties_example examples/07_moon_properties.cpp)
siderust_add_example(08_solar_system_example examples/08_solar_system.cpp)
siderust_add_example(09_star_observability_example examples/09_star_observability.cpp)
siderust_add_example(10_time_periods_example examples/10_time_periods.cpp)
siderust_add_example(11_serde_serialization_example examples/11_serde_serialization.cpp)

# ---------------------------------------------------------------------------
# Tests
Expand All @@ -193,6 +183,8 @@ set(TEST_SOURCES
tests/test_bodies.cpp
tests/test_altitude.cpp
tests/test_ephemeris.cpp
tests/test_bodycentric.cpp
tests/test_subject.cpp
)

add_executable(test_siderust ${TEST_SOURCES})
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
libssl-dev \
graphviz \
rsync \
clang-format \
clang-tidy \
gcovr \
&& rm -rf /var/lib/apt/lists/*

RUN curl -fsSL "https://github.com/doxygen/doxygen/releases/download/Release_1_16_1/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz" -o /tmp/doxygen.tar.gz && \
Expand Down
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,39 @@ Modern, header-only C++17 wrapper for **siderust** — a high-precision astronom
|--------|-------------|
| **Time** (`time.hpp`) | `JulianDate`, `MJD`, `UTC`, `Period` — value types with arithmetic and UTC round-trips |
| **Coordinates** (`coordinates.hpp`) | Modular typed API (`coordinates/{geodetic,spherical,cartesian,types}.hpp`) plus selective alias headers under `coordinates/types/{spherical,cartesian}/...` |
| **Frames & Centers** (`frames.hpp`, `centers.hpp`) | Compile-time frame/center tags and transform capability traits |
| **Bodies** (`bodies.hpp`) | `Star` (RAII, catalog + custom), `Planet` (8 planets), `ProperMotion`, `Orbit` |
| **Observatories** (`observatories.hpp`) | Named sites: Roque de los Muchachos, Paranal, Mauna Kea, La Silla |
| **Altitude** (`altitude.hpp`) | Sun / Moon / Star / ICRS altitude: instant, above/below threshold, crossings, culminations |
| **Azimuth** (`azimuth.hpp`) | Sun / Moon / Star / ICRS azimuth: instant, crossings, extrema, range windows |
| **Targets** (`trackable.hpp`, `target.hpp`, `body_target.hpp`, `star_target.hpp`) | Polymorphic tracking with `Trackable`, `Target`, `BodyTarget`, and `StarTarget` |
| **Lunar Phase** (`lunar_phase.hpp`) | Phase geometry/labels, principal phase events, illumination window search |
| **Ephemeris** (`ephemeris.hpp`) | VSOP87 Sun/Earth positions, ELP2000 Moon position |

## Quick Start

```cpp
#include <siderust/siderust.hpp>
#include <cstdio>
#include <iostream>

int main() {
using namespace siderust;
using namespace qtty::literals;

auto obs = ROQUE_DE_LOS_MUCHACHOS;
auto jd = JulianDate::from_utc({2026, 7, 15, 22, 0, 0});
auto mjd = MJD::from_jd(jd);
auto win = Period(mjd, mjd + qtty::Day(1.0));

// Sun altitude
qtty::Radian alt = sun::altitude_at(obs, mjd);
std::printf("Sun altitude: %.4f rad\n", alt.value());
qtty::Degree sun_alt = sun::altitude_at(obs, mjd).to<qtty::Degree>();
qtty::Degree sun_az = sun::azimuth_at(obs, mjd);
std::cout << "Sun alt=" << sun_alt.value() << " deg"
<< " az=" << sun_az.value() << " deg\n";

// Star from catalog
const auto& vega = VEGA;
qtty::Radian star_alt = star_altitude::altitude_at(vega, obs, mjd);
std::printf("Vega altitude: %.4f rad\n", star_alt.value());
Target fixed(279.23473, 38.78369); // Vega-like ICRS target
std::cout << "Target alt=" << fixed.altitude_at(obs, mjd).value() << " deg\n";

// Night periods (astronomical twilight)
auto nights = sun::below_threshold(obs, mjd, mjd + 1.0, -18.0_deg);
for (auto& p : nights)
std::printf("Night: MJD %.4f – %.4f\n", p.start_mjd(), p.end_mjd());
auto nights = sun::below_threshold(obs, win, qtty::Degree(-18.0));
std::cout << "Astronomical-night periods in next 24h: " << nights.size() << "\n";

return 0;
}
Expand All @@ -65,6 +66,8 @@ cmake --build .
./coordinate_systems_example
./solar_system_bodies_example
./altitude_events_example
./trackable_targets_example
./azimuth_lunar_phase_example

# Run tests
ctest --output-on-failure
Expand Down Expand Up @@ -153,6 +156,12 @@ siderust-cpp/
│ ├── bodies.hpp ← Star, Planet, ProperMotion
│ ├── observatories.hpp ← named observatory locations
│ ├── altitude.hpp ← sun/moon/star altitude API
│ ├── azimuth.hpp ← azimuth queries and events
│ ├── lunar_phase.hpp ← moon phase geometry and events
│ ├── trackable.hpp ← polymorphic trackable interface
│ ├── target.hpp ← fixed ICRS target (RAII)
│ ├── body_target.hpp ← body enum trackable adapter
│ ├── star_target.hpp ← star trackable adapter
│ └── ephemeris.hpp ← VSOP87/ELP2000 positions
├── examples/demo.cpp
├── tests/
Expand Down
32 changes: 19 additions & 13 deletions docs/mainpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ codebase without writing a single line of Rust.
| **Bodies** (`bodies.hpp`) | `Star` (RAII, catalog + custom), `Planet` (8 planets), `ProperMotion`, `Orbit` |
| **Observatories** (`observatories.hpp`) | Named sites: Roque de los Muchachos, Paranal, Mauna Kea, La Silla |
| **Altitude** (`altitude.hpp`) | Sun / Moon / Star / ICRS altitude: instant, above/below threshold, crossings, culminations |
| **Azimuth** (`azimuth.hpp`) | Sun / Moon / Star / ICRS azimuth: instant, crossings, extrema, range windows |
| **Targets** (`trackable.hpp`, `target.hpp`, `body_target.hpp`, `star_target.hpp`) | Polymorphic target tracking across bodies, stars, and fixed ICRS directions |
| **Lunar Phase** (`lunar_phase.hpp`) | Moon phase geometry, labels, principal phase events, illumination windows |
| **Ephemeris** (`ephemeris.hpp`) | VSOP87 Sun/Earth positions, ELP2000 Moon position |

---
Expand All @@ -29,29 +32,27 @@ codebase without writing a single line of Rust.

```cpp
#include <siderust/siderust.hpp>
#include <cstdio>
#include <iostream>
#include <iomanip>

int main() {
using namespace siderust;
using namespace qtty::literals;

auto obs = ROQUE_DE_LOS_MUCHACHOS;
auto jd = JulianDate::from_utc({2026, 7, 15, 22, 0, 0});
auto mjd = MJD::from_jd(jd);
auto win = Period(mjd, mjd + qtty::Day(1.0));

// Sun altitude at the observatory
qtty::Radian alt = sun::altitude_at(obs, mjd);
std::printf("Sun altitude: %.4f rad\n", alt.value());
qtty::Degree sun_alt = sun::altitude_at(obs, mjd).to<qtty::Degree>();
qtty::Degree sun_az = sun::azimuth_at(obs, mjd);
std::cout << "Sun alt=" << sun_alt.value() << " deg"
<< " az=" << sun_az.value() << " deg\n";

// Star from built-in catalog
const auto& vega = VEGA;
qtty::Radian star_alt = star_altitude::altitude_at(vega, obs, mjd);
std::printf("Vega altitude: %.4f rad\n", star_alt.value());
Target fixed(279.23473, 38.78369); // Vega-like fixed ICRS target
std::cout << "Target alt=" << fixed.altitude_at(obs, mjd).value() << " deg\n";

// Astronomical night periods (twilight < -18°)
auto nights = sun::below_threshold(obs, mjd, mjd + 1.0, -18.0_deg);
for (auto& p : nights)
std::printf("Night: MJD %.4f – %.4f\n", p.start_mjd(), p.end_mjd());
auto nights = sun::below_threshold(obs, win, qtty::Degree(-18.0));
std::cout << "Astronomical-night periods in next 24h: " << nights.size() << "\n";

return 0;
}
Expand Down Expand Up @@ -112,6 +113,8 @@ cmake --build .
./coordinate_systems_example
./solar_system_bodies_example
./altitude_events_example
./trackable_targets_example
./azimuth_lunar_phase_example

# Run tests
ctest --output-on-failure
Expand All @@ -130,6 +133,9 @@ ctest --output-on-failure
- `siderust/bodies.hpp` — `Star`, `Planet`, and orbital / proper-motion types
- `siderust/observatories.hpp` — known observatory locations and custom geodetic points
- `siderust/altitude.hpp` — Sun / Moon / Star altitude queries and event search
- `siderust/azimuth.hpp` — azimuth queries, crossings, extrema, and azimuth ranges
- `siderust/trackable.hpp`, `siderust/target.hpp`, `siderust/body_target.hpp`, `siderust/star_target.hpp` — target abstractions and polymorphic tracking
- `siderust/lunar_phase.hpp` — moon phase geometry, labels, phase events, illumination windows
- `siderust/ephemeris.hpp` — VSOP87 / ELP2000 position queries

---
Expand Down
Loading
Loading