Skip to content

v0.2

Latest

Choose a tag to compare

@DRosenman DRosenman released this 22 Apr 18:51
· 5 commits to main since this release

Tidy N-body orbital mechanics for R — this release adds a Keplerian orbital elements interface, built-in solar system data from JPL, and several convenience functions that make it dramatically easier to set up realistic simulations.

New Functions

add_body_keplerian()

Add a body using classical Keplerian orbital elements (semi-major axis, eccentricity, inclination, longitude of ascending node, argument of periapsis, true anomaly) instead of raw Cartesian position and velocity vectors. Elements are converted relative to a parent body that must already exist in the system.

create_system() |>
  add_sun() |>
  add_body_keplerian("Earth", mass = mass_earth, parent = "Sun",
                     a = distance_earth_sun, e = 0.0167, i = 0)

add_planet()

Add a known solar system body by name with real JPL DE440 orbital data looked up automatically. Any element can be overridden for "what if" scenarios.

create_system() |>
  add_sun() |>
  add_planet("Earth", parent = "Sun") |>
  add_planet("Mars", parent = "Sun", e = 0)  # what if Mars had a circular orbit?

add_sun()

Convenience function to add the Sun at the origin. Pairs naturally with add_planet().

create_system() |>
  add_sun() |>
  add_planet("Earth", parent = "Sun")

load_solar_system()

One-liner that builds the complete solar system (Sun + 8 planets + Moon, optionally Pluto) using real JPL DE440 data. Returns a ready-to-simulate system.

load_solar_system() |>
  simulate_system(time_step = seconds_per_day, duration = seconds_per_year) |>
  plot_orbits()

Bug Fixes

  • three_d = FALSE now correctly forces 2D output on plot_orbits(), plot_system(), and animate_system(), even when the data has Z-axis motion. Previously, FALSE could not override auto-detection.
  • Fixed frozen 3D animations in animate_system_3d() caused by redraw = FALSE in plotly animation options.

Documentation

  • New vignette: Keplerian Orbital Elements — explains the six orbital elements and how add_body_keplerian() and add_planet() use them.
  • New section in The Physics vignette covering Keplerian-to-Cartesian conversion.
  • Expanded Examples vignette with Earth-Moon, Sun-Earth-Moon, and Kepler-16 binary star system demos.
  • Expanded Quick Start guide with add_planet() and load_solar_system() workflows.
  • New Further Reading vignette with references to the textbooks and resources behind the engine.
  • 320+ new test assertions covering add_body_keplerian(), add_planet(), and load_solar_system().

Full Changelog

v0.1.0...v0.2.0