# Restricted Two Body Equations

*All two-body equations!*

`AstrodynamicalCalculations.R2BPCalculations`

— ModuleCommon calculations within Restricted Two Body Problem dynamics.

**Extended Help**

**Imports**

`Base`

`Core`

`DocStringExtensions`

`LinearAlgebra`

`StaticArrays`

**Exports**

`apoapsis_radius`

`argument_of_periapsis`

`c3`

`cartesian_to_keplerian`

`cartesian_to_perifocal`

`conic`

`eccentricity`

`eccentricity_vector`

`hohmann`

`inclination`

`kepler`

`keplerian_to_cartesian`

`keplerian_to_perifocal`

`lambert`

`mean_motion`

`orbital_period`

`orbital_radius`

`orbital_speed`

`periapsis_radius`

`perifocal_to_cartesian`

`right_ascension_ascending_node`

`semi_parameter`

`semimajor_axis`

`specific_angular_momentum`

`specific_angular_momentum_vector`

`specific_energy`

`specific_potential_energy`

`sphere_of_activity`

`sphere_of_influence`

`time_since_periapsis`

`true_anomaly`

`v_infinity`

`AstrodynamicalCalculations.R2BPCalculations._cross`

— Method```
_cross(x, y, z, ẋ, ẏ, ż)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Return the cross product between two splatted three-vectors.

`AstrodynamicalCalculations.R2BPCalculations.apoapsis_radius`

— Method```
apoapsis_radius(a, e)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns apoapsis distance, rₐ.

`AstrodynamicalCalculations.R2BPCalculations.argument_of_periapsis`

— Method```
argument_of_periapsis(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the argument of periapsis.

`AstrodynamicalCalculations.R2BPCalculations.c3`

— Method```
c3(r, v, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns C3 value.

`AstrodynamicalCalculations.R2BPCalculations.cartesian_to_keplerian`

— Method```
cartesian_to_keplerian(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns a Keplarian representation of a Cartesian orbital state. Algorithm taught in ENAE601.

`AstrodynamicalCalculations.R2BPCalculations.cartesian_to_perifocal`

— Method```
cartesian_to_perifocal(i, Ω, ω, x, y, z, ẋ, ẏ, ż)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the position and velocity vectors in the Perifocal frame.

`AstrodynamicalCalculations.R2BPCalculations.conic`

— Method```
conic(e)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the conic section, as specified by eccentricity `e`

.

`AstrodynamicalCalculations.R2BPCalculations.eccentricity`

— Method```
eccentricity(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns orbital eccentricity, e.

`AstrodynamicalCalculations.R2BPCalculations.eccentricity_vector`

— Method```
eccentricity_vector(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns orbital eccentricity vector e̅.

`AstrodynamicalCalculations.R2BPCalculations.hohmann`

— Method```
hohmann(r₁, r₂, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Computes a Hohmann transfer, and returns the departure and arrival velocity vectors.

`AstrodynamicalCalculations.R2BPCalculations.inclination`

— Method```
inclination(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the orbital inclination.

`AstrodynamicalCalculations.R2BPCalculations.kepler`

— Method```
kepler(x, y, z, ẋ, ẏ, ż, μ, Δt; atol, maxiter)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Solves Kepler's Problem, predicting the orbit's future state geometrically.

`AstrodynamicalCalculations.R2BPCalculations.keplerian_to_cartesian`

— Method```
keplerian_to_cartesian(e, a, i, Ω, ω, ν, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns a Cartesian representation of a Keplerian two-body orbital state in an inertial frame, centered at the center of mass of the central body. Algorithm taught in ENAE601.

`AstrodynamicalCalculations.R2BPCalculations.keplerian_to_perifocal`

— Method```
keplerian_to_perifocal(a, e, ν, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns position and velocity vectors in the Perifocal frame.

`AstrodynamicalCalculations.R2BPCalculations.lambert`

— Method```
lambert(
x₁,
y₁,
z₁,
x₂,
y₂,
z₂,
μ,
Δt;
trajectory,
atol,
maxiter
)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Solves Lambert's problem through the use of univeral variables.

`AstrodynamicalCalculations.R2BPCalculations.lambert_lancaster_blanchard`

— Method```
lambert_lancaster_blanchard(
r̲₁,
r̲₂,
μ,
Δt;
revolutions,
branch,
trajectory,
atol,
maxiter,
output_extrema
)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

The following code was converted to Julia, from a GitHub repository that hosts a MATLAB implementation. At the time of writing, this respository has a BSD license. I'm providing the copyright notice here, as instructed by the license text.

```
Copyright (c) 2018, Rody Oldenhuis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of this project.
```

`AstrodynamicalCalculations.R2BPCalculations.lambert_oldenhuis`

— Method```
lambert_oldenhuis(r1vec, r2vec, tf, m, muC)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

The following code was converted to Julia, from a GitHub repository that hosts a MATLAB implementation. At the time of writing, this respository has a BSD license. I'm providing the copyright notice here, as instructed by the license text.

```
Copyright (c) 2018, Rody Oldenhuis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of this project.
```

`AstrodynamicalCalculations.R2BPCalculations.lancaster_blanchard`

— Method```
lancaster_blanchard(x, q, m)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

The following code was converted to Julia, from a GitHub repository that hosts the MATLAB implementation. At the time of writing, the respository has a BSD license. I'm providing the copyright notice here, as instructed by the license text.

```
Copyright (c) 2018, Rody Oldenhuis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of this project.
```

`AstrodynamicalCalculations.R2BPCalculations.mean_motion`

— Method```
mean_motion(a, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns mean motion, n.

`AstrodynamicalCalculations.R2BPCalculations.minmax_distances`

— Method```
minmax_distances(r̲₁, r̲₂, r₁, r₂, δₜ, a, v̲₁, v̲₂, m, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

The following code was converted to Julia, from a GitHub repository that hosts a MATLAB implementation. At the time of writing, this respository has a BSD license. I'm providing the copyright notice here, as instructed by the license text.

```
Copyright (c) 2018, Rody Oldenhuis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of this project.
```

`AstrodynamicalCalculations.R2BPCalculations.orbital_period`

— Method```
orbital_period(a, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the orbital period.

`AstrodynamicalCalculations.R2BPCalculations.orbital_radius`

— Method```
orbital_radius(p, e, ν)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns distance, r.

`AstrodynamicalCalculations.R2BPCalculations.orbital_speed`

— Method```
orbital_speed(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the instantaneous velocity, v, for any orbital representation.

`AstrodynamicalCalculations.R2BPCalculations.periapsis_radius`

— Method```
periapsis_radius(a, e)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns periapsis distance, rₚ.

`AstrodynamicalCalculations.R2BPCalculations.perifocal_to_cartesian`

— Method```
perifocal_to_cartesian(i, Ω, ω, x, y, z, ẋ, ẏ, ż)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns a spatial representation of the provied Perifocal state.

`AstrodynamicalCalculations.R2BPCalculations.right_ascension_ascending_node`

— Method```
right_ascension_ascending_node(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the right ascension of the ascending node.

`AstrodynamicalCalculations.R2BPCalculations.semi_parameter`

— Method```
semi_parameter(a, e)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns semilatus parameter, p.

`AstrodynamicalCalculations.R2BPCalculations.semimajor_axis`

— Method```
semimajor_axis(r, v, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns semimajor axis parameter, a.

`AstrodynamicalCalculations.R2BPCalculations.specific_angular_momentum`

— Method```
specific_angular_momentum(x, y, z, ẋ, ẏ, ż)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns scalar specific angular momentum vector, h.

`AstrodynamicalCalculations.R2BPCalculations.specific_angular_momentum_vector`

— Method```
specific_angular_momentum_vector(x, y, z, ẋ, ẏ, ż)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns specific angular momentum vector, h̅.

`AstrodynamicalCalculations.R2BPCalculations.specific_energy`

— Method```
specific_energy(a, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns specific orbital energy, ϵ.

`AstrodynamicalCalculations.R2BPCalculations.specific_potential_energy`

— Method```
specific_potential_energy(r, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns the specific potential energy: the energy per unit mass.

`AstrodynamicalCalculations.R2BPCalculations.sphere_of_activity`

— Method```
sphere_of_activity(a, m, M)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Sphere of activity.

`AstrodynamicalCalculations.R2BPCalculations.sphere_of_influence`

— Method```
sphere_of_influence(a, m, M)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Sphere of influence.

`AstrodynamicalCalculations.R2BPCalculations.time_since_periapsis`

— Method```
time_since_periapsis(n, e, E)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns time since periapsis, t.

`AstrodynamicalCalculations.R2BPCalculations.true_anomaly`

— Method```
true_anomaly(x, y, z, ẋ, ẏ, ż, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns true anomoly, ν.

`AstrodynamicalCalculations.R2BPCalculations.v_infinity`

— Method```
v_infinity(r, v, μ)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

Returns v∞.

`AstrodynamicalCalculations.R2BPCalculations.σmax`

— Method```
σmax(y)
```

This computation is valid for Restricted Two Body Problem (Keplerian) orbits.

```
Copyright (c) 2018, Rody Oldenhuis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of this project.
```