Spacecraft Control Framework 1.0
Spacecraft Control Library
sc_math.h
Go to the documentation of this file.
1/*
2 * sc_math.h
3 *
4 * Programmers: Stephanie Thomas, Michael Paluszek
5 *
6 * Copyright 2000-2006, Princeton Satellite Systems. All rights reserved.
7 *
8 * Math functions.
9 */
10
17#ifndef __SC_MATH__
18#define __SC_MATH__
19
20#include <math.h>
21#ifdef AS_OS_WINDOWS
22#include "matrixlib.h"
23#else
24#include <MatrixLib/MatrixLib.h>
25#endif
26#include "sc_constants.h"
27
28extern "C++"
29{
30
32double golden_section( double RHS( double x, void *context ), double a, double b, double tol, int maxIts, void *context );
34ml_matrix rk0( ml_matrix RHS( ml_matrix x, double t, void *context ), ml_matrix& x, double h, double t, void *context );
36ml_matrix rk4 ( ml_matrix RHS( ml_matrix x, double t ), ml_matrix& x, double h, double t );
38ml_matrix rk4( ml_matrix RHS( ml_matrix x, double t, void *context ), ml_matrix& x, double h, double t, void *context );
40ml_matrix rk4 ( ml_matrix RHS( ml_matrix& x, ml_matrix& a ), ml_matrix& x, double h, ml_matrix a );
42double pss_rem( double x, double y );
44double fix( double x );
46double r2p5( double x );
48int sct_sign( double x );
50double sct_max(double a, double b);
52double unwrap( double angle );
54ml_matrix intersect_line_ellipsoid(const ml_matrix& p, const ml_matrix& u, const ml_matrix& e);
56ml_matrix intersect_line_sphere(const ml_matrix& p, const ml_matrix& u, double r );
58ml_matrix p_gauss( int nMax, int mMax, double theta, ml_matrix &dp );
60void s_c_harm( const ml_matrix& a, int n, ml_matrix& s, ml_matrix& c );
62void c_to_d_zoh( const ml_matrix& a, const ml_matrix& b, double dT, ml_matrix& aD, ml_matrix& bD );
64ml_matrix expm( const ml_matrix& a );
66double WrapPhase( double angle );
68ml_matrix WrapPhase( ml_matrix angle );
70ml_matrix UnwrapPhase( ml_matrix theta );
72ml_matrix diff( ml_matrix a );
74ml_matrix delt_circ( ml_matrix x, ml_matrix y );
76ml_matrix circle_fit( ml_matrix x, ml_matrix y );
78double factorial( double n );
80double interp_2d(ml_matrix a, ml_matrix x, ml_matrix y, double xK, double yK );
82double newton_raphson( double f( double x, void *context ), double df( double x, void *context ), double x0,double tol, int nMax, void *context );
84double secant( double RHS( double x, void *context ), double x0, double x00, double tol, int nMax, void *context );
86ml_matrix average_unit_vector( ml_matrix u1, ml_matrix u2 );
88ml_matrix pinv( ml_matrix a );
90ml_matrix downhill_simplex( double RHS( const ml_matrix& x, void *context ), ml_matrix& x, ml_matrix& options, void *context );
92ml_matrix orthogonalize( ml_matrix a );
94ml_matrix logistic( ml_matrix x );
96double logistic( double x );
98double interp_extrap_1d(ml_matrix a, ml_matrix x, double xK);
100double gaussian_multivariate_density(ml_matrix y, ml_matrix y_bar, ml_matrix P );
102ml_matrix roots_second_order( double a, double b, double c );
104ml_matrix roots_second_order( const ml_matrix& p );
106ml_matrix skew_symmetric( const ml_matrix& p );
108double trig_reduction( double a, double b, double c );
110ml_matrix m_k_3_by_3( const ml_matrix& m, int k );
112int intersect_line_sphere_true( const ml_matrix& p1, const ml_matrix& p2, double r );
114ml_matrix append_diagonal( const ml_matrix& a, const ml_matrix& b);
116double trapezoidal_integration(double Integrand( double x, void *context ), double a, double b, int n, void* context);
118double 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);
119
120
121}
122
123#endif
Physical and mathematical constants.
double sct_max(double a, double b)
Find maximum of two numbers.
Definition: sc_math.cc:317
double golden_section(double RHS(double x, void *context), double a, double b, double tol, int maxIts, void *context)
Golden section minimization.
Definition: sc_math.cc:118
int intersect_line_sphere_true(const ml_matrix &p1, const ml_matrix &p2, double r)
Find if a line intersects a sphere.
Definition: sc_math.cc:1300
double r2p5(double x)
Round to nearest 0.5.
Definition: sc_math.cc:263
ml_matrix m_k_3_by_3(const ml_matrix &m, int k)
Returns a 3x3 matrix from a 3x3*n matrix.
Definition: sc_math.cc:1286
void s_c_harm(const ml_matrix &a, int n, ml_matrix &s, ml_matrix &c)
Generate a series of sine and cosine harmonics.
Definition: sc_math.cc:506
int sct_sign(double x)
Determine sign of number and return unitary value.
Definition: sc_math.cc:300
double secant(double RHS(double x, void *context), double x0, double x00, double tol, int nMax, void *context)
1 dimensional root finder
Definition: sc_math.cc:891
ml_matrix intersect_line_sphere(const ml_matrix &p, const ml_matrix &u, double r)
Find the intersection between a line and an sphere.
Definition: sc_math.cc:374
ml_matrix expm(const ml_matrix &a)
Compute the matrix exponential (of a square matrix only) using a power series expansion.
Definition: sc_math.cc:587
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.
Definition: sc_math.cc:1389
ml_matrix diff(ml_matrix a)
Compute the difference between successive elements of a 1-D vector.
Definition: sc_math.cc:692
ml_matrix circle_fit(ml_matrix x, ml_matrix y)
Compute a delta in circular coordinates.
Definition: sc_math.cc:785
ml_matrix append_diagonal(const ml_matrix &a, const ml_matrix &b)
Append a diagonal matrix to another matrix.
Definition: sc_math.cc:1324
double interp_extrap_1d(ml_matrix a, ml_matrix x, double xK)
1D interpolation and extrapolation
Definition: sc_math.cc:1130
double factorial(double n)
Compute a factorial.
Definition: sc_math.cc:808
ml_matrix roots_second_order(double a, double b, double c)
Roots second order.
Definition: sc_math.cc:1206
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.
Definition: sc_math.cc:410
double WrapPhase(double angle)
Wrap a phase angle to keep its value between -pi and +pi.
Definition: sc_math.cc:616
double gaussian_multivariate_density(ml_matrix y, ml_matrix y_bar, ml_matrix P)
Gaussian Mulivariate Normal Distribution function.
Definition: sc_math.cc:1170
double trapezoidal_integration(double Integrand(double x, void *context), double a, double b, int n, void *context)
Trapezoidal integration.
Definition: sc_math.cc:1362
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
Definition: sc_math.cc:185
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.
Definition: sc_math.cc:565
double interp_2d(ml_matrix a, ml_matrix x, ml_matrix y, double xK, double yK)
2D interpolation
Definition: sc_math.cc:825
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
Definition: sc_math.cc:871
ml_matrix skew_symmetric(const ml_matrix &p)
Generate a skew symmetric matrix.
Definition: sc_math.cc:1266
ml_matrix orthogonalize(ml_matrix a)
Orthogonalize.
Definition: sc_math.cc:98
double pss_rem(double x, double y)
Remainder function.
Definition: sc_math.cc:254
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
Definition: sc_math.cc:199
double trig_reduction(double a, double b, double c)
Solve for beta: a*sin(beta)+b*cos(beta) = c.
Definition: sc_math.cc:1245
ml_matrix pinv(ml_matrix a)
Pseudo inverse.
Definition: sc_math.cc:22
ml_matrix UnwrapPhase(ml_matrix theta)
Unwrap a vector of angular values so they change continuously instead of wrapping.
Definition: sc_math.cc:656
double unwrap(double angle)
Unwrap radian values to (-pi,pi) interval.
Definition: sc_math.cc:327
ml_matrix downhill_simplex(double RHS(const ml_matrix &x, void *context), ml_matrix &x, ml_matrix &options, void *context)
Downhill simplex.
Definition: sc_math.cc:923
double fix(double x)
Round to 0.
Definition: sc_math.cc:283
ml_matrix logistic(ml_matrix x)
Logistic function.
Definition: sc_math.cc:1105
ml_matrix average_unit_vector(ml_matrix u1, ml_matrix u2)
Average unit vector.
Definition: sc_math.cc:1089
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.
Definition: sc_math.cc:346
ml_matrix delt_circ(ml_matrix x, ml_matrix y)
Compute a delta in circular coordinates.
Definition: sc_math.cc:725