Shift the coordinate reference frame of the simulation
Source:R/shift_reference_frame.R
shift_reference_frame.RdRecalculates the positions and velocities of all bodies relative to a specific target body. This effectively "anchors the camera" to the chosen body, placing it at the origin (0, 0, 0) for all time steps.
Examples
# \donttest{
# Simulate Sun-Earth-Moon
orbit_data <- create_system() |>
add_sun() |>
add_body("Earth", mass = mass_earth, x = distance_earth_sun, vy = speed_earth) |>
add_body("Moon", mass = mass_moon, x = distance_earth_sun + distance_earth_moon,
vy = speed_earth + speed_moon) |>
simulate_system(time_step = seconds_per_hour, duration = seconds_per_year)
# Shift view to Earth and plot
orbit_data |>
shift_reference_frame(center_id = "Earth") |>
plot_orbits()
# }