diff --git a/lib/coordinate.py b/lib/coordinate.py index 99b75ce..6590bda 100644 --- a/lib/coordinate.py +++ b/lib/coordinate.py @@ -28,7 +28,6 @@ from numpy.linalg import norm - def quatmult(q, p): """Multiplies two quaternions.""" qp0 = q[0] * p[0] - q[1] * p[1] - q[2] * p[2] - q[3] * p[3] @@ -38,13 +37,11 @@ def quatmult(q, p): return np.array([qp0, qp1, qp2, qp3]) - def conj(q): """Returns conjugate of quaternion.""" return np.array([q[0], -q[1], -q[2], -q[3]]) - def normalize(v): """Normalizes given vector. Args: @@ -55,7 +52,6 @@ def normalize(v): return v / norm(v) - def quatrot(q, v): """Rotates a vector with coordinate transformation quaternion. This function calculates conj(q) * v * q, where the sign * means @@ -72,7 +68,6 @@ def quatrot(q, v): return rvq[1:4] - def dcm_from_quat(q): """Converts a quaternion to a direction cosine matrix (DCM).""" C = np.zeros((3, 3)) @@ -91,7 +86,6 @@ def dcm_from_quat(q): return C - def quat_from_dcm(C): """Converts a direction cosine matrix (DCM) into a quaternion.""" if (1.0 + C[0, 0] + C[1, 1] + C[2, 2]) < 0.0: @@ -106,7 +100,6 @@ def quat_from_dcm(C): return np.array((q0, q1, q2, q3)) - def ecef2geodetic(x, y, z): """Converts a position in ECEF frame into a geodetic coordinates. Args: @@ -135,7 +128,6 @@ def ecef2geodetic(x, y, z): return np.array((degrees(lat), degrees(lon), alt)) - def geodetic2ecef(lat, lon, alt): """Converts a position in geodetic coordinates into an ECEF frame. Args: @@ -161,7 +153,6 @@ def geodetic2ecef(lat, lon, alt): return np.array((x, y, z)) - def ecef2geodetic_sphere(x, y, z): """Converts a position in ECEF frame into a spherical coordinates. This function is DEPRECATED. @@ -181,7 +172,6 @@ def ecef2geodetic_sphere(x, y, z): return np.array((lat, lon, alt)) - def geodetic2ecef_sphere(lat, lon, alt): """Converts a position in spherical coordinates into an ECEF frame. This function is DEPRECATED. @@ -201,7 +191,6 @@ def geodetic2ecef_sphere(lat, lon, alt): return np.array((x, y, z)) - def ecef2eci(xyz_in, t): """Converts a position in ECEF coordinates into an ECI frame. Args: @@ -225,7 +214,6 @@ def ecef2eci(xyz_in, t): return xyz_out - def eci2ecef(xyz_in, t): """Converts a position in ECI coordinates into an ECEF frame. Args: @@ -249,7 +237,6 @@ def eci2ecef(xyz_in, t): return xyz_out - def vel_ecef2eci(vel_in, pos_in, t): """Converts a ground velocity vector in ECEF coordinates into an inertial velocity vector in ECI frame. @@ -271,7 +258,6 @@ def vel_ecef2eci(vel_in, pos_in, t): return vel_ground_eci + vel_rotation_eci - def vel_eci2ecef(vel_in, pos_in, t): """Converts an inertial velocity vector in ECI coordinates into a ground velocity vector in ECEF frame. @@ -292,7 +278,6 @@ def vel_eci2ecef(vel_in, pos_in, t): return eci2ecef(vel_ground_eci, t) - def quat_eci2ecef(t): """Returns coordinates transformation quaternion from the ECI frame to the ECEF frame. @@ -309,7 +294,6 @@ def quat_eci2ecef(t): ) - def quat_ecef2eci(t): """Returns coordinates transformation quaternion from the ECEF frame to the ECI frame. @@ -323,7 +307,6 @@ def quat_ecef2eci(t): return conj(quat_eci2ecef(t)) - def quat_ecef2nedc(pos_ecef): """(DEPRECATED) Returns coordinates transformation quaternion from the ECEF frame to the local spherical North-East-Down frame. @@ -349,7 +332,6 @@ def quat_ecef2nedc(pos_ecef): return quat_ecef2ned - def quat_ecef2nedg(pos_ecef): """Returns coordinates transformation quaternion from the ECEF frame to the WGS84 local North-East-Down frame. @@ -377,7 +359,6 @@ def quat_ecef2nedg(pos_ecef): return quat_ecef2ned - def quat_nedg2ecef(pos_ecef): """Returns coordinates transformation quaternion from the WGS84 local North-East-Down frame to the ECEF frame. @@ -390,7 +371,6 @@ def quat_nedg2ecef(pos_ecef): return conj(quat_ecef2nedg(pos_ecef)) - def quat_nedc2ecef(pos_ecef): """(DEPRECATED) Returns coordinates transformation quaternion from the local spherical North-East-Down frame to the ECEF frame. @@ -403,7 +383,6 @@ def quat_nedc2ecef(pos_ecef): return conj(quat_ecef2nedc(pos_ecef)) - def quat_eci2nedg(pos, t): """Returns coordinates transformation quaternion from the ECI frame to the WGS84 local North-East-Down frame. @@ -418,7 +397,6 @@ def quat_eci2nedg(pos, t): return quatmult(quat_eci2ecef(t), quat_ecef2nedg(eci2ecef(pos, t))) - def quat_eci2nedc(pos, t): """(DEPRECATED) Returns coordinates transformation quaternion from the ECI frame to the local spherical North-East-Down frame. @@ -433,7 +411,6 @@ def quat_eci2nedc(pos, t): return quatmult(quat_eci2ecef(t), quat_ecef2nedc(eci2ecef(pos, t))) - def quat_nedg2eci(pos, t): """Returns coordinates transformation quaternion from the WGS84 local North-East-Down frame to the ECI frame. @@ -448,7 +425,6 @@ def quat_nedg2eci(pos, t): return conj(quat_eci2nedg(pos, t)) - def quat_nedc2eci(pos, t): """(DEPRECATED) Returns coordinates transformation quaternion from the local spherical North-East-Down frame to the ECI frame. @@ -463,7 +439,6 @@ def quat_nedc2eci(pos, t): return conj(quat_eci2nedc(pos, t)) - def quat_from_euler(az, el, ro): """Converts Euler angles into a coordinate transformation quaternion. @@ -482,7 +457,6 @@ def quat_from_euler(az, el, ro): return quatmult(qz, quatmult(qy, qx)) - def gravity(pos): """Calculates gravity acceleration vector at the given position. This function uses JGM-3 geopotential model. @@ -511,7 +485,6 @@ def gravity(pos): return np.array([fx, fy, fz]) - def quat_nedg2body(quat_eci2body, pos, t): """Returns coordinates transformation quaternion from the WGS84 local North-East-Down frame to the body frame. @@ -529,7 +502,6 @@ def quat_nedg2body(quat_eci2body, pos, t): return quatmult(conj(q), quat_eci2body) - def euler_from_quat(q): """Calculates Euler angles from a coordinate transformation quaternion. @@ -556,7 +528,6 @@ def euler_from_quat(q): return np.rad2deg(np.array([az, el, ro])) - def euler_from_dcm(C): """Calculates Euler angles from a direction cosine matrix. The sequence of rotation is Z-Y-X (yaw-pitch-roll). @@ -577,7 +548,6 @@ def euler_from_dcm(C): return np.rad2deg(np.array([az, el, ro])) - def dcm_from_thrustvector(pos_eci, u): """Calculates direction cosine matrix(DCM) from the position and the direction of body axis. @@ -600,7 +570,6 @@ def dcm_from_thrustvector(pos_eci, u): return np.vstack((xb_dir, yb_dir, zb_dir)) - def eci2geodetic(pos_in, t): """Converts a position in ECI frame into a WGS84 geodetic(latitude, longitude, altitude) coordinates. @@ -619,7 +588,6 @@ def eci2geodetic(pos_in, t): return ecef2geodetic(pos_ecef[0], pos_ecef[1], pos_ecef[2]) - def orbital_elements(r_eci, v_eci): """Calculates orbital elements from position and velocity vectors. Args: