pf_vector.h
00001 /* 00002 * Player - One Hell of a Robot Server 00003 * Copyright (C) 2003 00004 * Andrew Howard 00005 * Brian Gerkey 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 */ 00022 00023 00024 /************************************************************************** 00025 * Desc: Vector functions 00026 * Author: Andrew Howard 00027 * Date: 10 Dec 2002 00028 * CVS: $Id: pf_vector.h 8108 2009-07-23 23:03:37Z thjc $ 00029 *************************************************************************/ 00030 00031 #ifndef PF_VECTOR_H 00032 #define PF_VECTOR_H 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 00038 #include <stdio.h> 00039 00040 // The basic vector 00041 typedef struct 00042 { 00043 double v[3]; 00044 } pf_vector_t; 00045 00046 00047 // The basic matrix 00048 typedef struct 00049 { 00050 double m[3][3]; 00051 } pf_matrix_t; 00052 00053 00054 // Return a zero vector 00055 pf_vector_t pf_vector_zero(); 00056 00057 // Check for NAN or INF in any component 00058 int pf_vector_finite(pf_vector_t a); 00059 00060 // Print a vector 00061 void pf_vector_fprintf(pf_vector_t s, FILE *file, const char *fmt); 00062 00063 // Simple vector addition 00064 pf_vector_t pf_vector_add(pf_vector_t a, pf_vector_t b); 00065 00066 // Simple vector subtraction 00067 pf_vector_t pf_vector_sub(pf_vector_t a, pf_vector_t b); 00068 00069 // Transform from local to global coords (a + b) 00070 pf_vector_t pf_vector_coord_add(pf_vector_t a, pf_vector_t b); 00071 00072 // Transform from global to local coords (a - b) 00073 pf_vector_t pf_vector_coord_sub(pf_vector_t a, pf_vector_t b); 00074 00075 00076 // Return a zero matrix 00077 pf_matrix_t pf_matrix_zero(); 00078 00079 // Check for NAN or INF in any component 00080 int pf_matrix_finite(pf_matrix_t a); 00081 00082 // Print a matrix 00083 void pf_matrix_fprintf(pf_matrix_t s, FILE *file, const char *fmt); 00084 00085 // Compute the matrix inverse. Will also return the determinant, 00086 // which should be checked for underflow (indicated singular matrix). 00087 //pf_matrix_t pf_matrix_inverse(pf_matrix_t a, double *det); 00088 00089 // Decompose a covariance matrix [a] into a rotation matrix [r] and a 00090 // diagonal matrix [d] such that a = r * d * r^T. 00091 void pf_matrix_unitary(pf_matrix_t *r, pf_matrix_t *d, pf_matrix_t a); 00092 00093 #ifdef __cplusplus 00094 } 00095 #endif 00096 00097 #endif