00001 // Filename: lquaternion_src.h 00002 // Created by: frang (06Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Class : FLOATNAME(LQuaternion) 00021 // Description : This is the base quaternion class 00022 //////////////////////////////////////////////////////////////////// 00023 class EXPCL_PANDA FLOATNAME(LQuaternion) : public FLOATNAME(LVecBase4) { 00024 PUBLISHED: 00025 INLINE_LINMATH FLOATNAME(LQuaternion)(); 00026 INLINE_LINMATH FLOATNAME(LQuaternion)(const FLOATNAME(LVecBase4) ©); 00027 INLINE_LINMATH FLOATNAME(LQuaternion)(FLOATTYPE, FLOATTYPE, FLOATTYPE, FLOATTYPE); 00028 00029 static FLOATNAME(LQuaternion) pure_imaginary(const FLOATNAME(LVector3) &); 00030 00031 INLINE_LINMATH FLOATNAME(LVecBase3) 00032 xform(const FLOATNAME(LVecBase3) &v) const; 00033 00034 INLINE_LINMATH FLOATNAME(LQuaternion) 00035 multiply(const FLOATNAME(LQuaternion) &rhs) const; 00036 00037 INLINE_LINMATH FLOATNAME(LQuaternion) operator - () const; 00038 00039 INLINE_LINMATH FLOATNAME(LQuaternion) operator *(const FLOATNAME(LQuaternion) &) const; 00040 INLINE_LINMATH FLOATNAME(LQuaternion)& operator *=(const FLOATNAME(LQuaternion) &); 00041 00042 INLINE_LINMATH FLOATNAME(LMatrix3) operator *(const FLOATNAME(LMatrix3) &); 00043 INLINE_LINMATH FLOATNAME(LMatrix4) operator *(const FLOATNAME(LMatrix4) &); 00044 00045 INLINE_LINMATH bool almost_equal(const FLOATNAME(LQuaternion) &, FLOATTYPE) const; 00046 INLINE_LINMATH bool almost_equal(const FLOATNAME(LQuaternion) &) const; 00047 00048 INLINE_LINMATH void output(ostream&) const; 00049 00050 void extract_to_matrix(FLOATNAME(LMatrix3) &m) const; 00051 void extract_to_matrix(FLOATNAME(LMatrix4) &m) const; 00052 00053 void set_from_matrix(const FLOATNAME(LMatrix3) &m); 00054 INLINE_LINMATH void set_from_matrix(const FLOATNAME(LMatrix4) &m); 00055 void set_hpr(const FLOATNAME(LVecBase3) &hpr); 00056 FLOATNAME(LVecBase3) get_hpr() const; 00057 00058 INLINE_LINMATH FLOATNAME(LVector3) get_axis() const; 00059 INLINE_LINMATH FLOATTYPE get_angle() const; 00060 00061 INLINE_LINMATH FLOATTYPE get_r() const; 00062 INLINE_LINMATH FLOATTYPE get_i() const; 00063 INLINE_LINMATH FLOATTYPE get_j() const; 00064 INLINE_LINMATH FLOATTYPE get_k() const; 00065 00066 INLINE_LINMATH void set_r(FLOATTYPE r); 00067 INLINE_LINMATH void set_i(FLOATTYPE i); 00068 INLINE_LINMATH void set_j(FLOATTYPE j); 00069 INLINE_LINMATH void set_k(FLOATTYPE k); 00070 00071 INLINE_LINMATH bool normalize(); 00072 00073 INLINE_LINMATH bool invert_from(const FLOATNAME(LQuaternion) &other); 00074 INLINE_LINMATH bool invert_in_place(); 00075 00076 INLINE_LINMATH bool is_identity() const; 00077 INLINE_LINMATH static const FLOATNAME(LQuaternion) &ident_quat(); 00078 00079 private: 00080 static const FLOATNAME(LQuaternion) _ident_quat; 00081 00082 public: 00083 static TypeHandle get_class_type() { 00084 return _type_handle; 00085 } 00086 static void init_type(); 00087 private: 00088 static TypeHandle _type_handle; 00089 }; 00090 00091 00092 INLINE_LINMATH ostream& operator<<(ostream& os, const FLOATNAME(LQuaternion)& q) { 00093 q.output(os); 00094 return os; 00095 } 00096 00097 INLINE_LINMATH FLOATNAME(LQuaternion) invert(const FLOATNAME(LQuaternion) &a); 00098 00099 BEGIN_PUBLISH 00100 INLINE_LINMATH FLOATNAME(LMatrix3) 00101 operator * (const FLOATNAME(LMatrix3) &m, const FLOATNAME(LQuaternion) &q); 00102 INLINE_LINMATH FLOATNAME(LMatrix4) 00103 operator * (const FLOATNAME(LMatrix4) &m, const FLOATNAME(LQuaternion) &q); 00104 END_PUBLISH 00105 00106 #include "lquaternion_src.I"