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

FXQuatf.h

Go to the documentation of this file.
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,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: FXQuatf.h,v 1.17 2006/01/22 17:58:07 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 two unit vectors
00057   FXQuatf(const FXVec3f& fr,const FXVec3f& to);
00058 
00059   /// Construct quaternion from three axes
00060   FXQuatf(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez);
00061 
00062   /// Construct quaternion from 3x3 matrix
00063   FXQuatf(const FXMat3f& mat);
00064 
00065   /// Adjust quaternion length
00066   FXQuatf& adjust();
00067 
00068   /// Set quaternion from axis and angle
00069   void setAxisAngle(const FXVec3f& axis,FXfloat phi=0.0f);
00070 
00071   /// Obtain axis and angle from quaternion
00072   void getAxisAngle(FXVec3f& axis,FXfloat& phi) const;
00073 
00074   /// Set quaternion from roll (x), pitch (y), yaw (z)
00075   void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw);
00076   void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw) const;
00077 
00078   /// Set quaternion from yaw (z), pitch (y), roll (x)
00079   void setYawPitchRoll(FXfloat yaw,FXfloat pitch,FXfloat roll);
00080   void getYawPitchRoll(FXfloat& yaw,FXfloat& pitch,FXfloat& roll) const;
00081 
00082   /// Set quaternion from roll (x), yaw (z), pitch (y)
00083   void setRollYawPitch(FXfloat roll,FXfloat yaw,FXfloat pitch);
00084   void getRollYawPitch(FXfloat& roll,FXfloat& yaw,FXfloat& pitch) const;
00085 
00086   /// Set quaternion from pitch (y), roll (x),yaw (z)
00087   void setPitchRollYaw(FXfloat pitch,FXfloat roll,FXfloat yaw);
00088   void getPitchRollYaw(FXfloat& pitch,FXfloat& roll,FXfloat& yaw) const;
00089 
00090   /// Set quaternion from pitch (y), yaw (z), roll (x)
00091   void setPitchYawRoll(FXfloat pitch,FXfloat yaw,FXfloat roll);
00092   void getPitchYawRoll(FXfloat& pitch,FXfloat& yaw,FXfloat& roll) const;
00093 
00094   /// Set quaternion from yaw (z), roll (x), pitch (y)
00095   void setYawRollPitch(FXfloat yaw,FXfloat roll,FXfloat pitch);
00096   void getYawRollPitch(FXfloat& yaw,FXfloat& roll,FXfloat& pitch) const;
00097 
00098   /// Set quaternion from axes
00099   void setAxes(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez);
00100 
00101   /// Get quaternion axes
00102   void getAxes(FXVec3f& ex,FXVec3f& ey,FXVec3f& ez) const;
00103 
00104   /// Obtain local x axis
00105   FXVec3f getXAxis() const;
00106 
00107   /// Obtain local y axis
00108   FXVec3f getYAxis() const;
00109 
00110   /// Obtain local z axis
00111   FXVec3f getZAxis() const;
00112 
00113   /// Exponentiate quaternion
00114   FXQuatf exp() const;
00115 
00116   /// Take logarithm of quaternion
00117   FXQuatf log() const;
00118 
00119   /// Invert quaternion
00120   FXQuatf invert() const;
00121 
00122   /// Invert unit quaternion
00123   FXQuatf unitinvert() const;
00124 
00125   /// Conjugate quaternion
00126   FXQuatf conj() const;
00127 
00128   /// Construct quaternion from arc a->b on unit sphere
00129   FXQuatf& arc(const FXVec3f& a,const FXVec3f& b);
00130 
00131   /// Spherical lerp
00132   FXQuatf& lerp(const FXQuatf& u,const FXQuatf& v,FXfloat f);
00133 
00134   /// Multiply quaternions
00135   FXQuatf operator*(const FXQuatf& q) const;
00136 
00137   /// Rotation of a vector by a quaternion
00138   FXVec3f operator*(const FXVec3f& v) const;
00139   };
00140 
00141 
00142 }
00143 
00144 #endif

Copyright © 1997-2005 Jeroen van der Zijp