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

FXDQuat.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                Q u a t e r n i o n  D o u b l e -  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: FXDQuat.h,v 1.11 2002/03/12 07:11:30 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXDQUAT_H
00025 #define FXDQUAT_H
00026 
00027 namespace FX {
00028 
00029 /// Quaternion (double-precision version)
00030 class FXAPI FXDQuat : public FXDHVec {
00031 public:
00032 
00033   /// Default constructor
00034   FXDQuat(){}
00035 
00036   /// Construct from axis and angle
00037   FXDQuat(const FXDVec& axis,FXdouble phi=0.0);
00038 
00039   /// Construct from euler angles yaw (z), pitch (y), and roll (x)
00040   FXDQuat(FXdouble roll,FXdouble pitch,FXdouble yaw);
00041 
00042   /// Construct from components
00043   FXDQuat(FXdouble x,FXdouble y,FXdouble z,FXdouble w):FXDHVec(x,y,z,w){}
00044 
00045   /// Adjust quaternion length
00046   FXDQuat& adjust();
00047 
00048   /// Set quaternion from yaw (z), pitch (y), and roll (x)
00049   void setRollPitchYaw(FXdouble roll,FXdouble pitch,FXdouble yaw);
00050 
00051   /// Obtain yaw, pitch, and roll
00052   void getRollPitchYaw(FXdouble& roll,FXdouble& pitch,FXdouble& yaw);
00053 
00054   /// Exponentiate quaternion
00055   friend FXAPI FXDQuat exp(const FXDQuat& q);
00056 
00057   /// Take logarithm of quaternion
00058   friend FXAPI FXDQuat log(const FXDQuat& q);
00059 
00060   /// Invert quaternion
00061   friend FXAPI FXDQuat invert(const FXDQuat& q);
00062 
00063   /// Conjugate quaternion
00064   friend FXAPI FXDQuat conj(const FXDQuat& q);
00065 
00066   /// Multiply quaternions
00067   friend FXAPI FXDQuat operator*(const FXDQuat& p,const FXDQuat& q);
00068 
00069   /// Construct quaternion from arc a->b on unit sphere
00070   friend FXAPI FXDQuat arc(const FXDVec& a,const FXDVec& b);
00071 
00072   /// Spherical lerp
00073   friend FXAPI FXDQuat lerp(const FXDQuat& u,const FXDQuat& v,FXdouble f);
00074   };
00075 
00076 }
00077 
00078 #endif