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
axis.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 __AXIS_H
25 #define __AXIS_H
26 
27 #include <osg/Vec3>
28 #include <osg/Vec4>
29 #include <ode-dbl/ode.h>
30 #include <iostream>
31 
32 namespace lpzrobots{
33 
34  // class for axis. This is a internally a 4 dimensional vector (homogenenous) with last component = 0
35  // meaning it is a direction not a point
36  class Axis : public osg::Vec4 {
37  public:
38  Axis () : osg::Vec4() {}
39  Axis (float x, float y, float z) : osg::Vec4(x, y, z, 0) {}
40  Axis (const osg::Vec4& v) : osg::Vec4(v) { w() =0; }
41  Axis (const osg::Vec3& v) : osg::Vec4(v,0) {}
42  Axis (const dReal v[3]) : osg::Vec4(v[0], v[1], v[2], 0) {}
43 
44  osg::Vec3 vec3() const { return osg::Vec3( x(), y(), z()); }
45 
46  float enclosingAngle(const Axis& a) const {
47  return acos((*this * a)/(this->length() * a.length()));
48  }
49 
50  Axis crossProduct(const Axis& a) const {
51  return Axis(y()*a.z() - z()*a.y(), z()*a.x() - x()*a.z(), x()*a.y() - y()*a.x());
52  }
53 
54  void print(){
55  std::cout << '(' << x() << ',' << y() << ',' << z() << ')' << std::endl;
56  }
57  };
58 
59 }
60 
61 #endif
Definition: axis.h:36
Axis crossProduct(const Axis &a) const
Definition: axis.h:50
Axis(const osg::Vec4 &v)
Definition: axis.h:40
Axis(float x, float y, float z)
Definition: axis.h:39
Axis(const osg::Vec3 &v)
Definition: axis.h:41
Vec3f Vec3
Definition: osgforwarddecl.h:42
void print()
Definition: axis.h:54
float enclosingAngle(const Axis &a) const
Definition: axis.h:46
Axis()
Definition: axis.h:38
Vec4f Vec4
Definition: osgforwarddecl.h:44
osg::Vec3 vec3() const
Definition: axis.h:44
Axis(const dReal v[3])
Definition: axis.h:42