Skip to contents

Drops bodies by name from an `orbit_system`. This is the counterpart to [add_body()] — use it to strip out bodies you no longer need before simulating, or to prune a system built with [load_solar_system()].

Usage

remove_body(system, id)

Arguments

system

An `orbit_system` object.

id

A character vector of body names to remove. All names must exist in the system.

Value

The updated `orbit_system` with the specified bodies removed.

Details

“` load_solar_system() |> remove_body(c("Pluto", "Moon")) |> simulate_system(time_step = seconds_per_day, duration = seconds_per_year) “`

Examples

# Remove a single body
create_system() |>
  add_sun() |>
  add_planet("Earth", parent = "Sun") |>
  add_planet("Mars",  parent = "Sun") |>
  remove_body("Mars")
#> ───────────────────────────────── orbit_system ───────────────────────────────── 
#> G: 6.6743e-11 (standard)
#> Bodies: 2
#> 
#> # A tibble: 2 × 8
#>   id       mass             x             y     z      vx     vy    vz
#>   <chr>   <dbl>         <dbl>         <dbl> <dbl>   <dbl>  <dbl> <dbl>
#> 1 Sun   1.99e30            0             0      0      0      0      0
#> 2 Earth 5.97e24 -32965585121. 143360295956.     0 -29520. -6788.     0

# \donttest{
# Remove multiple bodies from the full solar system
load_solar_system() |>
  remove_body(c("Pluto", "Moon")) |>
  simulate_system(time_step = seconds_per_day, duration = seconds_per_year) |>
  plot_orbits()
# }