Rotation.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef BASE_ROTATION_H
00025 #define BASE_ROTATION_H
00026 
00027 #include "Vector3D.h"
00028 
00029 namespace Base {
00030 
00031 // forward declarations
00032 class Matrix4D;
00033 
00034 class BaseExport Rotation
00035 {
00036 public:
00039     Rotation();
00040     Rotation(const Vector3d& axis, const double fAngle);
00041     Rotation(const Matrix4D& matrix);
00042     Rotation(const double q[4]);
00043     Rotation(const double q0, const double q1, const double q2, const double q3);
00044     Rotation(const Vector3d& rotateFrom, const Vector3d& rotateTo);
00045     Rotation(const Rotation& rot);
00047 
00050     const double * getValue(void) const;
00051     void getValue(double & q0, double & q1, double & q2, double & q3) const;
00052     void setValue(const double q0, const double q1, const double q2, const double q3);
00053     void getValue(Vector3d & axis, double & rfAngle) const;
00054     void getValue(Matrix4D & matrix) const;
00055     void setValue(const double q[4]);
00056     void setValue(const Matrix4D& matrix);
00057     void setValue(const Vector3d & axis, const double fAngle);
00058     void setValue(const Vector3d & rotateFrom, const Vector3d & rotateTo);
00060     void setYawPitchRoll(double y, double p, double r);
00062     void getYawPitchRoll(double& y, double& p, double& r) const;
00064 
00067     Rotation & invert(void);
00068     Rotation inverse(void) const;
00070 
00073     Rotation & operator*=(const Rotation & q);
00074     Rotation operator *(const Rotation & q) const;
00075     bool operator==(const Rotation & q) const;
00076     bool operator!=(const Rotation & q) const;
00077     double & operator [] (unsigned short usIndex){return quat[usIndex];}
00078     const double & operator [] (unsigned short usIndex) const{return quat[usIndex];}
00079 
00080     void multVec(const Vector3d & src, Vector3d & dst) const;
00081     void scaleAngle(const double scaleFactor);
00083 
00084     static Rotation slerp(const Rotation & rot0, const Rotation & rot1, double t);
00085     static Rotation identity(void);
00086 
00087 private:
00088     void normalize();
00089     double quat[4];
00090 };
00091 
00092 }
00093 
00094 #endif // BASE_ROTATION_H

Generated on Wed Nov 23 19:00:36 2011 for FreeCAD by  doxygen 1.6.1