00001 #ifndef XDKWRL_SFROTATION_H
00002 #define XDKWRL_SFROTATION_H
00003
00004 #include <xdkwrl/fieldtypes.h>
00005 #include <iostream>
00006
00007 namespace wrl
00008 {
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 class SFRotation
00019 {
00020 public:
00021 inline SFRotation();
00022 inline SFRotation(const float x,const float y,const float z,
00023 const float angle);
00024 inline SFRotation& operator=(const SFRotation& r);
00025 inline const float* axis() const;
00026 inline float angle() const;
00027 inline void setAxis(const float x,const float y,const float z);
00028 inline void setAngle(const float);
00029 inline void setAxisAndAngle(const float x,const float y,const float z,
00030 const float a);
00031 inline bool operator==(const SFRotation& r) const;
00032 static inline const char* typeName();
00033 static inline FieldTypeId typeId();
00034 friend std::ostream& operator<<(std::ostream& s,const SFRotation& f);
00035 protected:
00036 private:
00037 float axis_[3];
00038 float angle_;
00039 };
00040
00041
00042
00043 inline
00044 SFRotation::SFRotation()
00045 : angle_(0.0f)
00046 {
00047 axis_[0] = 0.0f;
00048 axis_[1] = 0.0f;
00049 axis_[2] = 1.0f;
00050 }
00051 inline
00052 SFRotation::SFRotation(const float x,const float y,const float z,
00053 const float a)
00054 : angle_(a)
00055 {
00056 axis_[0] = x;
00057 axis_[1] = y;
00058 axis_[2] = z;
00059 }
00060 inline SFRotation&
00061 SFRotation::operator=(const SFRotation& r)
00062 {
00063 axis_[0] = r.axis_[0];
00064 axis_[1] = r.axis_[1];
00065 axis_[2] = r.axis_[2];
00066 angle_ = r.angle_;
00067 return *this;
00068 }
00069 inline const float*
00070 SFRotation::axis() const
00071 {
00072 return axis_;
00073 }
00074 inline float
00075 SFRotation::angle() const
00076 {
00077 return angle_;
00078 }
00079 inline void
00080 SFRotation::setAxis(const float x,const float y,const float z)
00081 {
00082 axis_[0] = x;
00083 axis_[1] = y;
00084 axis_[2] = z;
00085 }
00086 inline void
00087 SFRotation::setAngle(const float a)
00088 {
00089 angle_ = a;
00090 }
00091 inline void
00092 SFRotation::setAxisAndAngle(const float x,const float y,const float z,
00093 const float a)
00094 {
00095 axis_[0] = x;
00096 axis_[1] = y;
00097 axis_[2] = z;
00098 angle_ = a;
00099 }
00100 inline bool
00101 SFRotation::operator==(const SFRotation& r) const
00102 {
00103 return
00104 axis_[0] == r.axis_[0] &&
00105 axis_[1] == r.axis_[1] &&
00106 axis_[2] == r.axis_[2] &&
00107 angle_ == r.angle_;
00108 }
00109 inline const char*
00110 SFRotation::typeName()
00111 {
00112 return "SFRotation";
00113 }
00114 inline FieldTypeId
00115 SFRotation::typeId()
00116 {
00117 return sfRotation;
00118 }
00119 inline std::ostream& operator<<(std::ostream& s,const SFRotation& f)
00120 {
00121 return s<<f.axis_[0]<<' '<<f.axis_[1]<<' '<<f.axis_[2]<<' '<<f.angle_;
00122 }
00123 };
00124
00125 #endif // XDKWRL_SFROTATION_H