CartesianValues.h

Go to the documentation of this file.
00001 /* ============================================================
00002  *
00003  * This file is a part of RCI project
00004  *
00005  * Copyright (C) 2011 by Arne Nordmann <anordman at cor-lab dot uni-bielefeld dot de>
00006  *
00007  * This file may be licensed under the terms of the
00008  * GNU Lesser General Public License Version 3 (the ``LGPL''),
00009  * or (at your option) any later version.
00010  *
00011  * Software distributed under the License is distributed
00012  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
00013  * express or implied. See the LGPL for the specific language
00014  * governing rights and limitations.
00015  *
00016  * You should have received a copy of the LGPL along with this
00017  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
00018  * or write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  * The development of this software was supported by:
00022  *   CoR-Lab, Research Institute for Cognition and Robotics
00023  *     Bielefeld University
00024  *
00025  * ============================================================ */
00026 
00027 #pragma once
00028 
00029 #include <iostream>
00030 
00031 #include <boost/shared_ptr.hpp>
00032 #include <boost/math/quaternion.hpp>
00033 
00034 #include "cca/dto/DataTransferObject.h"
00035 #include "cca/dto/ContainingDoubles.h"
00036 
00037 namespace rci {
00038 
00039 class CartesianTranslational;
00040 typedef boost::shared_ptr<CartesianTranslational> CartesianTranslationalPtr;
00041 class CartesianRotational;
00042 typedef boost::shared_ptr<CartesianRotational> CartesianRotationalPtr;
00043 class CartesianValue;
00044 typedef boost::shared_ptr<CartesianValue> CartesianValuePtr;
00045 
00051 class CartesianTranslational: public cca::DataTransferObject,
00052         public cca::ContainingDoubles {
00053 
00054 public:
00055     CartesianTranslational();
00056     CartesianTranslational(double valx, double valy, double valz);
00057     CartesianTranslational(const nemo::RealVector& values);
00058     CartesianTranslational(const CartesianTranslational& transl);
00059     CartesianTranslational(const CartesianTranslationalPtr& transl);
00060     virtual ~CartesianTranslational();
00061 
00067     virtual double x() const;
00068 
00073     virtual double y() const;
00074 
00079     virtual double z() const;
00080 
00086     virtual std::string print() const;
00087 };
00088 
00095 class CartesianRotational: public cca::DataTransferObject,
00096         public cca::ContainingDoubles {
00097 
00098 public:
00099     CartesianRotational();
00100     CartesianRotational(double vala, double valb, double valc);
00101     CartesianRotational(double vala, double valb, double valc, double vald);
00102     CartesianRotational(const nemo::RealVector& values);
00103     CartesianRotational(const CartesianRotational& rot);
00104     CartesianRotational(const CartesianRotationalPtr& rot);
00105     CartesianRotational(const ::boost::math::quaternion<double> quaternion);
00106     CartesianRotational(double rxx, double rxy, double rxz, double ryx,
00107             double ryy, double ryz, double rzx, double rzy, double rzz);
00108     ~CartesianRotational();
00109 
00114     virtual double a() const;
00115 
00120     virtual double b() const;
00121 
00126     virtual double c() const;
00127 
00132     virtual double q0() const;
00133 
00138     virtual double q1() const;
00139 
00144     virtual double q2() const;
00145 
00150     virtual double q3() const;
00151 
00152     virtual nemo::RealVector asDoubleVector() const;
00153 
00161     virtual double asDouble(unsigned int index) const;
00162 
00164     virtual void setValue(double value);
00165 
00174     virtual void setValue(unsigned int index, double value);
00175 
00180     virtual ::boost::math::quaternion<double> asQuaternion() const;
00181 
00187     virtual nemo::RealVector asEulerAngles() const;
00188 
00194     virtual nemo::RealVector asAxisAngle() const;
00195 
00201     virtual nemo::RealVector asCompactAxisAngle() const;
00202 
00207     virtual std::string print() const;
00208 
00209 protected:
00210 
00212     static double epsilon() {
00213         return 10e-7;
00214     }
00215 
00224     static double signum(double value) {
00225         if (value > 0)
00226             return 1;
00227         if (value < 0)
00228             return -1;
00229         return 0;
00230     }
00231 
00235     ::boost::math::quaternion<double> _quaternion;
00236 };
00237 
00243 class CartesianValue: public cca::DataTransferObject {
00244 
00245 public:
00246     CartesianTranslational _transl;
00247     CartesianRotational _rot;
00248 
00249     CartesianValue();
00250     CartesianValue(double valx, double valy, double valz, double vala,
00251             double valb, double valc, double vald);
00252     CartesianValue(const nemo::RealVector& values);
00253     CartesianValue(const CartesianValue& val);
00254     CartesianValue(const CartesianTranslationalPtr& transl,
00255             const CartesianRotationalPtr& rot);
00256     virtual ~CartesianValue();
00257 
00266     virtual double asDouble(unsigned int index) const;
00267 
00274     virtual nemo::RealVector asDoubleVector() const;
00275 
00285     virtual void setValue(unsigned int index, double value);
00286 
00292     virtual double x() const;
00293 
00299     virtual double y() const;
00300 
00306     virtual double z() const;
00307 
00313     virtual double a() const;
00314 
00320     virtual double b() const;
00321 
00327     virtual double c() const;
00328 
00334     virtual double q0() const;
00335 
00341     virtual double q1() const;
00342 
00348     virtual double q2() const;
00349 
00355     virtual double q3() const;
00356 
00362     virtual unsigned int getDimension() const;
00363 };
00364 
00365 }
Generated on Thu Aug 2 14:02:49 2012 for RCI by  doxygen 1.6.3