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,2004 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.3 2004/02/27 18:30:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXQUATD_H 00025 #define FXQUATD_H 00026 00027 00028 namespace FX { 00029 00030 00031 /// double-precision quaternion 00032 class FXAPI FXQuatd : public FXVec4d { 00033 public: 00034 00035 /// Constructors 00036 FXQuatd(){} 00037 00038 /// Copy constructor 00039 FXQuatd(const FXQuatd& q):FXVec4d(q){} 00040 00041 /// Construct from components 00042 FXQuatd(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww):FXVec4d(xx,yy,zz,ww){} 00043 00044 // Construct from array of floats 00045 FXQuatd(const FXdouble v[]):FXVec4d(v){} 00046 00047 /// Construct from axis and angle 00048 FXQuatd(const FXVec3d& axis,FXdouble phi=0.0); 00049 00050 /// Construct from euler angles yaw (z), pitch (y), and roll (x) 00051 FXQuatd(FXdouble roll,FXdouble pitch,FXdouble yaw); 00052 00053 /// Adjust quaternion length 00054 FXQuatd& adjust(); 00055 00056 /// Set quaternion from axis and angle 00057 void setAxisAngle(const FXVec3d& axis,FXdouble phi=0.0); 00058 00059 /// Obtain axis and angle from quaternion 00060 void getAxisAngle(FXVec3d& axis,FXdouble& phi) const; 00061 00062 /// Set quaternion from yaw (z), pitch (y), and roll (x) 00063 void setRollPitchYaw(FXdouble roll,FXdouble pitch,FXdouble yaw); 00064 00065 /// Obtain yaw, pitch, and roll from quaternion 00066 void getRollPitchYaw(FXdouble& roll,FXdouble& pitch,FXdouble& yaw) const; 00067 00068 /// Exponentiate quaternion 00069 friend FXAPI FXQuatd exp(const FXQuatd& q); 00070 00071 /// Take logarithm of quaternion 00072 friend FXAPI FXQuatd log(const FXQuatd& q); 00073 00074 /// Invert quaternion 00075 friend FXAPI FXQuatd invert(const FXQuatd& q); 00076 00077 /// Invert unit quaternion 00078 friend FXAPI FXQuatd unitinvert(const FXQuatd& q); 00079 00080 /// Conjugate quaternion 00081 friend FXAPI FXQuatd conj(const FXQuatd& q); 00082 00083 /// Multiply quaternions 00084 friend FXAPI FXQuatd operator*(const FXQuatd& p,const FXQuatd& q); 00085 00086 // Rotation of a vector by a quaternion 00087 friend FXAPI FXVec3d operator*(const FXQuatd& quat,const FXVec3d& vec); 00088 00089 /// Construct quaternion from arc a->b on unit sphere 00090 friend FXAPI FXQuatd arc(const FXVec3d& a,const FXVec3d& b); 00091 00092 /// Spherical lerp 00093 friend FXAPI FXQuatd lerp(const FXQuatd& u,const FXQuatd& v,FXdouble f); 00094 }; 00095 00096 00097 00098 } 00099 00100 #endif

Copyright © 1997-2004 Jeroen van der Zijp