Spacecraft Control Framework 1.0
Spacecraft Control Library
|
Math utility functions. More...
Go to the source code of this file.
Functions | |
double | golden_section (double RHS(double x, void *context), double a, double b, double tol, int maxIts, void *context) |
Golden section minimization. More... | |
ml_matrix | rk0 (ml_matrix RHS(ml_matrix x, double t, void *context), ml_matrix &x, double h, double t, void *context) |
0th order Runge-Kutta integration algorithm with time as a RHS input More... | |
ml_matrix | rk4 (ml_matrix RHS(ml_matrix x, double t), ml_matrix &x, double h, double t) |
4th order Runge-Kutta integration algorithm with time as a RHS input More... | |
ml_matrix | rk4 (ml_matrix RHS(ml_matrix x, double t, void *context), ml_matrix &x, double h, double t, void *context) |
4th order Runge-Kutta integration algorithm with time as a RHS input and a context pointer | |
ml_matrix | rk4 (ml_matrix RHS(ml_matrix &x, ml_matrix &a), ml_matrix &x, double h, ml_matrix a) |
4th order Runge-Kutta integration algorithm with a matrix input to the RHS | |
double | pss_rem (double x, double y) |
Remainder function. More... | |
double | fix (double x) |
Round to 0. More... | |
double | r2p5 (double x) |
Round to nearest 0.5. More... | |
int | sct_sign (double x) |
Determine sign of number and return unitary value. More... | |
double | sct_max (double a, double b) |
Find maximum of two numbers. More... | |
double | unwrap (double angle) |
Unwrap radian values to (-pi,pi) interval. More... | |
ml_matrix | intersect_line_ellipsoid (const ml_matrix &p, const ml_matrix &u, const ml_matrix &e) |
Find the intersection between a line and an ellipsoid. More... | |
ml_matrix | intersect_line_sphere (const ml_matrix &p, const ml_matrix &u, double r) |
Find the intersection between a line and an sphere. More... | |
ml_matrix | p_gauss (int nMax, int mMax, double theta, ml_matrix &dp) |
Computes the Gaussian form of the Legendre functions and the first derivatives. More... | |
void | s_c_harm (const ml_matrix &a, int n, ml_matrix &s, ml_matrix &c) |
Generate a series of sine and cosine harmonics. More... | |
void | c_to_d_zoh (const ml_matrix &a, const ml_matrix &b, double dT, ml_matrix &aD, ml_matrix &bD) |
Compute a discrete-time linear system from a continuous system. More... | |
ml_matrix | expm (const ml_matrix &a) |
Compute the matrix exponential (of a square matrix only) using a power series expansion. More... | |
double | WrapPhase (double angle) |
Wrap a phase angle to keep its value between -pi and +pi. More... | |
ml_matrix | WrapPhase (ml_matrix angle) |
Wrap a vector of phase angles to keep their values between -pi and +pi. More... | |
ml_matrix | UnwrapPhase (ml_matrix theta) |
Unwrap a vector of angular values so they change continuously instead of wrapping. More... | |
ml_matrix | diff (ml_matrix a) |
Compute the difference between successive elements of a 1-D vector. More... | |
ml_matrix | delt_circ (ml_matrix x, ml_matrix y) |
Compute a delta in circular coordinates. More... | |
ml_matrix | circle_fit (ml_matrix x, ml_matrix y) |
Compute a delta in circular coordinates. More... | |
double | factorial (double n) |
Compute a factorial. | |
double | interp_2d (ml_matrix a, ml_matrix x, ml_matrix y, double xK, double yK) |
2D interpolation | |
double | newton_raphson (double f(double x, void *context), double df(double x, void *context), double x0, double tol, int nMax, void *context) |
1 dimensional root finder | |
double | secant (double RHS(double x, void *context), double x0, double x00, double tol, int nMax, void *context) |
1 dimensional root finder | |
ml_matrix | average_unit_vector (ml_matrix u1, ml_matrix u2) |
Average unit vector. | |
ml_matrix | pinv (ml_matrix a) |
Pseudo inverse. More... | |
ml_matrix | downhill_simplex (double RHS(const ml_matrix &x, void *context), ml_matrix &x, ml_matrix &options, void *context) |
Downhill simplex. More... | |
ml_matrix | orthogonalize (ml_matrix a) |
Orthogonalize. More... | |
ml_matrix | logistic (ml_matrix x) |
Logistic function. More... | |
double | logistic (double x) |
Logistic function. More... | |
double | interp_extrap_1d (ml_matrix a, ml_matrix x, double xK) |
1D interpolation and extrapolation More... | |
double | gaussian_multivariate_density (ml_matrix y, ml_matrix y_bar, ml_matrix P) |
Gaussian Mulivariate Normal Distribution function. More... | |
ml_matrix | roots_second_order (double a, double b, double c) |
Roots second order. More... | |
ml_matrix | roots_second_order (const ml_matrix &p) |
Roots second order. More... | |
ml_matrix | skew_symmetric (const ml_matrix &p) |
Generate a skew symmetric matrix. More... | |
double | trig_reduction (double a, double b, double c) |
Solve for beta: a*sin(beta)+b*cos(beta) = c. More... | |
ml_matrix | m_k_3_by_3 (const ml_matrix &m, int k) |
Returns a 3x3 matrix from a 3x3*n matrix. More... | |
int | intersect_line_sphere_true (const ml_matrix &p1, const ml_matrix &p2, double r) |
Find if a line intersects a sphere. More... | |
ml_matrix | append_diagonal (const ml_matrix &a, const ml_matrix &b) |
Append a diagonal matrix to another matrix. More... | |
double | trapezoidal_integration (double Integrand(double x, void *context), double a, double b, int n, void *context) |
Trapezoidal integration. More... | |
double | two_dimensional_integration (ml_matrix Integrand(const ml_matrix &x, const ml_matrix &y, void *context), double a, double b, double c, double d, int nX, int nY, void *context) |
Two dimensional integration. More... | |
Math utility functions.
double golden_section | ( | double | RHSdouble x, void *context, |
double | a, | ||
double | b, | ||
double | tol, | ||
int | maxIts, | ||
void * | context | ||
) |
Golden section minimization.
RHS | Right-hand side function definition |
a | Left range |
b | Right range |
tol | Tolerance |
maxIts | Maximum number of interations |
*context | to data from RSH |
ml_matrix rk0 | ( | ml_matrix | RHSml_matrix x, double t, void *context, |
ml_matrix & | x, | ||
double | h, | ||
double | t, | ||
void * | context | ||
) |
0th order Runge-Kutta integration algorithm with time as a RHS input
0th order Runge-Kutta integration algorithm with time as a RHS input
RHS actually does the propagation
RHS | Right-hand side function definition |
x | Current state |
h | Integration time step |
t | Current time |
*context | Pointer to data to be passed to RHS |
ml_matrix rk4 | ( | ml_matrix | RHSml_matrix x, double t, |
ml_matrix & | x, | ||
double | h, | ||
double | t | ||
) |
4th order Runge-Kutta integration algorithm with time as a RHS input
4th order Runge-Kutta integration algorithm with time as a RHS input
RHS | Right-hand side function definition |
x | Current state |
h | Integration time step |
t | Current time |
double pss_rem | ( | double | x, |
double | y | ||
) |
Remainder function.
Remainder function.
x | Numerator |
y | Denominator |
Referenced by delt_circ(), and r2p5().
double fix | ( | double | x | ) |
Round to 0.
Round to 0.
x | Number to be rounded |
Referenced by jd_to_date().
double r2p5 | ( | double | x | ) |
Round to nearest 0.5.
Round to nearest 0.5.
x | Number to be rounded |
References pss_rem().
Referenced by jd_to_date(), and mean_sidereal_day().
int sct_sign | ( | double | x | ) |
Determine sign of number and return unitary value.
Determine sign of number and return unitary value.
x | Number |
Referenced by ImpulsiveManeuver(), InPlane(), OutOfPlane(), and Target().
double sct_max | ( | double | a, |
double | b | ||
) |
Find maximum of two numbers.
Find maximum of two numbers.
a | First number |
b | Second number |
double unwrap | ( | double | angle | ) |
Unwrap radian values to (-pi,pi) interval.
Unwrap radian values to (-pi,pi) interval.
angle | Angle in radians |
Referenced by PID3Axis::Update().
ml_matrix intersect_line_ellipsoid | ( | const ml_matrix & | p, |
const ml_matrix & | u, | ||
const ml_matrix & | e | ||
) |
Find the intersection between a line and an ellipsoid.
Always returns the closest point. The line is defined by a point and unit vectors. Returns empty if there is no intersection
p | (3,1) Point |
u | (3,1) Unit vector |
e | (3,1) (a,b,c) semi-axes of ellipsoid |
Referenced by intersect_line_sphere().
ml_matrix intersect_line_sphere | ( | const ml_matrix & | p, |
const ml_matrix & | u, | ||
double | r | ||
) |
Find the intersection between a line and an sphere.
Find the intersection between a line and an sphere.
Always returns the closest point. The line is defined by a point and unit vectors.
p | (3,1) Point |
u | (3,1) Unit vector |
r | (1,1) Radius of sphere |
References intersect_line_ellipsoid().
ml_matrix p_gauss | ( | int | nMax, |
int | mMax, | ||
double | theta, | ||
ml_matrix & | dp | ||
) |
Computes the Gaussian form of the Legendre functions and the first derivatives.
Computes the Gaussian form of the Legendre functions and the first derivatives.
Because there is no zero indexing in MATLAB, the P's are offset in the p matrix as follows:
n,m p(n+1,m+1) = P
MATLAB Form: [p, dP] = PGauss( nMax, mMax, theta )
References: Wertz, J., Spacecraft Attitude Determination and Control, Kluwer, 1976, pp. 781.
nMax | max value of first index |
mMax | max value of second index |
theta | input value (usually an angle in rads) |
dp | Matrix for derivative outputs dp(n,m) / d(theta) |
Referenced by mag_field().
void s_c_harm | ( | const ml_matrix & | a, |
int | n, | ||
ml_matrix & | s, | ||
ml_matrix & | c | ||
) |
Generate a series of sine and cosine harmonics.
Generate a series of sine and cosine harmonics.
a | Column vector (m,1) argument, in radians |
n | Number of harmonics |
s | Vector of sine harmonics output |
c | Vector of cosine harmonics output |
Referenced by mag_field().
void c_to_d_zoh | ( | const ml_matrix & | a, |
const ml_matrix & | b, | ||
double | dT, | ||
ml_matrix & | f, | ||
ml_matrix & | g | ||
) |
Compute a discrete-time linear system from a continuous system.
Compute a discrete-time linear system from a continuous system.
a | Continuous matrix |
b | Continuous matrix |
dT | Time step (sec) |
f | Discrete matrix |
g | Discrete matrix |
References expm().
Referenced by FFEccLinOrb(), LPCircular(), LPEccentricGVE(), and MonitoringAlg().
ml_matrix expm | ( | const ml_matrix & | a | ) |
Compute the matrix exponential (of a square matrix only) using a power series expansion.
a | Square matrix |
Referenced by c_to_d_zoh().
double WrapPhase | ( | double | angle | ) |
Wrap a phase angle to keep its value between -pi and +pi.
*sctlib
angle | Phase angle [rad] |
Referenced by add_elements(), CirclePhase(), El2Alfriend(), EllipsePhase(), FFEccGoals(), FFEccHills2Goals(), FFEccXExt(), FFEccYExt(), FFEccZExt(), GenerateTeamGoals(), InPlane(), MeanAnom2TrueLat(), MonitoringAlg(), OrbElemDiff(), orbit_acquisition_dv(), sub_elements(), and TargetTrueAnom().
ml_matrix WrapPhase | ( | ml_matrix | angle | ) |
ml_matrix UnwrapPhase | ( | ml_matrix | angle | ) |
Unwrap a vector of angular values so they change continuously instead of wrapping.
*sctlib
angle | Vector of angular values. [rad] |
References diff(), PI, and TWO_PI.
Referenced by DeltaEl2AlfriendMat(), FFEccDiscreteHills(), GenerateTimeVector(), ImpulsiveLPManeuver(), LPEccentric(), LPEccentricGVE(), and MonitoringAlg().
ml_matrix diff | ( | ml_matrix | a | ) |
Compute the difference between successive elements of a 1-D vector.
Compute the difference between successive elements of a 1-D vector.
a | 1-dimensional matrix, length N |
Referenced by AccelVector2ManeuverStruct(), DeltaEl2AlfriendMat(), FFEccDiscreteHills(), FFEccEstimateCost(), FFEccXExt(), FFEccYExt(), FFEccZExt(), ImpulsiveLPManeuver(), LPEccentricGVE(), LPEccentricTimeWeight(), MonitoringAlg(), NearestOffset(), OptimalAssignment(), and UnwrapPhase().
ml_matrix delt_circ | ( | ml_matrix | x, |
ml_matrix | y | ||
) |
ml_matrix circle_fit | ( | ml_matrix | x, |
ml_matrix | y | ||
) |
Compute a delta in circular coordinates.
Compute a delta in circular coordinates.
x | column matrix |
y | column matrix |
ml_matrix pinv | ( | ml_matrix | a | ) |
Pseudo inverse.
Pseudo inverse.
a | matrix |
Referenced by az_el_range_range_rate_to_rv(), camera_calibration(), momentum_unloading(), and q_from_u().
ml_matrix downhill_simplex | ( | double | RHSconst ml_matrix &x, void *context, |
ml_matrix & | x, | ||
ml_matrix & | options, | ||
void * | context | ||
) |
Downhill simplex.
RHS | Function to minimize |
x | Initial guess |
options | Options |
context | Context pointer to pass to RHS |
Referenced by fit_PSF_to_data().
ml_matrix orthogonalize | ( | ml_matrix | a | ) |
Orthogonalize.
Orthogonalize.
Orthogonalize a 3x3 matrix
a | matrix |
Referenced by camera_calibration(), and q_from_u().
ml_matrix logistic | ( | ml_matrix | x | ) |
Logistic function.
x | input |
double logistic | ( | double | x | ) |
Logistic function.
x | input |
double interp_extrap_1d | ( | ml_matrix | a, |
ml_matrix | x, | ||
double | xK | ||
) |
1D interpolation and extrapolation
1D interpolation and extrapolation
a | array of values |
x | corresponding x value |
xK | value of interest |
double gaussian_multivariate_density | ( | ml_matrix | y, |
ml_matrix | y_bar, | ||
ml_matrix | P | ||
) |
Gaussian Mulivariate Normal Distribution function.
Gaussian Mulivariate Normal Distribution function.
y | array of parameters |
y_bar | corresponding means |
P | covariance matrix |
ml_matrix roots_second_order | ( | double | a, |
double | b, | ||
double | c | ||
) |
Roots second order.
Roots second order.
a | Coefficient |
b | Coefficient |
c | Coefficient |
Referenced by roots_second_order().
ml_matrix roots_second_order | ( | const ml_matrix & | p | ) |
Roots second order.
Roots second order.
p | array of coefficients |
References roots_second_order().
ml_matrix skew_symmetric | ( | const ml_matrix & | v | ) |
Generate a skew symmetric matrix.
Generate a skew symmetric matrix.
v | Vector (3x1) |
Referenced by attitude_propagation_discrete(), discrete_state_transition_matrix(), multi_body_central_hub_with_rwa::state_derivative(), and multi_body_central_hub::state_derivative().
double trig_reduction | ( | double | a, |
double | b, | ||
double | c | ||
) |
Solve for beta: a*sin(beta)+b*cos(beta) = c.
a | Coefficient |
b | Coefficient |
c | RHS |
ml_matrix m_k_3_by_3 | ( | const ml_matrix & | m, |
int | k | ||
) |
Returns a 3x3 matrix from a 3x3*n matrix.
m | 3x3*n matrix |
k | index |
Referenced by multi_body_central_hub_with_rwa::state_derivative(), and multi_body_central_hub::state_derivative().
int intersect_line_sphere_true | ( | const ml_matrix & | p1, |
const ml_matrix & | p2, | ||
double | r | ||
) |
Find if a line intersects a sphere.
Find if a line intersects a sphere.
p1 | 3x1 origin point on the sphere |
p2 | 3x1 final point off the sphere |
r | Radius of sphere |
ml_matrix append_diagonal | ( | const ml_matrix & | a, |
const ml_matrix & | b | ||
) |
Append a diagonal matrix to another matrix.
Append a diagonal matrix to another matrix.
a | square matrix |
b | diagonal of a matrix |
double trapezoidal_integration | ( | double | Integranddouble x, void *context, |
double | a, | ||
double | b, | ||
int | n, | ||
void * | context | ||
) |
double two_dimensional_integration | ( | ml_matrix | Integrandconst ml_matrix &x, const ml_matrix &y, void *context, |
double | a, | ||
double | b, | ||
double | c, | ||
double | d, | ||
int | nX, | ||
int | nY, | ||
void * | context | ||
) |
Two dimensional integration.
Two dimensional integration.
Integrand | pointer to the integrand function |
a | Minimum x |
b | Maximum x |
c | Minimum y |
d | Maximum y |
nX | Number of divisions in x |
nY | Number of divisions in y |
*context | Pointer to data to pass to Integrand |
Referenced by imager_psf(), and imager_psf_uint16().