SwiftAA Astronomical Algorithms Library

repository·master·Indexed 42 days ago

https://github.com/onekiloparsec/swiftaa

A high-accuracy astronomical algorithms library for Swift that wraps the C++ AA+ library. It provides tools for solar system modeling, celestial body positions, and time computations with unit-safe APIs based on the Astronomical Algorithms textbook by Jean Meeus.

Tokens
572
Snippets
1
Records
4
Agent score
3%

What's inside SwiftAA

  1. Overview of SwiftAA capabilities

    master

    SwiftAA is a comprehensive collection of accurate astronomical algorithms for Swift. It is designed to help developers build solar system models, compute seasonal lengths, moon phases, rise/transit/set times, planetary moon positions, and coordinate transformations with professional-grade accuracy.

    Key features include:

    • Unit Safety: Stronger unit safety compared to the underlying C++ APIs.
    • High Accuracy: Based on the Astronomical Algorithms textbook by Jean Meeus, including VSOP87 framework and ELP/MPP02 theory support.
    • High Test Coverage: Over 90% unit test coverage for the Swift code, validated against USNO, SkySafari, and Xephem data.
  2. Understand the SwiftAA architecture and targets

    master

    SwiftAA is built on top of a C++ implementation of astronomical algorithms called AA+. To bridge these layers, the project uses a C-based layer called AABridge.

    When using Swift Package Manager, there are three distinct targets available. You should only embed the highest-level target you intend to use:

    1. AA+: The core C++ implementation of the Astronomical Algorithms textbook.
    2. AABridge: The C bridge between the C++ code and Swift.
    3. SwiftAA: The modern Swift wrapper providing unit safety and readable APIs.

    Recommendation: For most users, you only need to embed the SwiftAA target, as it transitively depends on the others.

  3. Caution regarding coordinate transformations

    master

    The underlying AA+ implementation follows the conventions found in Jean Meeus' Astronomical Algorithms. However, these do not include modern coordinate conventions like ICRS.

    If your application requires transformations based on modern standards, you should exercise caution or consider using a package like AstroPy for coordinate handling.

  4. Install SwiftAA via Swift Package Manager

    master

    To add SwiftAA to your project using Swift Package Manager (SPM), you can use either the Xcode interface or by manually editing your Package.swift file.

    Via Xcode

    1. Go to File > Swift Packages > Add Package Dependency...
    2. Enter the repository URL: https://github.com/onekiloparsec/SwiftAA.git
    3. Choose the SwiftAA target.

    Via Package.swift

    Add the following line to your dependencies section:

    .package(url: "https://github.com/onekiloparsec/SwiftAA.git", from: "3.0.1")