Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 9 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ jobs:
set -euo pipefail
git submodule status --recursive
echo
echo "siderust-ffi: $(git -C siderust-ffi rev-parse HEAD) ($(git -C siderust-ffi describe --tags --always 2>/dev/null || true))"
echo "siderust: $(git -C siderust-ffi/siderust rev-parse HEAD) ($(git -C siderust-ffi/siderust describe --tags --always 2>/dev/null || true))"
echo "siderust-ffi: $(git -C siderust/siderust-ffi rev-parse HEAD) ($(git -C siderust/siderust-ffi describe --tags --always 2>/dev/null || true))"
echo "siderust: $(git -C siderust rev-parse HEAD) ($(git -C siderust describe --tags --always 2>/dev/null || true))"

- name: Install system dependencies
shell: bash
Expand Down Expand Up @@ -130,10 +130,11 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
siderust-ffi/target
siderust-ffi/siderust/dev-deps/tempoch/tempoch-ffi/target
qtty-cpp/qtty/target
qtty-cpp/qtty/qtty-ffi/target
siderust/siderust-ffi/target
siderust/target
tempoch-cpp/tempoch/tempoch-ffi/target
tempoch-cpp/qtty-cpp/qtty/target
tempoch-cpp/qtty-cpp/qtty/qtty-ffi/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
Expand Down Expand Up @@ -221,9 +222,8 @@ jobs:
set -euo pipefail
gcovr \
--root . \
--exclude 'build-coverage/.*' \
--exclude 'build-coverage[^/]*/.*' \
--exclude 'siderust/.*' \
--exclude 'qtty-cpp/.*' \
--exclude 'tempoch-cpp/.*' \
--exclude 'tests/.*' \
--exclude 'examples/.*' \
Expand All @@ -237,9 +237,8 @@ jobs:
mkdir -p coverage_html
gcovr \
--root . \
--exclude 'build-coverage/.*' \
--exclude 'build-coverage[^/]*/.*' \
--exclude 'siderust/.*' \
--exclude 'qtty-cpp/.*' \
--exclude 'tempoch-cpp/.*' \
--exclude 'tests/.*' \
--exclude 'examples/.*' \
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ build/
cmake-build-*/
out/
build-*
coverage_html/
coverage.xml
coverage*

# IDE files
.vscode/
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "qtty-cpp"]
path = qtty-cpp
url = git@github.com:VPRamon/qtty-cpp.git
[submodule "tempoch-cpp"]
path = tempoch-cpp
url = git@github.com:Siderust/tempoch-cpp.git
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ add_dependencies(siderust_ffi build_siderust_ffi)
# ---------------------------------------------------------------------------
# Header-only C++ wrapper library
# ---------------------------------------------------------------------------
# Pull in qtty-cpp (unit-safe quantities) as a subdirectory
# Pull in qtty-cpp (unit-safe quantities) via the nested tempoch-cpp checkout
set(QTTY_FFI_FEATURES "" CACHE STRING "Cargo features for qtty-ffi" FORCE)
add_subdirectory(qtty-cpp)
add_subdirectory(tempoch-cpp/qtty-cpp)

# Pull in tempoch-cpp (time types) as a subdirectory
set(TEMPOCH_FFI_FEATURES "" CACHE STRING "Cargo features for tempoch-ffi" FORCE)
add_subdirectory(tempoch-cpp)

# Paths to qtty-ffi shared library (for RPATH)
set(QTTY_SUBMODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qtty-cpp/qtty)
set(QTTY_SUBMODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tempoch-cpp/qtty-cpp/qtty)
set(QTTY_ARTIFACT_DIR ${QTTY_SUBMODULE_DIR}/target/release)

# Paths to tempoch-ffi shared library (for RPATH)
Expand Down Expand Up @@ -122,9 +122,9 @@ endif()

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

# ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ COPY . /workspace
# Fail early if required submodules are missing from the build context.
RUN test -f siderust/siderust-ffi/Cargo.toml && \
test -f tempoch-cpp/tempoch/tempoch-ffi/Cargo.toml && \
test -f qtty-cpp/CMakeLists.txt
test -f tempoch-cpp/qtty-cpp/CMakeLists.txt

# Validate the container toolchain by configuring, building, testing, and generating docs.
RUN rm -rf build && \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ siderust-cpp/
│ ├── test_altitude.cpp
│ └── test_ephemeris.cpp
├── siderust-ffi/ ← git submodule (contains `siderust` as nested submodule)
└── qtty-cpp/ git submodule
└── tempoch-cpp/qtty-cpp/ ← nested git submodule
```

## Architecture
Expand Down
2 changes: 1 addition & 1 deletion docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ MACRO_EXPANSION = NO
SKIP_FUNCTION_MACROS = YES
INCLUDE_PATH = \
"@CMAKE_CURRENT_SOURCE_DIR@/include" \
"@CMAKE_CURRENT_SOURCE_DIR@/qtty-cpp/include" \
"@CMAKE_CURRENT_SOURCE_DIR@/tempoch-cpp/qtty-cpp/include" \
"@CMAKE_CURRENT_SOURCE_DIR@/siderust-ffi/include" \
"@CMAKE_CURRENT_SOURCE_DIR@/siderust-ffi/siderust/dev-deps/tempoch/tempoch-ffi/include"

Expand Down
43 changes: 21 additions & 22 deletions examples/13_coordinate_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
/// cartesian dot product, Euclidean 3D distance, and how type safety prevents
/// accidentally mixing incompatible coordinate systems.
///
/// Build with: cmake --build build-local --target 13_coordinate_operations_example
/// Run with: ./build-local/13_coordinate_operations_example
/// Build with: cmake --build build-local --target
/// 13_coordinate_operations_example Run with:
/// ./build-local/13_coordinate_operations_example

#include <siderust/siderust.hpp>

Expand All @@ -36,8 +37,8 @@ int main() {
// Two well-known stars using EquatorialMeanJ2000 directions.
// Constructor: Direction(azimuth, polar) = Direction(RA, Dec)
spherical::direction::EquatorialMeanJ2000 polaris(
37.9546_deg, // Right Ascension
89.2641_deg // Declination
37.9546_deg, // Right Ascension
89.2641_deg // Declination
);
spherical::direction::EquatorialMeanJ2000 sirius(
101.2872_deg, // Right Ascension
Expand All @@ -62,8 +63,8 @@ int main() {
// Self-separation must be exactly 0
auto self_sep = polaris.angular_separation(polaris);
std::cout << std::setprecision(6);
std::cout << "Self-separation of Polaris = " << self_sep
<< " (must be 0)" << std::endl
std::cout << "Self-separation of Polaris = " << self_sep << " (must be 0)"
<< std::endl
<< std::endl;

// =========================================================================
Expand All @@ -81,13 +82,14 @@ int main() {
double angle_deg = angle_rad * 180.0 / M_PI;

std::cout << std::setprecision(4);
std::cout << "Polaris cartesian: (" << polaris_cart.x << ", " << polaris_cart.y
<< ", " << polaris_cart.z << ")" << std::endl;
std::cout << "Polaris cartesian: (" << polaris_cart.x << ", "
<< polaris_cart.y << ", " << polaris_cart.z << ")" << std::endl;
std::cout << "Sirius cartesian: (" << sirius_cart.x << ", " << sirius_cart.y
<< ", " << sirius_cart.z << ")" << std::endl;
std::cout << std::setprecision(6);
std::cout << " angle_to (Cartesian) = " << angle_rad << " rad = "
<< std::setprecision(4) << angle_deg << "\u00b0" << std::endl;
std::cout << " angle_to (Cartesian) = " << angle_rad
<< " rad = " << std::setprecision(4) << angle_deg << "\u00b0"
<< std::endl;
std::cout << " angular_separation (Vincenty) = " << sep << std::endl;
std::cout << std::scientific << std::setprecision(2);
std::cout << " Difference = "
Expand All @@ -110,24 +112,23 @@ int main() {

std::cout << std::setprecision(6);
std::cout << "dot(North Pole, Equatorial point) = "
<< north_pole_c.dot(equatorial_c)
<< " (must be 0)" << std::endl;
<< north_pole_c.dot(equatorial_c) << " (must be 0)" << std::endl;

// Anti-Polaris: opposite direction on the sky
spherical::direction::EquatorialMeanJ2000 anti_polaris(
qtty::Degree(polaris.ra().value() + 180.0),
qtty::Degree(-polaris.dec().value()));
auto anti_polaris_c = anti_polaris.to_cartesian();
std::cout << "dot(Polaris, anti-Polaris) = "
<< polaris_cart.dot(anti_polaris_c)
<< " (must be -1)" << std::endl
<< polaris_cart.dot(anti_polaris_c) << " (must be -1)" << std::endl
<< std::endl;

// =========================================================================
// 4. Euclidean Distance Between Spherical Positions
// =========================================================================
std::cout << "4. EUCLIDEAN DISTANCE BETWEEN SPHERICAL POSITIONS" << std::endl;
std::cout << "--------------------------------------------------" << std::endl;
std::cout << "--------------------------------------------------"
<< std::endl;

// Approximate heliocentric ecliptic positions (lon, lat, distance)
spherical::position::EclipticMeanJ2000<qtty::AstronomicalUnit> earth(
Expand Down Expand Up @@ -172,7 +173,7 @@ int main() {
auto diff = mars_cart - earth_cart;
std::cout << " Mars \u2212 Earth vector: (" << diff.x() << ", " << diff.y()
<< ", " << diff.z() << ")" << std::endl;
std::cout << " |Mars \u2212 Earth| = " << diff.distance() << std::endl
std::cout << " |Mars \u2212 Earth| = " << diff.magnitude() << std::endl
<< std::endl;

// =========================================================================
Expand All @@ -194,12 +195,10 @@ int main() {
<< " (must be 90\u00b0)" << std::endl
<< std::endl;

std::cout
<< " Type safety note: spherical::direction::EclipticMeanJ2000 and"
<< std::endl;
std::cout
<< " spherical::direction::EquatorialMeanJ2000 are distinct types."
<< std::endl;
std::cout << " Type safety note: spherical::direction::EclipticMeanJ2000 and"
<< std::endl;
std::cout << " spherical::direction::EquatorialMeanJ2000 are distinct types."
<< std::endl;
std::cout << " angular_separation only compiles within the same frame."
<< std::endl
<< std::endl;
Expand Down
Loading