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

Copyright © 1997-2004 Jeroen van der Zijp