bazar  1.3.1
linear_algebra.h
Go to the documentation of this file.
1 /*
2 Copyright 2005, 2006 Computer Vision Lab,
3 Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland.
4 All rights reserved.
5 
6 This file is part of BazAR.
7 
8 BazAR is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 BazAR is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 BazAR; if not, write to the Free Software Foundation, Inc., 51 Franklin
19 Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
22 #ifndef LINEAR_ALGEBRA_H
23 #define LINEAR_ALGEBRA_H
24 
25 #include <iostream>
26 using namespace std;
27 
28 // Vectors:
29 double gfla_norme(double v1, double v2, double v3);
30 
31 double gfla_normalize_3(double v[3]);
32 
33 void gfla_scale_3(const double s, double v[3]);
34 void gfla_scale_3(const double s, const double v[3], double sv[3]);
35 
36 void gfla_add_3(const double u[3], const double v[3], double w[3]);
37 void gfla_sub_3(const double u[3], const double v[3], double w[3]);
38 
39 void gfla_opp_3(double v[3]);
40 void gfla_cross_product(const double v1[3], const double v2[3], double v1v2[3]);
41 double gfla_dot_product(const double v1[3], const double v2[3]);
42 void gfla_copy_3(const double v[3], double copy[3]);
43 
44 // Copy matrices:
45 void gfla_copy_3x3(const double M[3][3], double copy[3][3]);
46 void gfla_copy_3x4(const double M[3][4], double copy[3][4]);
47 
48 // Matrices:
49 double gfla_det(const double M[3][3]);
50 double gfla_det(const double M11, const double M12,
51  const double M21, const double M22);
52 double gfla_det(const double M11, const double M12, const double M13,
53  const double M21, const double M22, const double M23,
54  const double M31, const double M32, const double M33);
55 
56 // Print matrices:
57 void gfla_print_mat_3x3(ostream & o, double M[3][3]);
58 void gfla_print_mat_3x4(ostream & o, double M[3][4]);
59 void gfla_print_mat_4x4(ostream & o, double * M);
60 
61 // Rotation matrices:
62 void gfla_get_rotation_from_euler_angles(double R[3][3], const double omega, const double phi, const double kappa);
63 int gfla_get_euler_angles_from_rotation(const double R[3][3], double * omega, double * phi, double * kappa);
64 
65 // Multiplication Vectors/Matrices
66 void gfla_mul_scale_mat_3x3(double s, double M[3][3], double sM[3][3]);
67 
68 void gfla_mul_mat_vect_3x3(const double M[3][3], const double v[3], double Mv[3]);
69 void gfla_mul_T_mat_vect_3x3(const double M[3][3], const double v[3], double tMv[3]);
70 void gfla_mul_mat_vect_3x4(const double M[3][4], const double v[3], double Mv[3]);
71 void gfla_mul_mat_3x3x4(const double M[3][3], const double N[3][4], double MN[3][4]);
72 
73 // Inverse
74 void gfla_inverse_3(double A[3][3], double invA[3][3]);
75 
76 #endif // LINEAR_ALGEBRA_H