Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXQuatd.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *              D o u b l e - P r e c i s i o n  Q u a t e r n i o n             *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1994,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library 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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXQuatd.h,v 1.15 2006/01/22 17:58:07 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXQUATD_H
00025 #define FXQUATD_H
00026 
00027 
00028 namespace FX {
00029 
00030 
00031 class FXMat3d;
00032 
00033 
00034 /// Double-precision quaternion
00035 class FXAPI FXQuatd : public FXVec4d {
00036 public:
00037 
00038   /// Constructors
00039   FXQuatd(){}
00040 
00041   /// Copy constructor
00042   FXQuatd(const FXQuatd& q):FXVec4d(q){}
00043 
00044   /// Construct from components
00045   FXQuatd(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww):FXVec4d(xx,yy,zz,ww){}
00046 
00047   /// Construct from array of doubles
00048   FXQuatd(const FXdouble v[]):FXVec4d(v){}
00049 
00050   /// Construct from axis and angle
00051   FXQuatd(const FXVec3d& axis,FXdouble phi=0.0);
00052 
00053   /// Construct from euler angles yaw (z), pitch (y), and roll (x)
00054   FXQuatd(FXdouble roll,FXdouble pitch,FXdouble yaw);
00055 
00056   /// Construct quaternion from two unit vectors
00057   FXQuatd(const FXVec3d& fr,const FXVec3d& to);
00058 
00059   /// Construct quaternion from three axes
00060   FXQuatd(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez);
00061 
00062   /// Construct quaternion from 3x3 matrix
00063   FXQuatd(const FXMat3d& mat);
00064 
00065   /// Adjust quaternion length
00066   FXQuatd& adjust();
00067 
00068   /// Set quaternion from axis and angle
00069   void setAxisAngle(const FXVec3d& axis,FXdouble phi=0.0);
00070 
00071   /// Obtain axis and angle from quaternion
00072   void getAxisAngle(FXVec3d& axis,FXdouble& phi) const;
00073 
00074   /// Set quaternion from roll (x), pitch (y), yaw (z)
00075   void setRollPitchYaw(FXdouble roll,FXdouble pitch,FXdouble yaw);
00076   void getRollPitchYaw(FXdouble& roll,FXdouble& pitch,FXdouble& yaw) const;
00077 
00078   /// Set quaternion from yaw (z), pitch (y), roll (x)
00079   void setYawPitchRoll(FXdouble yaw,FXdouble pitch,FXdouble roll);
00080   void getYawPitchRoll(FXdouble& yaw,FXdouble& pitch,FXdouble& roll) const;
00081 
00082   /// Set quaternion from roll (x), yaw (z), pitch (y)
00083   void setRollYawPitch(FXdouble roll,FXdouble yaw,FXdouble pitch);
00084   void getRollYawPitch(FXdouble& roll,FXdouble& yaw,FXdouble& pitch) const;
00085 
00086   /// Set quaternion from pitch (y), roll (x),yaw (z)
00087   void setPitchRollYaw(FXdouble pitch,FXdouble roll,FXdouble yaw);
00088   void getPitchRollYaw(FXdouble& pitch,FXdouble& roll,FXdouble& yaw) const;
00089 
00090   /// Set quaternion from pitch (y), yaw (z), roll (x)
00091   void setPitchYawRoll(FXdouble pitch,FXdouble yaw,FXdouble roll);
00092   void getPitchYawRoll(FXdouble& pitch,FXdouble& yaw,FXdouble& roll) const;
00093 
00094   /// Set quaternion from yaw (z), roll (x), pitch (y)
00095   void setYawRollPitch(FXdouble yaw,FXdouble roll,FXdouble pitch);
00096   void getYawRollPitch(FXdouble& yaw,FXdouble& roll,FXdouble& pitch) const;
00097 
00098   /// Set quaternion from axes
00099   void setAxes(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez);
00100 
00101   /// Get quaternion axes
00102   void getAxes(FXVec3d& ex,FXVec3d& ey,FXVec3d& ez) const;
00103 
00104   /// Obtain local x axis
00105   FXVec3d getXAxis() const;
00106 
00107   /// Obtain local y axis
00108   FXVec3d getYAxis() const;
00109 
00110   /// Obtain local z axis
00111   FXVec3d getZAxis() const;
00112 
00113   /// Exponentiate quaternion
00114   FXQuatd exp() const;
00115 
00116   /// Take logarithm of quaternion
00117   FXQuatd log() const;
00118 
00119   /// Invert quaternion
00120   FXQuatd invert() const;
00121 
00122   /// Invert unit quaternion
00123   FXQuatd unitinvert() const;
00124 
00125   /// Conjugate quaternion
00126   FXQuatd conj() const;
00127 
00128   /// Construct quaternion from arc a->b on unit sphere
00129   FXQuatd& arc(const FXVec3d& a,const FXVec3d& b);
00130 
00131   /// Spherical lerp
00132   FXQuatd& lerp(const FXQuatd& u,const FXQuatd& v,FXdouble f);
00133 
00134   /// Multiply quaternions
00135   FXQuatd operator*(const FXQuatd& q) const;
00136 
00137   /// Rotation of a vector by a quaternion
00138   FXVec3d operator*(const FXVec3d& v) const;
00139   };
00140 
00141 
00142 }
00143 
00144 #endif

Copyright © 1997-2005 Jeroen van der Zijp