axis.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __AXIS_H
00025 #define __AXIS_H
00026 
00027 #include <osg/Vec3>
00028 #include <osg/Vec4>
00029 #include <ode-dbl/ode.h>
00030 #include <iostream>
00031 
00032 namespace lpzrobots{
00033 
00034   // class for axis. This is a internally a 4 dimensional vector (homogenenous) with last component = 0 
00035   //   meaning it is a direction not a point
00036   class Axis : public osg::Vec4 {
00037   public:
00038     Axis () : osg::Vec4() {}
00039     Axis (float x, float y, float z) : osg::Vec4(x, y, z, 0) {}
00040     Axis (const osg::Vec4& v) : osg::Vec4(v) { w() =0; }
00041     Axis (const osg::Vec3& v) : osg::Vec4(v,0) {}
00042     Axis (const dReal v[3]) : osg::Vec4(v[0], v[1], v[2], 0) {}
00043 
00044     osg::Vec3 vec3() const { return osg::Vec3( x(), y(), z()); }
00045 
00046     float enclosingAngle(const Axis& a) const {
00047       return acos((*this * a)/(this->length() * a.length()));
00048     }
00049 
00050     Axis crossProduct(const Axis& a) const {
00051       return Axis(y()*a.z() - z()*a.y(), z()*a.x() - x()*a.z(), x()*a.y() - y()*a.x());
00052     }
00053     
00054     void print(){
00055       std::cout << '(' << x() << ',' << y() << ',' << z() << ')' << std::endl;
00056     }
00057   };
00058   
00059 }
00060 
00061 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3