AxisAngle4.hpp

Go to the documentation of this file.
00001 /*
00002    Copyright (C) 1997,1998,1999
00003    Kenji Hiranabe, Eiwa System Management, Inc.
00004 
00005    This program is free software.
00006    Implemented by Kenji Hiranabe(hiranabe@esm.co.jp),
00007    conforming to the Java(TM) 3D API specification by Sun Microsystems.
00008 
00009    Permission to use, copy, modify, distribute and sell this software
00010    and its documentation for any purpose is hereby granted without fee,
00011    provided that the above copyright notice appear in all copies and
00012    that both that copyright notice and this permission notice appear
00013    in supporting documentation. Kenji Hiranabe and Eiwa System Management,Inc.
00014    makes no representations about the suitability of this software for any
00015    purpose.  It is provided "AS IS" with NO WARRANTY.
00016 
00017    Copyright (C) 2006
00018    Rune Myrland, Skalden Studio AS
00019    SagaEngine adaptions, involving conversion from floating point values to fixed point values.
00020    Kenji Hiranabe's license apply.
00021 */
00022 #ifndef util_vecmath_AxisAngle4_hpp
00023 #define util_vecmath_AxisAngle4_hpp
00024 
00025 #include "util_vecmath.hpp"
00026 #include "Vector3.hpp"
00027 #include "../math/CoorT.hpp"
00028 #include "../math/BrayT.hpp"
00029 
00030 namespace se_core {
00031 
00039     class _SeCoreExport AxisAngle4 {
00040         /*
00041          * I assumed that the length of axis vectors is not significant.
00042          */
00043     public:
00047         typedef coor_t value_type;
00048 
00052         coor_t x_;
00053 
00057         coor_t y_;
00058 
00062         coor_t z_;
00063 
00067         bray_t angle_;
00068 
00077         AxisAngle4(coor_t xvalue, coor_t yvalue, coor_t zvalue, bray_t anglevalue):
00078             x_(xvalue), y_(yvalue), z_(zvalue), angle_(anglevalue) { }
00079 
00083         AxisAngle4() { }
00084 
00093         AxisAngle4(const Vector3& axis, bray_t ang):
00094             x_(axis.x_), y_(axis.y_), z_(axis.z_), angle_(ang) { }
00095 
00096         AxisAngle4(const coor_t len, const Euler3& a1) {
00097             set(len, a1);
00098         }
00099 
00100 
00101         void setIdentity() {
00102             x_ = y_ = 0;
00103             z_ = -1;
00104             angle_ = 0;
00105         }
00106 
00114         void set(const Vector3& axis, bray_t ang) {
00115             x_ = axis.x_;
00116             y_ = axis.y_;
00117             z_ = axis.z_;
00118             angle_ = ang;
00119         }
00120 
00128         void set(coor_t x, coor_t y, coor_t z, bray_t angle) {
00129             this->x_ = x;
00130             this->y_ = y;
00131             this->z_ = z_;
00132             this->angle_ = angle;
00133         }
00134 
00139         void set(const AxisAngle4& a1) {
00140             x_ = a1.x_;
00141             y_ = a1.y_;
00142             z_ = a1.z_;
00143             angle_ = a1.angle_;
00144         }
00145 
00146 
00152         void set(const Quat4& q1);
00153 
00154 
00155         void set(const coor_t len, const bray_t yaw);
00156         void set(const coor_t len, const bray_t yaw, const bray_t pitch);
00157         void set(const coor_t len, const Euler3& a1);
00158 
00159         // helper method
00160     protected:
00161         void setFromQuat(coor_t x, coor_t y, coor_t z, coor_t w);
00162 
00163     public:
00169         bool equals(const AxisAngle4& a1) const {
00170             return x_ == a1.x_ && y_ == a1.y_ && z_ == a1.z_ && angle_ == a1.angle_;
00171         }
00172 
00180         bool epsilonEquals(const AxisAngle4& a1, coor_t epsilon, bray_t epsilonAngle = 1) const {
00181             return (CoorT::abs(a1.x_ - x_) <= epsilon) &&
00182                 (CoorT::abs(a1.y_ - y_) <= epsilon) &&
00183                 (CoorT::abs(a1.z_ - z_) <= epsilon) &&
00184                 (BrayT::abs(a1.angle_ - angle_) <= epsilonAngle);
00185         }
00186 
00187         // copy constructor and operator = is made by complier
00188 
00189         bool operator==(const AxisAngle4& m1) const {
00190             return equals(m1);
00191         }
00192 
00193         const char* toLog() const;
00194     };
00195     
00196 }
00197 
00198 #endif

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:13 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo