Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mathutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __MATHUTILS_H
25 #define __MATHUTILS_H
26 
27 #include <selforg/matrix.h>
28 #include <selforg/position.h>
29 #include "osgforwarddecl.h"
30 #include <osg/Math>
31 
32 namespace lpzrobots {
33 
34  class Axis;
35 
36 /* template<typename T> */
37 /* inline T clip(T v,T minimum, T maximum) */
38 /* { return clampBelow(clampAbove(v,minimum),maximum); } */
39 
40 /*template<typename T> */
41 /* inline T abs(T v) */
42 /*{ return ((v>0)?v:-v); } */
43 
44  template<typename T>
45  inline T normalize360(T v)
46  { while (v>360) v-=360; while (v<360) v+=360; return v; }
47  /*******************************************************************************/
48 
49 
50  /**
51  * returns a rotation matrix (osg) with the given angles
52  * alpha, beta and gamma
53  */
54  osg::Matrix osgRotate(const double& alpha, const double& beta, const double& gamma);
55 
56  /**
57  converts osg matrix to matrix of matrixlib
58  */
60 
61 
62  /**
63  returns a Rotation matrix that rotates the x-axis along with the given axis.
64  The other 2 axis (y,z) are ambiguous.
65  */
66  osg::Matrix rotationMatrixFromAxisX(const Axis& axis);
67 
68  /**
69  returns a Rotation matrix that rotates the z-axis along with the given axis.
70  The other 2 axis (x,y) are ambiguous.
71  */
72  osg::Matrix rotationMatrixFromAxisZ(const Axis& axis);
73 
74  /**
75  * returns the angle between two vectors (in rad)
76  */
77  double getAngle(const osg::Vec3& a, const osg::Vec3& b) ;
78 
79  /// converts an ode rotation matrix into a 3x3 rotation matrix (matrixlib)
80  matrix::Matrix odeRto3x3RotationMatrixT ( const double R[12] );
81 
82  /// converts an ode rotation matrix into a 3x3 rotation matrix (matrixlib)
83  matrix::Matrix odeRto3x3RotationMatrix ( const double R[12] );
84 
85  /*******************************************************************************/
86 
87  /**
88  Multiplies 3x3 matrix with position
89  */
91 
92  /**
93  * returns a rotation matrix with the given angle
94  */
95  matrix::Matrix getRotationMatrix(const double& angle);
96 
97 
98  /**
99  * returns a translation matrix with the given Position
100  */
102 
103 
104  /**
105  * removes the translation in the matrix
106  */
108 
109 
110  /**
111  * removes the rotation in the matrix
112  */
114 
115 
116  /**
117  * returns the angle between two vectors
118  */
119  double getAngle(Position a, Position b) ;
120 
121 }
122 
123 #endif
Matrix getRotationMatrix(const double &angle)
returns a rotation matrix with the given angle
Definition: mathutils.cpp:128
Matrix type.
Definition: matrix.h:65
matrix::Matrix odeRto3x3RotationMatrixT(const double R[12])
converts an ode rotation matrix into a 3x3 rotation matrix (matrixlib)
Definition: mathutils.cpp:85
Position multMatrixPosition(const Matrix &r, Position &p)
Multiplies 3x3 matrix with position.
Definition: mathutils.cpp:118
Matrixd Matrix
Definition: osgforwarddecl.h:47
double getAngle(const osg::Vec3 &a, const osg::Vec3 &b)
returns the angle between two vectors (in rad)
Definition: mathutils.cpp:79
Definition: position.h:30
T normalize360(T v)
Definition: mathutils.h:45
Vec3f Vec3
Definition: osgforwarddecl.h:42
osg::Matrix rotationMatrixFromAxisX(const Axis &axis)
returns a Rotation matrix that rotates the x-axis along with the given axis.
Definition: mathutils.cpp:63
Matrix osgMatrix2Matrixlib(const osg::Matrix &m)
converts osg matrix to matrix of matrixlib
Definition: mathutils.cpp:48
osg::Matrix osgRotate(const double &alpha, const double &beta, const double &gamma)
returns a rotation matrix (osg) with the given angles alpha, beta and gamma
Definition: mathutils.cpp:39
Matrix removeRotationInMatrix(const Matrix &pose)
removes the rotation in the matrix
Definition: mathutils.cpp:162
osg::Matrix rotationMatrixFromAxisZ(const Axis &axis)
returns a Rotation matrix that rotates the z-axis along with the given axis.
Definition: mathutils.cpp:71
const int T
integer constant for use with exp function and (^) operator to transpose the matrix ...
Definition: matrix.cpp:21
Matrix getTranslationMatrix(const Position &p)
returns a translation matrix with the given Position
Definition: mathutils.cpp:139
Matrix removeTranslationInMatrix(const Matrix &pose)
removes the translation in the matrix
Definition: mathutils.cpp:150
matrix::Matrix odeRto3x3RotationMatrix(const double R[12])
converts an ode rotation matrix into a 3x3 rotation matrix (matrixlib)
Definition: mathutils.cpp:99