Astronomy Engine

repository·master·Indexed 21 days ago

https://github.com/cosinekitty/astronomy

A high-performance, lightweight suite of libraries for calculating celestial body positions and predicting astronomical events such as eclipses, moon phases, and planetary transits. It provides implementations and examples for C, C#, Java, Kotlin, Node.js, and web browsers, featuring capabilities for coordinate transformations, rise/set times, and geoid functions for geographic triangulation.

Tokens
173.6K
Snippets
667
Records
1.1K
Agent score
74%

What's inside Astronomy Engine

  1. Overview of Astronomy Engine (JavaScript/TypeScript)

    master

    Astronomy Engine is a comprehensive library for astronomical calculations. The JavaScript/TypeScript version supports:

    • Client-side programming in the browser.
    • Backend use in Node.js.

    The library is generated from a single TypeScript source (astronomy.ts) and provides several distribution formats:

    • astronomy.js: Human-readable JavaScript.
    • astronomy.browser.min.js: Minified version optimized for browsers.
    • astronomy.min.js: Minified version optimized for Node.js.
    • astronomy.ts: The raw TypeScript source for direct usage.
  2. Overview of Astronomy Engine features

    master

    Astronomy Engine is a suite of open source libraries designed to calculate the positions of celestial bodies and predict astronomical events. It is optimized to be small, fast, and accurate to within $\pm$1 arcminute.

    Core Capabilities:

    • Celestial Body Positions: Calculates positions for the Sun, Moon, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, and Pluto.
    • Coordinate Systems: Provides heliocentric and geocentric Cartesian vectors. Supports conversions between Equatorial J2000, Equatorial equator-of-date, Ecliptic J2000, Topocentric Horizontal, and Galactic (IAU 1958) orientations.
    • Observer-based Calculations: Determines apparent horizon-based positions for any observer on Earth given latitude, longitude, and elevation (in meters), with optional atmospheric refraction correction.
    • Event Prediction:
      • Rise, set, and culmination times for the Sun, Moon, and planets.
      • Civil, nautical, and astronomical twilight (dawn/dusk).
      • Moon phases (new, first quarter, full, third quarter).
      • Lunar and solar eclipses.
      • Transits of Mercury and Venus.
      • Equinoxes and solstices.
      • Planetary conjunctions, oppositions, and apsides.
      • Maximum elongation for Mercury and Venus.
    • Advanced Features:
      • Visual magnitude determination.
      • Jupiter's moon positions (Io, Europa, Ganymede, Callisto).
      • Custom simulation of user-defined small bodies (asteroids, comets).
      • Constellation identification for sky points.
      • Lunar libration and axis orientation/rotation angles.
  3. Overview of Astronomy Engine Python API topics

    master

    The Astronomy Engine Python API provides a comprehensive suite of tools for astronomical calculations, categorized into several functional areas:

    • Celestial Body Positions: Calculate vectors and coordinates (Right Ascension, Declination, Ecliptic, Horizon) for the Sun, Moon, and planets.
    • Geographic Helpers: Convert between geocentric vectors and observer-specific geographic coordinates.
    • Time-based Events: Search for rise, set, and culmination times, as well as specific altitudes (e.g., for twilight).
    • Lunar & Planetary Cycles: Calculate moon phases, eclipses, transits, lunar apsides (perigee/apogee), and planetary apsides (perihelion/aphelion).
    • Visual Properties: Calculate visual magnitude, elongation, and illumination.
    • Coordinate Transformations: Convert vectors between various orientation systems (EQJ, EQD, ECL, ECT, HOR, GAL) using rotation matrices.
    • Gravitational Simulation: Use the GravitySimulator class to model the trajectories of small bodies (asteroids, comets, spacecraft) under the gravitational influence of the Sun and planets.
  4. Explore Astronomy Engine examples in C

    master

    The demo/c/ directory contains several example programs demonstrating various astronomical calculations using the Astronomy Engine C API. These examples cover topics such as coordinate transformations, celestial body positions, and time calculations.

    Key capabilities demonstrated in the examples include:

    • Celestial Body Positions: Calculating equatorial and horizontal coordinates for the Sun, Moon, and planets (positions.c).
    • Rise/Set Times: Calculating sunrise, sunset, moonrise, and moonset times (riseset.c).
    • Lunar Phenomena: Calculating Moon phases (moonphase.c) and predicting lunar eclipses (lunar_eclipse.c).
    • Coordinate Conversions: Converting galactic coordinates to horizontal coordinates (galactic.c) or finding where the ecliptic intersects the horizon (horizon.c).
    • Time & Seasons: Calculating true solar time using the Sun's hour angle (solar_time.c) and determining equinoxes and solstices (seasons.c).
    • Advanced Geometry: Using geoid functions like VectorObserver and ObserverVector to triangulate geographic coordinates from angular directions (triangulate.c).
    • Imaging: Generating a PNG world map showing sunlight and moonlight intensity on a Mercator projection (worldmap.cpp).
  5. Explore Astronomy Engine Python examples

    master
    The demo/python/ directory contains a collection of practical examples demonstrating how to use the Astronomy Engine in Python for various astronomical calculations. These examples cover topics such as coordinate transformations, celestial body positions, and event prediction.
  6. Available Kotlin demo topics

    master

    The Kotlin demo is organized into separate source files, each representing a specific astronomical topic. You can run any of these by passing their name (lowercase) to the ./rundemo script.

    • constellation: Finds which constellation the Moon is in at a given time and demonstrates binary searching for constellation border crossings.
    • jupitermoons: Calculates coordinates for Jupiter and its four major moons (Io, Europa, Ganymede, Callisto) from Earth, including light-delay corrections.
    • lunareclipse: Searches for the first 10 partial or total lunar eclipses after a specified time.
    • moonphase: Determines the Moon's current phase and predicts the next 10 quarter phases.
    • positions: Displays equatorial and horizontal coordinates for the Sun, Moon, and planets based on observer latitude, longitude, and time.
    • risesetculm: Calculates rise, set, and culmination times for the Sun and Moon.
    • seasons: Calculates equinoxes and solstices for a given calendar year.
  7. What is Terrestrial Time (tt)?

    master

    In the Astronomy Engine, tt is a Double representing Terrestrial Time expressed as the number of days elapsed since noon on January 1, 2000.

    Unlike Universal Time (ut), tt is an atomic time scale that increases uniformly based on SI seconds (divided by 86400) rather than Earth's rotation. This makes it suitable for calculating celestial movements that are independent of Earth's rotation, such as planetary orbits or the Moon's orbit around the Earth.

    Historically, this scale was referred to as Ephemeris Time (ET).

  8. What is the Solar System Barycenter (SSB)?

    master
    The Solar System Barycenter (SSB) is the Solar System's center of gravity. It serves as an inertial reference point that is ideal for simulating the movement of objects within the Solar System. The Sun and all planets revolve around this point. Its position relative to the Sun varies (sometimes inside, sometimes outside) based primarily on the positions of Jupiter, Saturn, Uranus, and Neptune.
  9. What is the Earth/Moon Barycenter (EMB)?

    master

    The Earth/Moon Barycenter (EMB) is the common center of gravity between the Earth and the Moon. It is the point around which both celestial bodies co-orbit.

    Key characteristics:

    • The EMB is located approximately 4670 km from the center of the Earth, positioned toward the Moon's center.
    • Because of this distance, the EMB is always located within the Earth's interior.