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