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

FXQuatf.h

00001 /******************************************************************************** 00002 * * 00003 * S i n g 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: FXQuatf.h,v 1.13 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXQUATF_H 00025 #define FXQUATF_H 00026 00027 00028 namespace FX { 00029 00030 00031 class FXMat3f; 00032 00033 00034 /// Single-precision quaternion 00035 class FXAPI FXQuatf : public FXVec4f { 00036 public: 00037 00038 /// Construct 00039 FXQuatf(){} 00040 00041 /// Copy constructor 00042 FXQuatf(const FXQuatf& q):FXVec4f(q){} 00043 00044 /// Construct from components 00045 FXQuatf(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww):FXVec4f(xx,yy,zz,ww){} 00046 00047 /// Construct from array of floats 00048 FXQuatf(const FXfloat v[]):FXVec4f(v){} 00049 00050 /// Construct from axis and angle 00051 FXQuatf(const FXVec3f& axis,FXfloat phi=0.0f); 00052 00053 /// Construct from euler angles yaw (z), pitch (y), and roll (x) 00054 FXQuatf(FXfloat roll,FXfloat pitch,FXfloat yaw); 00055 00056 /// Construct quaternion from axes 00057 FXQuatf(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez); 00058 00059 /// Construct quaternion from 3x3 matrix 00060 FXQuatf(const FXMat3f& mat); 00061 00062 /// Adjust quaternion length 00063 FXQuatf& adjust(); 00064 00065 /// Set quaternion from axis and angle 00066 void setAxisAngle(const FXVec3f& axis,FXfloat phi=0.0f); 00067 00068 /// Obtain axis and angle from quaternion 00069 void getAxisAngle(FXVec3f& axis,FXfloat& phi) const; 00070 00071 /// Set quaternion from yaw (z), pitch (y), and roll (x) 00072 void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw); 00073 00074 /// Obtain yaw, pitch, and roll from quaternion 00075 void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw) const; 00076 00077 /// Set quaternion from axes 00078 void setAxes(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez); 00079 00080 /// Get quaternion axes 00081 void getAxes(FXVec3f& ex,FXVec3f& ey,FXVec3f& ez) const; 00082 00083 /// Obtain local x axis 00084 FXVec3f getXAxis() const; 00085 00086 /// Obtain local y axis 00087 FXVec3f getYAxis() const; 00088 00089 /// Obtain local z axis 00090 FXVec3f getZAxis() const; 00091 00092 /// Exponentiate quaternion 00093 friend FXAPI FXQuatf exp(const FXQuatf& q); 00094 00095 /// Take logarithm of quaternion 00096 friend FXAPI FXQuatf log(const FXQuatf& q); 00097 00098 /// Invert quaternion 00099 friend FXAPI FXQuatf invert(const FXQuatf& q); 00100 00101 /// Invert unit quaternion 00102 friend FXAPI FXQuatf unitinvert(const FXQuatf& q); 00103 00104 /// Conjugate quaternion 00105 friend FXAPI FXQuatf conj(const FXQuatf& q); 00106 00107 /// Multiply quaternions 00108 friend FXAPI FXQuatf operator*(const FXQuatf& p,const FXQuatf& q); 00109 00110 /// Rotation of a vector by a quaternion 00111 friend FXAPI FXVec3f operator*(const FXQuatf& quat,const FXVec3f& vec); 00112 00113 /// Construct quaternion from arc a->b on unit sphere 00114 friend FXAPI FXQuatf arc(const FXVec3f& a,const FXVec3f& b); 00115 00116 /// Spherical lerp 00117 friend FXAPI FXQuatf lerp(const FXQuatf& u,const FXQuatf& v,FXfloat f); 00118 00119 /// Convert quaternion to 3x3 matrix 00120 friend FXAPI FXMat3f toMatrix(const FXQuatf& quat); 00121 00122 /// Convert 3x3 matrix to quaternion 00123 friend FXAPI FXQuatf fromMatrix(const FXMat3f& mat); 00124 }; 00125 00126 00127 00128 } 00129 00130 #endif

Copyright © 1997-2005 Jeroen van der Zijp