| add_sun | R Documentation |
A convenience function that adds the Sun as the central body of a simulation. By default it is placed at the origin with zero velocity, which is the natural choice for a heliocentric reference frame. Position and velocity can be overridden for advanced use cases such as barycentric coordinates.
add_sun(system, mass = mass_sun, x = 0, y = 0, z = 0, vx = 0, vy = 0, vz = 0)
system |
An 'orbit_system' object created by [create_system()]. |
mass |
Mass of the Sun in kilograms. Defaults to [mass_sun] (1.989 x 10^30 kg). |
x |
Initial X-axis position in meters (default 0). |
y |
Initial Y-axis position in meters (default 0). |
z |
Initial Z-axis position in meters (default 0). |
vx |
Initial velocity along the X-axis in m/s (default 0). |
vy |
Initial velocity along the Y-axis in m/s (default 0). |
vz |
Initial velocity along the Z-axis in m/s (default 0). |
This pairs naturally with [add_planet()]:
“' create_system() |> add_sun() |> add_planet("Earth", parent = "Sun") |> add_planet("Mars", parent = "Sun") “'
The updated 'orbit_system' with the Sun added.
# Typical usage — Sun at the origin
create_system() |>
add_sun()
# Full solar system in three lines
create_system() |>
add_sun() |>
add_planet("Earth", parent = "Sun") |>
add_planet("Mars", parent = "Sun") |>
simulate_system(time_step = seconds_per_day, duration = seconds_per_year) |>
plot_orbits()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.