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

FXQuatd.h

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,2005 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.10 2005/01/16 16:06:06 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 axes 00057 FXQuatd(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez); 00058 00059 /// Construct quaternion from 3x3 matrix 00060 FXQuatd(const FXMat3d& mat); 00061 00062 /// Adjust quaternion length 00063 FXQuatd& adjust(); 00064 00065 /// Set quaternion from axis and angle 00066 void setAxisAngle(const FXVec3d& axis,FXdouble phi=0.0); 00067 00068 /// Obtain axis and angle from quaternion 00069 void getAxisAngle(FXVec3d& axis,FXdouble& phi) const; 00070 00071 /// Set quaternion from yaw (z), pitch (y), and roll (x) 00072 void setRollPitchYaw(FXdouble roll,FXdouble pitch,FXdouble yaw); 00073 00074 /// Obtain yaw, pitch, and roll from quaternion 00075 void getRollPitchYaw(FXdouble& roll,FXdouble& pitch,FXdouble& yaw) const; 00076 00077 /// Set quaternion from axes 00078 void setAxes(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez); 00079 00080 /// Get quaternion axes 00081 void getAxes(FXVec3d& ex,FXVec3d& ey,FXVec3d& ez) const; 00082 00083 /// Obtain local x axis 00084 FXVec3d getXAxis() const; 00085 00086 /// Obtain local y axis 00087 FXVec3d getYAxis() const; 00088 00089 /// Obtain local z axis 00090 FXVec3d getZAxis() const; 00091 00092 /// Exponentiate quaternion 00093 friend FXAPI FXQuatd exp(const FXQuatd& q); 00094 00095 /// Take logarithm of quaternion 00096 friend FXAPI FXQuatd log(const FXQuatd& q); 00097 00098 /// Invert quaternion 00099 friend FXAPI FXQuatd invert(const FXQuatd& q); 00100 00101 /// Invert unit quaternion 00102 friend FXAPI FXQuatd unitinvert(const FXQuatd& q); 00103 00104 /// Conjugate quaternion 00105 friend FXAPI FXQuatd conj(const FXQuatd& q); 00106 00107 /// Multiply quaternions 00108 friend FXAPI FXQuatd operator*(const FXQuatd& p,const FXQuatd& q); 00109 00110 /// Rotation of a vector by a quaternion 00111 friend FXAPI FXVec3d operator*(const FXQuatd& quat,const FXVec3d& vec); 00112 00113 /// Construct quaternion from arc a->b on unit sphere 00114 friend FXAPI FXQuatd arc(const FXVec3d& a,const FXVec3d& b); 00115 00116 /// Spherical lerp 00117 friend FXAPI FXQuatd lerp(const FXQuatd& u,const FXQuatd& v,FXdouble f); 00118 00119 /// Convert quaternion to 3x3 matrix 00120 friend FXAPI FXMat3d toMatrix(const FXQuatd& quat); 00121 00122 /// Convert 3x3 matrix to quaternion 00123 friend FXAPI FXQuatd fromMatrix(const FXMat3d& mat); 00124 }; 00125 00126 00127 00128 } 00129 00130 #endif

Copyright © 1997-2005 Jeroen van der Zijp