pf_vector.h
1/*
2 * Player - One Hell of a Robot Server
3 * Copyright (C) 2003
4 * Andrew Howard
5 * Brian Gerkey
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23
24/**************************************************************************
25 * Desc: Vector functions
26 * Author: Andrew Howard
27 * Date: 10 Dec 2002
28 * CVS: $Id$
29 *************************************************************************/
30
31#ifndef PF_VECTOR_H
32#define PF_VECTOR_H
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#include <stdio.h>
39
40// The basic vector
41typedef struct
42{
43 double v[3];
45
46
47// The basic matrix
48typedef struct
49{
50 double m[3][3];
52
53
54// Return a zero vector
55pf_vector_t pf_vector_zero();
56
57// Check for NAN or INF in any component
58int pf_vector_finite(pf_vector_t a);
59
60// Print a vector
61void pf_vector_fprintf(pf_vector_t s, FILE *file, const char *fmt);
62
63// Simple vector addition
64pf_vector_t pf_vector_add(pf_vector_t a, pf_vector_t b);
65
66// Simple vector subtraction
67pf_vector_t pf_vector_sub(pf_vector_t a, pf_vector_t b);
68
69// Transform from local to global coords (a + b)
70pf_vector_t pf_vector_coord_add(pf_vector_t a, pf_vector_t b);
71
72// Transform from global to local coords (a - b)
73pf_vector_t pf_vector_coord_sub(pf_vector_t a, pf_vector_t b);
74
75
76// Return a zero matrix
77pf_matrix_t pf_matrix_zero();
78
79// Check for NAN or INF in any component
80int pf_matrix_finite(pf_matrix_t a);
81
82// Print a matrix
83void pf_matrix_fprintf(pf_matrix_t s, FILE *file, const char *fmt);
84
85// Compute the matrix inverse. Will also return the determinant,
86// which should be checked for underflow (indicated singular matrix).
87//pf_matrix_t pf_matrix_inverse(pf_matrix_t a, double *det);
88
89// Decompose a covariance matrix [a] into a rotation matrix [r] and a
90// diagonal matrix [d] such that a = r * d * r^T.
91void pf_matrix_unitary(pf_matrix_t *r, pf_matrix_t *d, pf_matrix_t a);
92
93#ifdef __cplusplus
94}
95#endif
96
97#endif
Definition pf_vector.h:49
Definition pf_vector.h:42