gcrf_to_lunar
- ssapy.utils.gcrf_to_lunar(r, t, v=None)[source][source]
Transform position and velocity vectors from the GCRF (Geocentric Celestial Reference Frame) to a lunar-centric frame.
This function converts coordinates from the Earth-centered GCRF to a coordinate system centered on the Moon. It uses the Moon’s position and velocity to define the transformation.
Parameters:
r (numpy array): Position vector(s) in the GCRF [x, y, z]. t (numpy array): Time(s) at which the position vector(s) are defined. v (numpy array, optional): Velocity vector(s) in the GCRF [vx, vy, vz]. If not provided, only position is transformed.
Returns:
- numpy array or tuple:
If v is not provided: Transformed position vector(s) in the lunar-centric frame.
- If v is provided: A tuple containing:
r_lunar (numpy array): Transformed position vector(s) in the lunar-centric frame.
v_lunar (numpy array): Transformed velocity vector(s) in the lunar-centric frame.
Notes:
The MoonPosition class is used to calculate the Moon’s position at a given time.
The Moon’s velocity is approximated using finite differences over a ±5-second interval.
- The lunar-centric frame is defined with the following axes:
x-axis: Points from the Moon toward the Earth (direction of the Moon’s position vector).
y-axis: Perpendicular to the Moon’s velocity vector, in the plane of motion.
z-axis: Perpendicular to both the x-axis and y-axis (right-hand rule).
The transformation matrix R is constructed using these axes and applied to the input position vector(s).