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

Copyright © 1997-2009 Jeroen van der Zijp