Skip to contents

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

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

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.

Examples

# Remove a single body
create_system() |>
  add_sun() |>
  add_planet("Earth", parent = "Sun") |>
  add_planet("Mars",  parent = "Sun") |>
  remove_body("Mars")
#> $bodies
#> # 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
#> 
#> $forces
#> $forces$gravity
#> $forces$gravity$type
#> [1] "n_body_gravity"
#> 
#> $forces$gravity$G
#> [1] 6.6743e-11
#> 
#> 
#> 
#> $time
#> [1] 0
#> 
#> attr(,"class")
#> [1] "orbit_system"

# \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()
# }