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

Copyright © 1997-2009 Jeroen van der Zijp