Robot Simulator of the Robotics Group for Self-Organization of Control: pos.h Source File

# pos.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 __POS_H
    00025 #define __POS_H
    00026
    00027 #include <iostream>
    00028
    00029 #include <osg/Vec3>
    00030 #include <osg/Vec4>
    00031 #include <ode-dbl/ode.h>
    00032 #include <selforg/position.h>
    00033
    00034 namespace lpzrobots{
    00035
    00036   class Pos : public osg::Vec3 {
    00037   public:
    00038     Pos () : osg::Vec3 () {};
    00039     Pos (float x, float y, float z) : osg::Vec3(x, y, z) {}
    00040     Pos (const osg::Vec3& v) : osg::Vec3(v) {}
    00041     Pos (const osg::Vec4& v) : osg::Vec3(v.x(),v.y(),v.z()) {}
    00042     Pos (const Position& p) : osg::Vec3(p.x, p.y, p.z) {}
    00043     Pos (const dReal v[3]) : osg::Vec3(v[0], v[1], v[2]) {}
    00044
    00045     /// scaling
    00046     Pos operator*(double f) const { return Pos(x()*f,y()*f,z()*f);}
    00047     /// scalar product
    00048     double operator*(const Pos& p) const { return p.x()*x() + p.y()*y() + p.z()*z();}
    00049     /// componentwise  product
    00050     Pos operator&(const Pos& p) const { return Pos(p.x()*x(), p.y()*y(), p.z()*z());}
    00051
    00052     Position toPosition(){
    00053       return Position(x(), y(), z());
    00054     }
    00055
    00056     void print() const {
    00057       std::cout << '(' << x() << ',' << y() << ',' << z() << ')' << std::endl;
    00058     }
    00059   };
    00060
    00061 }
    00062
    00063 #endif