Spacecraft Control Framework 1.0
Spacecraft Control Library
Classes | Typedefs | Functions
sc_coord.h File Reference

Coordinate transformation functions. More...

Go to the source code of this file.

Classes

struct  sun_vector_out_s
 

Typedefs

typedef struct sun_vector_out_s sun_vector_out
 

Functions

ml_matrix az_el_range_range_rate_to_rv (const ml_matrix &q_radar_to_hills, double az, double el, double range, double range_dot)
 Converts az, el, range and range rate to exact r and approximate v. More...
 
ml_matrix q_from_u (const ml_matrix &u_catalog, const ml_matrix &u_meas)
 Returns a quaternion given at least 3 matching vectors. More...
 
double q_to_angle (const ml_matrix &quaternion)
 Returns value of the angle from the quaternion in radians. More...
 
ml_matrix q_to_vec (const ml_matrix &quaternion)
 Returns the value of the vector from quaternion. More...
 
ml_matrix au_to_q (double angle, double unit_vec[3])
 Compute quaternion from angle and unit vector, array format. More...
 
ml_matrix au_to_q (double angle, const ml_matrix &unit_vec)
 Compute quaternion from angle and unit vector, matrix format. More...
 
double q_to_au (const ml_matrix &quaternion, ml_matrix &unit_vec)
 Compute angle and unit vector from quaternion. More...
 
ml_matrix eul_to_mat (const ml_matrix &euler)
 Convert 3-2-1 Euler angle sequence to a matrix that transforms in the direction of the rotation. More...
 
ml_matrix eul_to_q (const ml_matrix &euler)
 Convert 3-2-1 Euler angle sequence to a quaternion that transforms in the direction of the rotation.
 
ml_matrix delta_eul_to_q (const ml_matrix &q, const ml_matrix &euler)
 Apply a 3-2-1 Euler angle sequence to a quaternion that transforms in the direction of the rotation. More...
 
ml_matrix rot_mat_x (const double &a)
 Generate a rotation matrix for angular rotation about the x axis. More...
 
ml_matrix rot_mat_y (const double &a)
 Generate a rotation matrix for angular rotation about the y axis. More...
 
ml_matrix rot_mat_z (const double &a)
 Generate a rotation matrix for angular rotation about the z axis. More...
 
ml_matrix mat_to_q (const ml_matrix &mat)
 Convert a matrix to a quaternion. More...
 
ml_matrix mat_to_eul (const ml_matrix &mat, const ml_matrix &euler)
 Convert a matrix to an Euler angle sequence. More...
 
ml_matrix u_to_q (const ml_matrix &vec1, const ml_matrix &vec2)
 Computes the quaternion which aligns one vector with a second. More...
 
ml_matrix perpendicular (const ml_matrix &vec)
 Computes the perpendicular vector. More...
 
ml_matrix q_error (const ml_matrix &q_ref, const ml_matrix &q_meas)
 Finds the small error between two quaternions and converts them into an angle vector. More...
 
ml_matrix qb_to_i_dot (const ml_matrix &quaternion, const ml_matrix &w)
 Calculates the derivative of the body to inertial quaternion. More...
 
ml_matrix qi_to_b_dot (const ml_matrix &quat, const ml_matrix &w)
 Calculates the derivative of the inertial to body quaternion. More...
 
ml_matrix qeb_re_ub_to_az_el (const ml_matrix &qEB, const ml_matrix &rE, const ml_matrix &vB)
 Calculate azimuth & elevation angle from ECI to body quaternion, position, and boresight vector. More...
 
ml_matrix mat_eci_to_lvlh (const ml_matrix &pos, const ml_matrix &vel)
 Generate the matrix that transforms from ECI to LVLH coordinates. More...
 
ml_matrix q_eci_to_lvlh (const ml_matrix &pos, const ml_matrix &vel)
 Generate the quaternion that transforms from ECI to LVLH coordinates. More...
 
ml_matrix mat_eci_to_hills (const ml_matrix &r, const ml_matrix &v)
 Generate the matrix that transforms from ECI to Hills coordinates. More...
 
ml_matrix q_eci_to_hills (const ml_matrix &r, const ml_matrix &v)
 Generate the quaternion that transforms from ECI to Hills coordinates. More...
 
ml_matrix eci_to_hills (const ml_matrix &x0, const ml_matrix &x1)
 Transform from two ECI states to one relative state in Hills-frame. More...
 
ml_matrix hills_to_eci (const ml_matrix &x0, const ml_matrix &xH)
 Transform from a relative state in Hills-frame to an absolute ECI state. More...
 
ml_matrix qslerp (const ml_matrix &quat1, const ml_matrix &quat2, double t)
 Interpolates between two quaternions. More...
 
ml_matrix lat_lon_alt_to_pos (double lat, double lon, double h, double f=FLATTENING_FACTOR, double a=RADIUS_EARTH)
 Compute EF position vector from latitude, longitude, and altitude. More...
 
ml_matrix lat_lon_alt_to_pos (const ml_matrix &lat_lon_alt, double f=FLATTENING_FACTOR, double a=RADIUS_EARTH)
 Compute EF position vector from matrix [latitude;longitude;altitude]. More...
 
ml_matrix lat_lon_to_pos (double lat, double lon, double f, double a, bool is_geodetic)
 Converts latitude and longitude to r for an ellipsoidal planet. More...
 
ml_matrix lat_lon_to_pos (double lat, double lon, double f=FLATTENING_FACTOR, double a=RADIUS_EARTH, int type=0)
 Converts latitude and longitude to r for an ellipsoidal planet. More...
 
ml_matrix pos_to_lat_lon_alt (const ml_matrix &efPos, double f=FLATTENING_FACTOR, double a=RADIUS_EARTH, double tolerance=1.0e-6)
 Compute latitude, longitude, and altitude from EF position vector. More...
 
void cart_to_sph (const ml_matrix &x, const ml_matrix &y, const ml_matrix &z, ml_matrix &r, ml_matrix &theta, ml_matrix &phi)
 Converts cartesian coordinates to spherical. More...
 
ml_matrix cart_to_sph (const ml_matrix &x)
 Converts cartesian coordinates to spherical. Stacked form. More...
 
void sph_to_cart (const ml_matrix &r, const ml_matrix &theta, const ml_matrix &phi, ml_matrix &x, ml_matrix &y, ml_matrix &z)
 Convert spherical coordinates to cartesian. More...
 
ml_matrix RPhiTheta2Cart (const ml_matrix &r)
 Computes the transformation matrix from an r, phi, theta frame to cartesian. More...
 
ml_matrix CameraToECI (double az, double el, double tt, const ml_matrix &qECIToBody, const ml_matrix &mBaseToBody)
 Computes the transformation matrix from a camera frame with 3 rotations to the body frame. More...
 
ml_matrix eci_to_ned (const ml_matrix &r, int opt=0, double f=FLATTENING_FACTOR)
 Computes the transformation matrix or quaternion from a eciframe to the North East Down (NED) frame. More...
 
ml_matrix u_to_az_el (const ml_matrix &u)
 Computes the azimuth and elevation of a unit vector. More...
 
ml_matrix u_to_x_z (const ml_matrix &u)
 Computes the x and z rotations to align z with a unit vector. More...
 
ml_matrix az_el_to_u (double az, double el)
 Computes u from azimuth and elevation of a unit vector. More...
 
ml_matrix az_el_to_u (const ml_matrix &az, const ml_matrix &el)
 Compute a unit vector from azimuth and elevation. More...
 
ml_matrix q_from_dq (const ml_matrix &q, const ml_matrix &dX)
 Computes q as the product of q and a delta quaternion. More...
 
ml_matrix dq_from_dX (const ml_matrix &dX)
 Delta quaternion from a 3 vector. More...
 
ml_matrix r_lvlh_to_eci (const ml_matrix &r_eci, const ml_matrix &v_eci, const ml_matrix &r)
 LVLH position to ECI. More...
 
ml_matrix v_lvlh_to_eci (const ml_matrix &r_eci, const ml_matrix &v_eci, const ml_matrix &v)
 ECI position to LVLH. More...
 
ml_matrix r_eci_to_lvlh (const ml_matrix &r_eci, const ml_matrix &v_eci, const ml_matrix &r)
 LVLH position to ECI. More...
 
ml_matrix v_eci_to_lvlh (const ml_matrix &r_eci, const ml_matrix &v_eci, const ml_matrix &v)
 ECI position to LVLH. More...
 
ml_matrix x_lvlh_to_eci (const ml_matrix &r_eci, const ml_matrix &v_eci, const ml_matrix &x)
 LVLH state to ECI. More...
 
ml_matrix x_eci_to_lvlh (const ml_matrix &r_eci, const ml_matrix &v_eci, const ml_matrix &x)
 ECI state to LVLH. More...
 
ml_matrix x_lvlh_to_eci (const ml_matrix &x_eci, const ml_matrix &x)
 ECI state to LVLH. More...
 
ml_matrix x_eci_to_lvlh (const ml_matrix &x_eci, const ml_matrix &x)
 ECI state to LVLH. More...
 
ml_matrix LLAToECEF (const ml_matrix &lla, double rP=RADIUS_EARTH)
 Compute ECEF position from latitude, longitude, altitude. More...
 
ml_matrix small_angles_to_q (const ml_matrix &angle)
 Convert small angles to a quaternion. More...
 
ml_matrix spice_to_3_by_3 (const ml_matrix &m, int k=1)
 Convert SPICE rotation matrix to 3x3. More...
 
double esd_to_azim (const ml_matrix &u)
 Convert an East-South-Down vector to azimuth from North. More...
 
double esd_to_elev (const ml_matrix &u)
 Convert an East-South-Down vector to elevation from nadir. More...
 
ml_matrix azim_elev_to_esd (const double &azim, const double &elev)
 Convert azimuth / elevation angles to an East-South-Down unit vector. More...
 
ml_matrix ecef_to_esd (const ml_matrix &rEF)
 Compute rotation matrix from Earth-fixed frame to East-South-Down frame at given Earth-fixed position. More...
 
ml_matrix u_eci_to_az_el_body (const ml_matrix &u_eci, const ml_matrix &q_eci_to_body, const ml_matrix &q_body_to_base)
 Find az and el from an ECI vector. More...
 
sun_vector_out sun_vector_pointing (const ml_matrix &u_eci, const ml_matrix &u_sun_eci)
 Rotation angles to point a solar wing at the sun. More...
 
ml_matrix target_from_r_v_d (const ml_matrix &r, double rP, const ml_matrix &v, double d)
 Landing target. More...
 
ml_matrix ef_to_lla (const ml_matrix &r)
 EF to LLA.
 
ml_matrix eci_to_llr (const ml_matrix &eciCoord, double jd)
 EF to LLA.
 
ml_matrix q_from_two_u (const ml_matrix &u, const ml_matrix &v)
 Quaternion from two unit vectors.
 
ml_matrix q_to_ra_dec (const ml_matrix &quaternion, const ml_matrix &uu)
 Compute right ascension and declination (in radians) of a unit vector in the body frame from a quaterion that transforms from the inertial to the body frame. More...
 
ml_matrix u_to_ra_dec (const ml_matrix &unit_vec)
 Computes right ascension and declination from a unit vector. More...
 
ml_matrix u_to_ra_dec (const ml_matrix &unit_vec, bool normalize)
 Computes right ascension and declination from a unit vector and normalizes the result. More...
 
ml_matrix ra_dec_to_q (const ml_matrix &uu, double ra, double dec)
 Compute a quaternion from right ascension and declination. More...
 
ml_matrix ra_dec_to_u (double ra, double dec)
 Calculate a unit vector from right ascension and declination. More...
 
ml_matrix ra_dec_to_u (const ml_matrix &ra, const ml_matrix &dec)
 Calculate a unit vector from right ascension and declination. More...
 
ml_matrix az_el_to_q (ml_matrix az, ml_matrix el)
 Compute a quaternion from azimuth and elevation. More...
 
ml_matrix az_el_to_q (double az, double el)
 Compute a quaternion from azimuth and elevation. More...
 

Detailed Description

Coordinate transformation functions.

Function Documentation

◆ az_el_range_range_rate_to_rv()

ml_matrix az_el_range_range_rate_to_rv ( const ml_matrix &  q_radar_to_hills,
double  az,
double  el,
double  range,
double  range_dot 
)

Converts az, el, range and range rate to exact r and approximate v.

Parameters
azAzimuth
elElevation
rangeRange
range_dotRange rate
Returns
state [r;v]

References pinv().

◆ q_from_u()

ml_matrix q_from_u ( const ml_matrix &  u_catalog,
const ml_matrix &  u_meas 
)

Returns a quaternion given at least 3 matching vectors.

Parameters
u_catalogA 3xn matrix of catalog unit vectors
u_measA 3xn matrix of measured unit vectors
Returns
The quaternion.

References mat_to_q(), orthogonalize(), and pinv().

◆ q_to_angle()

double q_to_angle ( const ml_matrix &  quaternion)

Returns value of the angle from the quaternion in radians.

Parameters
quaternionThe quaternion.
Returns
The angle from the quaternion in radians.

References PI, and TWO_PI.

Referenced by q_to_au(), and PID3Axis::Update().

◆ q_to_vec()

ml_matrix q_to_vec ( const ml_matrix &  quaternion)

Returns the value of the vector from quaternion.

Parameters
quaternionThe quaternion.
Returns
The vector from the quaternion.

Referenced by q_to_au(), and PID3Axis::Update().

◆ au_to_q() [1/2]

ml_matrix au_to_q ( double  angle,
double  unit_vec[3] 
)

Compute quaternion from angle and unit vector, array format.

Parameters
angle
unit_vec
Returns
The quaternion computed from the provided angle and unit vector.

Referenced by AlignThruster(), orbit_acquisition_dv(), PID3Axis::SetAlignAndRotateCommand(), multi_body_central_hub_with_rwa::state_derivative(), multi_body_central_hub::state_derivative(), target_from_r_v_d(), aero_newtonian::update(), and PID3Axis::Update().

◆ au_to_q() [2/2]

ml_matrix au_to_q ( double  angle,
const ml_matrix &  unit_vec 
)

Compute quaternion from angle and unit vector, matrix format.

Parameters
angle
unit_vec
Returns
The quaternion computed from the provided angle and unit vector.

◆ q_to_au()

double q_to_au ( const ml_matrix &  quaternion,
ml_matrix &  unit_vec 
)

Compute angle and unit vector from quaternion.

Parameters
quaternionThe quaternion.
unit_vecThe unit vector will be returned in this matrix.
Returns
The angle computed from the quaternion, measured in radians.

References q_to_angle(), and q_to_vec().

◆ eul_to_mat()

ml_matrix eul_to_mat ( const ml_matrix &  euler)

Convert 3-2-1 Euler angle sequence to a matrix that transforms in the direction of the rotation.

Parameters
euler(3,1) The Euler angle sequence to be converted.
Returns
The matrix which transforms in the direction of the rotation.

◆ delta_eul_to_q()

ml_matrix delta_eul_to_q ( const ml_matrix &  q,
const ml_matrix &  euler 
)

Apply a 3-2-1 Euler angle sequence to a quaternion that transforms in the direction of the rotation.

Apply a 3-2-1 Euler angle sequence to a quaternion that transforms in the direction of the rotation.

Parameters
euler(3,1) The Euler angle sequence to be converted.
q(4,1) The original quaternion.
Returns
The matrix which transforms in the direction of the rotation.

References eul_to_q().

◆ rot_mat_x()

ml_matrix rot_mat_x ( const double &  a)

Generate a rotation matrix for angular rotation about the x axis.

Generate a rotation matrix for angular rotation about the x axis.

Parameters
aAngle of rotation (rad)
Returns
The rotation matrix.

◆ rot_mat_y()

ml_matrix rot_mat_y ( const double &  a)

Generate a rotation matrix for angular rotation about the y axis.

Generate a rotation matrix for angular rotation about the y axis.

Parameters
aAngle of rotation (rad)
Returns
The rotation matrix.

◆ rot_mat_z()

ml_matrix rot_mat_z ( const double &  a)

Generate a rotation matrix for angular rotation about the z axis.

Generate a rotation matrix for angular rotation about the z axis.

Parameters
aAngle of rotation (rad)
Returns
The rotation matrix.

◆ mat_to_q()

ml_matrix mat_to_q ( const ml_matrix &  mat)

Convert a matrix to a quaternion.

Convert a matrix to a quaternion.

Wrapper for the MatrixLib function q_from_mat.

Parameters
mat(3,3) The matrix to be converted.
Returns
The quaternion generated from the provided matrix.

Referenced by az_el_to_q(), eci_to_ned(), q_eci_to_hills(), q_eci_to_lvlh(), q_from_u(), and sun_vector_pointing().

◆ mat_to_eul()

ml_matrix mat_to_eul ( const ml_matrix &  mat,
const ml_matrix &  euler 
)

Convert a matrix to an Euler angle sequence.

Wrapper for the MatrixLib function q_mat_to_eul.

Parameters
mat(3,3)
euler(3,1)
Returns
Returns the Euler angle sequence generated from the provided matrix.

◆ u_to_q()

ml_matrix u_to_q ( const ml_matrix &  vec1,
const ml_matrix &  vec2 
)

Computes the quaternion which aligns one vector with a second.

Computes the quaternion which aligns one vector with a second.

This is not a unique solution.

Wrapper for the MatrixLib function q_from_u.

Parameters
vec1(3,1) Starting vector.
vec2(3,1) Ending vector.
Returns
Quaternion which rotates vec1 into vec2

Referenced by AlignThruster(), sensor_cone(), PID3Axis::SetAlignAndRotateCommand(), sun_vector_pointing(), and PID3Axis::Update().

◆ perpendicular()

ml_matrix perpendicular ( const ml_matrix &  vec)

Computes the perpendicular vector.

Wrapper for the MatrixLib function q_perpendicular.

Parameters
vec(3,1) The vector.
Returns
Returns the perpendicular to the given vector.

Referenced by q_from_two_u().

◆ q_error()

ml_matrix q_error ( const ml_matrix &  q_ref,
const ml_matrix &  q_meas 
)

Finds the small error between two quaternions and converts them into an angle vector.

This routine gives the correct sign when both vectors transform from frame a to frame b and frame b is the body frame. If the convention is reversed you must reverse the sign.

Parameters
q_ref(4,1) Reference quaternion.
q_meas(4,1) Measured quaternion.
Returns
(3,1) Vector of small angular errors.

◆ qb_to_i_dot()

ml_matrix qb_to_i_dot ( const ml_matrix &  quaternion,
const ml_matrix &  w 
)

Calculates the derivative of the body to inertial quaternion.

Calculates the derivative of the body to inertial quaternion.

Parameters
quaternion(4,1) The quaternion, should be a column vector
w(3,1) The anglular velocity, a 3 element column vector
Returns
(4,1) Derivative of the body to inertial quaternion.

◆ qi_to_b_dot()

ml_matrix qi_to_b_dot ( const ml_matrix &  quat,
const ml_matrix &  w 
)

Calculates the derivative of the inertial to body quaternion.

Calculates the derivative of the inertial to body quaternion.

Parameters
quat(4,1) The quaternion, should be a column vector.
w(3,1) The angular rate, a 3 element column vector.
Returns
(4,1) Derivative of the inertial to body quaternion.

Referenced by attitude_propagation(), multi_body_central_hub_with_rwa::state_derivative(), and multi_body_central_hub::state_derivative().

◆ qeb_re_ub_to_az_el()

ml_matrix qeb_re_ub_to_az_el ( const ml_matrix &  qEB,
const ml_matrix &  rE,
const ml_matrix &  vB 
)

Calculate azimuth & elevation angle from ECI to body quaternion, position, and boresight vector.

Calculate azimuth & elevation angle from ECI to body quaternion, position, and boresight vector.

Azimuth angle is measured clockwise from north to the projection of the boresight vector onto the east-north plane. Elevation angle is the "angle off nadir", the angular distance between the nadir vector and the boresight vector. Adapted by KenW from Joe Mueller's QEB_RE_UB_to_AzEl.m matlab code in /Contracts/NavyReconfigure/Matlab

Parameters
qEB(4,1) ECI to spacecraft body coordinate frame quaternion
rE(3,1) ECI position of spacecraft
vB(3,1) boresight vector defined in body frame
Returns
(2,1) matrix containing azimuth angle in (1,1) and elevation angle in (2,1)

◆ mat_eci_to_lvlh()

ml_matrix mat_eci_to_lvlh ( const ml_matrix &  pos,
const ml_matrix &  vel 
)

Generate the matrix that transforms from ECI to LVLH coordinates.

For LVLH coordinates; z is in the -r direction y is in the - rxv direction x completes the set

Parameters
pos(3,1) Position vectors
vel(3,1) Velocity vectors
Returns
(4,n) The quaternions that transform from ECI to LVLH coordinates.

Referenced by q_eci_to_lvlh().

◆ q_eci_to_lvlh()

ml_matrix q_eci_to_lvlh ( const ml_matrix &  pos,
const ml_matrix &  vel 
)

Generate the quaternion that transforms from ECI to LVLH coordinates.

Parameters
pos(3,1) Position vector
vel(3,1) Velocity vector
Returns
(4,n) The quaternions that transform from ECI to LVLH coordinates.

References mat_eci_to_lvlh(), and mat_to_q().

Referenced by r_eci_to_lvlh(), r_lvlh_to_eci(), v_eci_to_lvlh(), v_lvlh_to_eci(), x_eci_to_lvlh(), and x_lvlh_to_eci().

◆ mat_eci_to_hills()

ml_matrix mat_eci_to_hills ( const ml_matrix &  r,
const ml_matrix &  v 
)

Generate the matrix that transforms from ECI to Hills coordinates.

For Hills coordinates; x is in the + r direction z is in the + rxv direction y completes the set (aligned with velocity for circular orbits)

Parameters
r(3,1) Position vector
v(3,1) Velocity vector
Returns
q (4,1) Quaternion

Referenced by eci_to_hills(), hills_to_eci(), and q_eci_to_hills().

◆ q_eci_to_hills()

ml_matrix q_eci_to_hills ( const ml_matrix &  r,
const ml_matrix &  v 
)

Generate the quaternion that transforms from ECI to Hills coordinates.

Parameters
r(3,1) Position vector
v(3,1) Velocity vector
Returns
q (4,1) Quaternion

References mat_eci_to_hills(), and mat_to_q().

Referenced by AlignThruster().

◆ eci_to_hills()

ml_matrix eci_to_hills ( const ml_matrix &  x0,
const ml_matrix &  x1 
)

Transform from two ECI states to one relative state in Hills-frame.

Parameters
x0(6,1) ECI position and velocity of reference orbit
x1(6,1) ECI position and velocity of secondary orbit
Returns
xH (6,1) Relative position and velocity in Hills-frame

References mat_eci_to_hills().

Referenced by FFEccDeltaElem2Hills().

◆ hills_to_eci()

ml_matrix hills_to_eci ( const ml_matrix &  x0,
const ml_matrix &  xH 
)

Transform from a relative state in Hills-frame to an absolute ECI state.

Parameters
x0(6,1) ECI position and velocity of reference orbit
xH(6,1) Relative position and velocity in Hills-frame
Returns
x1 (6,1) ECI position and velocity of secondary orbit

References mat_eci_to_hills().

Referenced by FFEccHills2DeltaElem().

◆ q_to_ra_dec()

ml_matrix q_to_ra_dec ( const ml_matrix &  quaternion,
const ml_matrix &  uu 
)

Compute right ascension and declination (in radians) of a unit vector in the body frame from a quaterion that transforms from the inertial to the body frame.

Compute right ascension and declination from a quaterion.

Parameters
quaternion(4,1) The quaternion (inertial to body).
uu(3,1) unit vector in the body frame.
Returns
The right ascension and declination.

References u_to_ra_dec().

◆ u_to_ra_dec() [1/2]

ml_matrix u_to_ra_dec ( const ml_matrix &  unit_vec)

Computes right ascension and declination from a unit vector.

Computes right ascension and declination from a unit vector.

Parameters
unit_vec(3,n) Unit vector(s)
Returns
rADec (2,n) stacked vector(s) of right ascension (top) and declination (bot)

Referenced by q_to_ra_dec().

◆ u_to_ra_dec() [2/2]

ml_matrix u_to_ra_dec ( const ml_matrix &  unit_vec,
bool  normalize 
)

Computes right ascension and declination from a unit vector and normalizes the result.

Computes right ascension and declination from a unit vector and normalizes the result.

Parameters
unit_vec(3,n) Unit vector(s)
normalizeFlag indicating whether the return vector should be normalized.
Returns
rADec (2,n) stacked vector(s) of right ascension (top) and declination (bot)

References TWO_PI.

◆ ra_dec_to_q()

ml_matrix ra_dec_to_q ( const ml_matrix &  uu,
double  ra,
double  dec 
)

Compute a quaternion from right ascension and declination.

If right ascension and declination are defined in frame a, and u is fixed in frame b, q transforms from frame a to b such that u lies along the vector determined by (rA,dec) in frame a.

Parameters
uu(3,1) unit vector
ra(1) Right ascension [rad]
dec(1) Declination [rad]
Returns
(4,1) Quaternion

References ra_dec_to_u().

◆ ra_dec_to_u() [1/2]

ml_matrix ra_dec_to_u ( double  ra,
double  dec 
)

Calculate a unit vector from right ascension and declination.

Parameters
ra(1) Right ascension [rad]
dec(1) Declination [rad]
Returns
A unit vector(3,1) computed from the provided right ascension and declination.

Referenced by star::CalculateVector(), local_star_position(), ra_dec_to_q(), ra_dec_to_u(), stellar_reduction(), and star::UnitVector().

◆ ra_dec_to_u() [2/2]

ml_matrix ra_dec_to_u ( const ml_matrix &  ra,
const ml_matrix &  dec 
)

Calculate a unit vector from right ascension and declination.

Parameters
ra(1,n) Right ascension [rad]
dec(1,n) Declination [rad]
Returns
A unit vector computed from the provided right ascension and declination.

References ra_dec_to_u().

◆ az_el_to_q() [1/2]

ml_matrix az_el_to_q ( ml_matrix  az,
ml_matrix  el 
)

Compute a quaternion from azimuth and elevation.

Compute a quaternion from azimuth and elevation.

Parameters
azIs the azimuth (angle about +z from +x)
elis the elevation (angle about +y from +x)
Returns
(4,n) The quaternion from base to rotated frame.

References az_el_to_q().

Referenced by az_el_to_q().

◆ az_el_to_q() [2/2]

ml_matrix az_el_to_q ( double  az,
double  el 
)

Compute a quaternion from azimuth and elevation.

Compute a quaternion from azimuth and elevation.

Parameters
azIs the azimuth (angle about +z from +x)
elis the elevation (angle about +y from +x)
Returns
(4,1) The quaternion from base to rotated frame.

References mat_to_q().

◆ qslerp()

ml_matrix qslerp ( const ml_matrix &  quat1,
const ml_matrix &  quat2,
double  t 
)

Interpolates between two quaternions.

Parameters
quat1(4,1)
quat2(4,1)
t(1) between 0 to 1
Returns
(4,1) Interpolated quaternion

◆ lat_lon_alt_to_pos() [1/2]

ml_matrix lat_lon_alt_to_pos ( double  lat,
double  lon,
double  h,
double  f,
double  a 
)

Compute EF position vector from latitude, longitude, and altitude.

Parameters
latLatitude in radians.
lonLongitude in radians.
hDistance above the subsatellite point.
fFlattening factor
aEquatorial radius
Returns
(3,1) The EF position vector.

Referenced by earth_surface_ef_pos(), gps_eci_state_from_data(), and lat_lon_alt_to_pos().

◆ lat_lon_alt_to_pos() [2/2]

ml_matrix lat_lon_alt_to_pos ( const ml_matrix &  lat_lon_alt,
double  f,
double  a 
)

Compute EF position vector from matrix [latitude;longitude;altitude].

Compute EF position vector from matrix [latitude;longitude;altitude].

Parameters
lat_lon_alt[lat;lon;alt]
fFlattening factor
aEquatorial radius
Returns
(3,:) The EF position vectors.

References lat_lon_alt_to_pos().

◆ lat_lon_to_pos() [1/2]

ml_matrix lat_lon_to_pos ( double  lat,
double  lon,
double  f,
double  a,
bool  is_geodetic 
)

Converts latitude and longitude to r for an ellipsoidal planet.

Parameters
latLatitude in radians.
lonLongitude in radians.
fFlattening factor
aEquatorial radius
is_geodetictrue for geodetic
Returns
(3,1) The EF position vector.

◆ lat_lon_to_pos() [2/2]

ml_matrix lat_lon_to_pos ( double  lat,
double  lon,
double  f,
double  a,
int  type 
)

Converts latitude and longitude to r for an ellipsoidal planet.

Parameters
latLatitude in radians.
lonLongitude in radians.
fFlattening factor
aEquatorial radius
type0 for Geodetic
Returns
The EF position vector.

◆ pos_to_lat_lon_alt()

ml_matrix pos_to_lat_lon_alt ( const ml_matrix &  efPos,
double  f,
double  a,
double  tolerance 
)

Compute latitude, longitude, and altitude from EF position vector.

Parameters
efPosECEF position (km)
fFlattening factor
aEquatorial radius
toleranceTolerance for the iteration
Returns
(3,1) lat (radians), lon (radians), altitude (km)

References PI.

Referenced by earth_surface_ef_pos(), and sc_earth_elevation::elevationForEFPos().

◆ cart_to_sph() [1/2]

void cart_to_sph ( const ml_matrix &  x,
const ml_matrix &  y,
const ml_matrix &  z,
ml_matrix &  r,
ml_matrix &  theta,
ml_matrix &  phi 
)

Converts cartesian coordinates to spherical.

Individual vector form.

Parameters
x
y
z
r
theta
phi

Referenced by mag_field().

◆ cart_to_sph() [2/2]

ml_matrix cart_to_sph ( const ml_matrix &  x)

Converts cartesian coordinates to spherical. Stacked form.

Converts cartesian coordinates to spherical. Stacked form.

Stacked matrix form.

Parameters
xPosition state [x;y;z]
Returns
r New coordinates [r;theta;phi]

◆ sph_to_cart()

void sph_to_cart ( const ml_matrix &  r,
const ml_matrix &  theta,
const ml_matrix &  phi,
ml_matrix &  x,
ml_matrix &  y,
ml_matrix &  z 
)

Convert spherical coordinates to cartesian.

Convert spherical coordinates to cartesian.

Individual vector form.

Parameters
r
theta
phi
x
y
z

◆ RPhiTheta2Cart()

ml_matrix RPhiTheta2Cart ( const ml_matrix &  r)

Computes the transformation matrix from an r, phi, theta frame to cartesian.

Computes the transformation matrix from an r, phi, theta frame to cartesian.

In an RPT frame, r is the radial direction, phi is 'east', and theta is in the direction of co-elevation. When theta is zero the r vector is in the xy-plane.

Parameters
rPosition vector
Returns
cRPT2Cart Transformation matrix

Referenced by mag_field().

◆ CameraToECI()

ml_matrix CameraToECI ( double  az,
double  el,
double  tt,
const ml_matrix &  qECIToBody,
const ml_matrix &  mBaseToBody 
)

Computes the transformation matrix from a camera frame with 3 rotations to the body frame.

Computes the transformation matrix from a camera frame with 3 rotations to the body frame.

Parameters
azAzimuth (rad)
elElevation (rad)
ttTurntable angle (rad)
qECIToBodyQuaternion from ECI to Body
mBaseToBodyTransformation matrix from Camera base to body
Returns
mCameraToECI Transformation matrix

◆ eci_to_ned()

ml_matrix eci_to_ned ( const ml_matrix &  r,
int  opt,
double  f 
)

Computes the transformation matrix or quaternion from a eciframe to the North East Down (NED) frame.

Computes the transformation matrix or quaternion from a eciframe to the North East Down (NED) frame.

Reference: Stevens, B.L., Lewis, F.L. , Aircraft Control and Simulation, John Wiley & Sons, 1992, p. 36.

Parameters
rECI position vector (km)
opt0 output quaternion 1 output matrix (rad)
fFlattening factor
Returns
qECIToNED or mECIToNED Transformation quaternion or matrix

References mat_to_q().

Referenced by gps_eci_state_from_data().

◆ u_to_az_el()

ml_matrix u_to_az_el ( const ml_matrix &  u)

Computes the azimuth and elevation of a unit vector.

Computes the azimuth and elevation of a unit vector.

Parameters
uUnit vector
Returns
[az;el]

Referenced by u_eci_to_az_el_body().

◆ u_to_x_z()

ml_matrix u_to_x_z ( const ml_matrix &  u)

Computes the x and z rotations to align z with a unit vector.

Compute azimuth and elevation from a unit vector.

Parameters
uUnit vector
Returns
[z;x]

◆ az_el_to_u() [1/2]

ml_matrix az_el_to_u ( double  az,
double  el 
)

Computes u from azimuth and elevation of a unit vector.

Computes u from azimuth and elevation of a unit vector.

Parameters
azAzimuth
elElevation
Returns
Unit vector

◆ az_el_to_u() [2/2]

ml_matrix az_el_to_u ( const ml_matrix &  az,
const ml_matrix &  el 
)

Compute a unit vector from azimuth and elevation.

Compute a unit vector from azimuth and elevation.

Parameters
azis the azimuth (angle about +z from +x)
elis the elevation (angle about +y from +x)
Returns
The unit vector.

◆ q_from_dq()

ml_matrix q_from_dq ( const ml_matrix &  q,
const ml_matrix &  dX 
)

Computes q as the product of q and a delta quaternion.

Computes q as the product of q and a delta quaternion.

Parameters
qQuaternion
dXDelta quaternion
Returns
Quaternion

References dq_from_dX().

◆ dq_from_dX()

ml_matrix dq_from_dX ( const ml_matrix &  dX)

Delta quaternion from a 3 vector.

Delta quaternion from a 3 vector.

Parameters
dXDelta quaternion
Returns
Quaternion

Referenced by q_from_dq().

◆ r_lvlh_to_eci()

ml_matrix r_lvlh_to_eci ( const ml_matrix &  r_eci,
const ml_matrix &  v_eci,
const ml_matrix &  r 
)

LVLH position to ECI.

LVLH position to ECI.

Parameters
r_eciPosition vector of reference center in the ECI frame
v_eciVelocity vector of reference center in the ECI frame
rPosition vector in lvlh frame
Returns
Position vector in the eci frame

References q_eci_to_lvlh().

◆ v_lvlh_to_eci()

ml_matrix v_lvlh_to_eci ( const ml_matrix &  r_eci,
const ml_matrix &  v_eci,
const ml_matrix &  v 
)

ECI position to LVLH.

ECI position to LVLH.

Parameters
r_eciPosition vector of reference center in the ECI frame
v_eciVelocity vector of reference center in the ECI frame
vPosition vector in lvlh frame
Returns
Position vector in the eci frame

References q_eci_to_lvlh().

◆ r_eci_to_lvlh()

ml_matrix r_eci_to_lvlh ( const ml_matrix &  r_eci,
const ml_matrix &  v_eci,
const ml_matrix &  r 
)

LVLH position to ECI.

LVLH position to ECI.

Parameters
r_eciPosition vector of reference center in the ECI frame
v_eciVelocity vector of reference center in the ECI frame
rPosition vector in eci frame
Returns
Position vector in the lvlh frame

References q_eci_to_lvlh().

◆ v_eci_to_lvlh()

ml_matrix v_eci_to_lvlh ( const ml_matrix &  r_eci,
const ml_matrix &  v_eci,
const ml_matrix &  v 
)

ECI position to LVLH.

ECI position to LVLH.

Parameters
r_eciPosition vector of reference center in the ECI frame
v_eciVelocity vector of reference center in the ECI frame
vPosition vector in eci frame
Returns
Position vector in the lvlh frame

References q_eci_to_lvlh().

◆ x_lvlh_to_eci() [1/2]

ml_matrix x_lvlh_to_eci ( const ml_matrix &  r_eci,
const ml_matrix &  v_eci,
const ml_matrix &  x 
)

LVLH state to ECI.

LVLH state to ECI.

Parameters
r_eciPosition vector of reference center in the ECI frame
v_eciVelocity vector of reference center in the ECI frame
x[r;v] in lvlh frame
Returns
Position vector in the eci frame

References q_eci_to_lvlh().

◆ x_eci_to_lvlh() [1/2]

ml_matrix x_eci_to_lvlh ( const ml_matrix &  r_eci,
const ml_matrix &  v_eci,
const ml_matrix &  x 
)

ECI state to LVLH.

ECI state to LVLH.

Parameters
r_eciPosition vector of reference center in the ECI frame
v_eciVelocity vector of reference center in the ECI frame
x[r;v] in eci frame
Returns
Position vector in the eci frame

References q_eci_to_lvlh().

◆ x_lvlh_to_eci() [2/2]

ml_matrix x_lvlh_to_eci ( const ml_matrix &  x_eci,
const ml_matrix &  x 
)

ECI state to LVLH.

ECI state to LVLH.

Parameters
x_eciVelocity vector of reference center in the ECI frame
x[r;v] in lvlh frame
Returns
Position vector in the eci frame

References q_eci_to_lvlh().

◆ x_eci_to_lvlh() [2/2]

ml_matrix x_eci_to_lvlh ( const ml_matrix &  x_eci,
const ml_matrix &  x 
)

ECI state to LVLH.

ECI state to LVLH.

Parameters
x_eciState vector of reference center in the ECI frame [r;v]
x[r;v] in eci frame
Returns
State in the eci frame

References q_eci_to_lvlh().

◆ LLAToECEF()

ml_matrix LLAToECEF ( const ml_matrix &  lla,
double  rP 
)

Compute ECEF position from latitude, longitude, altitude.

Compute ECEF position from latitude, longitude, altitude.

Assumes a spherical planet. Can handle an array of positions.

Parameters
lla(3xn) Latitude [rad], longitude [rad], altitude [km]
rPRadius of planet (for Earth: 6378.14) [km]
Returns
ECEF position vector [km]

◆ small_angles_to_q()

ml_matrix small_angles_to_q ( const ml_matrix &  angle)

Convert small angles to a quaternion.

Parameters
angleAngle vector
Returns
Equivalent quaternion

◆ spice_to_3_by_3()

ml_matrix spice_to_3_by_3 ( const ml_matrix &  m,
int  k 
)

Convert SPICE rotation matrix to 3x3.

Convert SPICE rotation matrix to 3x3.

Parameters
mSPICE 9-by-1 rotation matrix (column major)
kColumn
Returns
3-by-3 matrix Planet fixed to ECI

◆ esd_to_azim()

double esd_to_azim ( const ml_matrix &  u)

Convert an East-South-Down vector to azimuth from North.

Parameters
uUnit vector in ESD frame
Returns
Azimuth angle from North vector (rad)

References PI.

Referenced by beam_contour::rotateAxis().

◆ esd_to_elev()

double esd_to_elev ( const ml_matrix &  u)

Convert an East-South-Down vector to elevation from nadir.

Parameters
uUnit vector in ESD frame
Returns
Elevation angle from nadir vector (rad)

Referenced by beam_contour::rotateAxis().

◆ azim_elev_to_esd()

ml_matrix azim_elev_to_esd ( const double &  azim,
const double &  elev 
)

Convert azimuth / elevation angles to an East-South-Down unit vector.

Parameters
azimAzimuth angle from North vector (rad)
elevElevation angle from nadir vector (rad)
Returns
Unit vector in ESD frame, 3x1 matrix

◆ ecef_to_esd()

ml_matrix ecef_to_esd ( const ml_matrix &  rEF)

Compute rotation matrix from Earth-fixed frame to East-South-Down frame at given Earth-fixed position.

Compute rotation matrix from Earth-fixed frame to East-South-Down frame at given Earth-fixed position.

Parameters
rEFEarth-fixed position
Returns
Rotation matrix from EF to ESD

◆ u_eci_to_az_el_body()

ml_matrix u_eci_to_az_el_body ( const ml_matrix &  u_eci,
const ml_matrix &  q_eci_to_body,
const ml_matrix &  q_body_to_base 
)

Find az and el from an ECI vector.

Parameters
u_eciVector in eci
q_eci_to_bodyQuaternion from ecu to body frame
q_body_to_sensorQuaternion from body to sensor frame
Returns
[az;el] radians

References u_to_az_el().

◆ sun_vector_pointing()

sun_vector_out sun_vector_pointing ( const ml_matrix &  u_eci,
const ml_matrix &  u_sun_eci 
)

Rotation angles to point a solar wing at the sun.

Rotation angles to point a solar wing at the sun.

Parameters
u_ecix-axis vector in
u_sun_eciSun vector in eci
Returns
sun_vector_out(q and wing angle)

References sun_vector_out_s::angle_solar_wing, mat_to_q(), sun_vector_out_s::q_eci_to_body, and u_to_q().

◆ target_from_r_v_d()

ml_matrix target_from_r_v_d ( const ml_matrix &  r,
double  r_p,
const ml_matrix &  v,
double  d 
)

Landing target.

Landing target.

Parameters
rPosition vector of spacecraft
r_pPlanet radius
vVelocity vector
dDownrange distance
Returns
Target vector

References au_to_q().