![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
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.13 2002/03/12 07:11:30 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXQUAT_H 00025 #define FXQUAT_H 00026 00027 namespace FX { 00028 00029 00030 /// Quaternion (single-precision version) 00031 class FXAPI FXQuat : public FXHVec { 00032 public: 00033 00034 /// Constructors 00035 FXQuat(){} 00036 00037 /// Construct from axis and angle 00038 FXQuat(const FXVec& axis,FXfloat phi=0.0); 00039 00040 /// Construct from euler angles yaw (z), pitch (y), and roll (x) 00041 FXQuat(FXfloat roll,FXfloat pitch,FXfloat yaw); 00042 00043 /// Construct from components 00044 FXQuat(FXfloat x,FXfloat y,FXfloat z,FXfloat w):FXHVec(x,y,z,w){} 00045 00046 /// Adjust quaternion length 00047 FXQuat& adjust(); 00048 00049 /// Set quaternion from yaw (z), pitch (y), and roll (x) 00050 void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw); 00051 00052 /// Obtain yaw, pitch, and roll 00053 void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw); 00054 00055 /// Exponentiate quaternion 00056 friend FXAPI FXQuat exp(const FXQuat& q); 00057 00058 /// Take logarithm of quaternion 00059 friend FXAPI FXQuat log(const FXQuat& q); 00060 00061 /// Invert quaternion 00062 friend FXAPI FXQuat invert(const FXQuat& q); 00063 00064 /// Conjugate quaternion 00065 friend FXAPI FXQuat conj(const FXQuat& q); 00066 00067 /// Multiply quaternions 00068 friend FXAPI FXQuat operator*(const FXQuat& p,const FXQuat& q); 00069 00070 /// Construct quaternion from arc a->b on unit sphere 00071 friend FXAPI FXQuat arc(const FXVec& a,const FXVec& b); 00072 00073 /// Spherical lerp 00074 friend FXAPI FXQuat lerp(const FXQuat& u,const FXQuat& v,FXfloat f); 00075 }; 00076 00077 } 00078 00079 #endif