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

FXQuat.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                    Q u a t e r n i o n   F u n c t i o n s                    *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1994,2002 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: FXQuat.h,v 1.11 2002/01/18 22:55:03 jeroen Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FXQUAT_H
00025 #define FXQUAT_H
00026 
00027 
00028 /// Quaternion (single-precision version)
00029 class FXAPI FXQuat : public FXHVec {
00030 public:
00031 
00032   /// Constructors
00033   FXQuat(){}
00034 
00035   /// Construct from axis and angle
00036   FXQuat(const FXVec& axis,FXfloat phi=0.0);
00037 
00038   /// Construct from euler angles yaw (z), pitch (y), and roll (x)
00039   FXQuat(FXfloat roll,FXfloat pitch,FXfloat yaw);
00040 
00041   /// Construct from components
00042   FXQuat(FXfloat x,FXfloat y,FXfloat z,FXfloat w):FXHVec(x,y,z,w){}
00043 
00044   /// Adjust quaternion length
00045   FXQuat& adjust();
00046 
00047   /// Set quaternion from yaw (z), pitch (y), and roll (x)
00048   void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw);
00049 
00050   /// Obtain yaw, pitch, and roll
00051   void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw);
00052 
00053   /// Exponentiate quaternion
00054   friend FXAPI FXQuat exp(const FXQuat& q);
00055 
00056   /// Take logarithm of quaternion
00057   friend FXAPI FXQuat log(const FXQuat& q);
00058 
00059   /// Invert quaternion
00060   friend FXAPI FXQuat invert(const FXQuat& q);
00061 
00062   /// Conjugate quaternion
00063   friend FXAPI FXQuat conj(const FXQuat& q);
00064 
00065   /// Multiply quaternions
00066   friend FXAPI FXQuat operator*(const FXQuat& p,const FXQuat& q);
00067 
00068   /// Construct quaternion from arc a->b on unit sphere
00069   friend FXAPI FXQuat arc(const FXVec& a,const FXVec& b);
00070 
00071   /// Spherical lerp
00072   friend FXAPI FXQuat lerp(const FXQuat& u,const FXQuat& v,FXfloat f);
00073   };
00074 
00075 #endif