-
Notifications
You must be signed in to change notification settings - Fork 0
Conversion Functions
Below are the various conversions functions currently defined in Astrodynamics, including conversion between Keplerian orbital elements and Cartesian state vectors (and vice versa) as well as more straightforward conversions:
Conversions between Cartesian the state vectors (position
The relevant sources for these functions will, of course, be provided, as neither of these functions are totally written from scratch by myself, though I have made fairly significant alterations to the original code to best suit this project.
The keplerian_2_cartesian
function takes a two-body system's standard gravitational parameter and a dictionary of Keplerian orbital elements and computes the equivalent Cartesian state vectors.
The first thing keplerian_2_cartesian
does is verify that the signs of the semi-major axis and eccentricity are consistent with their implications:
If the sign of the semi-major axis is inconsistent with that implied by the value of the eccentricity, the semi-major axis will be changed accordingly. Then, keplerian_2_cartesian
computes the magnitude of the specific angular momentum
Next, we need to evaluate the length of the semi-latus rectum
Which is then used to determine the magnitude of the position vector
Now, both the position and velocity vectors must be defined with respect to the perifocal frame, denoted by the subscript
With the position and velocity vectors in the perifocal frame defined, they can be applied to a rotation matrix given by the three Euler angles (Rotation
algorithm. The rotation is initialized by indicating the rotation sequence and supplying the opposite of each angle. Finally, SciPy provides a method for applying the given rotation to vectors, so we can apply the inverse rotation to the vectors in the perifocal frame and the algorithm returns the relevant position and velocity vectors in the equatorial frame, thus completing the conversion from Keplerian elements to Cartesian state vectors.
Code originally adapted from: https://orbital-mechanics.space/classical-orbital-elements/orbital-elements-and-the-state-vector.html#orbital-elements-state-vector
The cartesian_2_keplerian
function takes a two-body system's standard gravitational parameter and a dictionary of Cartesian state vectors and computes the corresponding Keplerian orbital elements.
The conversion from state vectors to Keplerian elements is fairly straightforward and doesn't require any fancy-pants rotations. To start, we need to evaluate the specific angular momentum vector
With the specific angular momentum vector, the eccentricity vector
The length of the semi-major axis is related to the specific orbital energy:
The inclination can be computed by comparing the magnitudes of the z-component of
Next, the longitude of the ascending node can be calculated by defining the convenience vector
The longitude of the ascending node
Next, the argument of periapsis is dependent on the sign of the eccentricity vector's z-component as follows:
Lastly, the true anomaly, which will first be denoted by
For the "true" true anomaly
And in the case of bound orbits:
Code adapted from: https://orbital-mechanics.space/classical-orbital-elements/orbital-elements-and-the-state-vector.html#state-vector-orbital-elements
The following functions are each defined in Astrodynamics and are specifically for converting between various anomaly types.
Caution
This section is pending review.
The mean_2_true_anom
function converts a mean anomaly to the equivalent true anomaly via:
Where
Converting the mean anomaly to the eccentric anomaly mean_2_eccentric_anom
function which computes the eccentric anomaly using the relation:
Where
The mean_2_hyperbolic_anom
function converts the mean anomaly to the hyperbolic anomaly
Converting the true anomaly to the eccentric anomaly is handled by the true_2_eccentric_anom
function following the relation:
Converting the true anomaly to the hyperbolic anomaly is handled by the true_2_hyperbolic_anom
function following the relation:
Converting the eccentric anomaly to the true anomaly is handled by the eccentric_2_true_anom
function following the same relation as in Eq. 19:
Converting the hyperbolic anomaly to the true anomaly is handled by the hyperbolic_2_true_anom
function following the same relation as in Eq. 20:
Caution
This function is not defined in the current version of Astrodynamics, but is anticipated to be included in a future release.
Converting the hyperbolic anomaly to the mean anomaly is handled by the hyperbolic_2_mean_anom
function and is equivalent to evaluating the hyperbolic Kepler equation at the given hyperbolic anomaly:
This last section covers the few conversion functions included for convenience.
The radians
function takes an angle measured in degrees and returns the equivalent angle in radians within the domain
The degrees
function takes an angle measured in radians and returns the equivalent angle in degrees within the domain
The unit
function takes a vector