pf_vector.h

00001 
00002 /**************************************************************************
00003  * Desc: Vector functions
00004  * Author: Andrew Howard
00005  * Date: 10 Dec 2002
00006  * CVS: $Id: pf_vector.h 1213 2003-02-10 01:37:19Z inspectorg $
00007  *************************************************************************/
00008 
00009 #ifndef PF_VECTOR_H
00010 #define PF_VECTOR_H
00011 
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015 
00016 #include <stdio.h>
00017   
00018 // The basic vector
00019 typedef struct
00020 {
00021   double v[3];
00022 } pf_vector_t;
00023 
00024 
00025 // The basic matrix
00026 typedef struct
00027 {
00028   double m[3][3];
00029 } pf_matrix_t;
00030 
00031 
00032 // Return a zero vector
00033 pf_vector_t pf_vector_zero();
00034 
00035 // Check for NAN or INF in any component
00036 int pf_vector_finite(pf_vector_t a);
00037 
00038 // Print a vector
00039 void pf_vector_fprintf(pf_vector_t s, FILE *file, const char *fmt);
00040 
00041 // Simple vector addition
00042 pf_vector_t pf_vector_add(pf_vector_t a, pf_vector_t b);
00043 
00044 // Simple vector subtraction
00045 pf_vector_t pf_vector_sub(pf_vector_t a, pf_vector_t b);
00046 
00047 // Transform from local to global coords (a + b)
00048 pf_vector_t pf_vector_coord_add(pf_vector_t a, pf_vector_t b);
00049 
00050 // Transform from global to local coords (a - b)
00051 pf_vector_t pf_vector_coord_sub(pf_vector_t a, pf_vector_t b);
00052 
00053 
00054 // Return a zero matrix
00055 pf_matrix_t pf_matrix_zero();
00056 
00057 // Check for NAN or INF in any component
00058 int pf_matrix_finite(pf_matrix_t a);
00059 
00060 // Print a matrix
00061 void pf_matrix_fprintf(pf_matrix_t s, FILE *file, const char *fmt);
00062 
00063 // Compute the matrix inverse.  Will also return the determinant,
00064 // which should be checked for underflow (indicated singular matrix).
00065 pf_matrix_t pf_matrix_inverse(pf_matrix_t a, double *det);
00066 
00067 // Decompose a covariance matrix [a] into a rotation matrix [r] and a
00068 // diagonal matrix [d] such that a = r * d * r^T.
00069 void pf_matrix_unitary(pf_matrix_t *r, pf_matrix_t *d, pf_matrix_t a);
00070 
00071 #ifdef __cplusplus
00072 }
00073 #endif
00074 
00075 #endif

Last updated 12 September 2005 21:38:45