00001 #ifndef _RBVECTOR3_HXX_
00002 #define _RBVECTOR3_HXX_
00003
00004 #include <RBasicTypes.hxx>
00005 #include <RBase/RString.hxx>
00006
00007 namespace RayGina
00008 {
00009 namespace CORE
00010 {
00011 template<typename T>
00012 class RVec3;
00013
00014 typedef RVec3<RReal> RVec3r;
00015 typedef RVec3<RReal32> RVec3f;
00016 typedef RVec3<RReal64> RVec3d;
00017 typedef RVec3<RInt32> RVec3i;
00018 typedef RVec3<RUInt32> RVec3u;
00019
00020 template<typename T>
00021 inline RVec3<T> operator*(const RVec3<T>& vec, T scalar);
00022
00023 template<typename T>
00024 inline RVec3<T> operator*(T scalar, const RVec3<T>& vec);
00025
00026 template<typename T>
00027 inline RVec3<T> operator+(const RVec3<T>& a, const RVec3<T>& b);
00028
00029 template<typename T>
00030 inline RVec3<T> operator-(const RVec3<T>& a, const RVec3<T>& b);
00031
00032 template<typename T>
00033 inline RVec3<T> operator-(const RVec3<T>& vec);
00034
00036 template<typename T>
00037 std::ostream& operator<<(std::ostream& os, const RVec3<T>& v);
00038
00039 template<typename T>
00040 inline const RString operator+(const RString&, const RVec3<T>& v);
00041
00042 }
00043 }
00044
00045 template<typename T>
00046 class RayGina::CORE::RVec3
00047 {
00048 public:
00049 enum AXIS
00050 {
00051 AXIS_X = 0,
00052 AXIS_Y,
00053 AXIS_Z,
00054 };
00055
00056 inline RVec3();
00057 inline RVec3(T x, T y, T z);
00058
00061
00062
00063 template<typename S> inline RVec3(const RVec3<S>& other);
00064
00065 inline void set(T x, T y, T z);
00066 inline T& at(unsigned int i);
00067 inline const T& at(unsigned int i) const;
00068 inline T& operator[](unsigned int i);
00069 inline const T& operator[](unsigned int i) const;
00070 inline T& x();
00071 inline const T& x() const;
00072 inline T& y();
00073 inline const T& y() const;
00074 inline T& z();
00075 inline const T& z() const;
00076
00077 inline RVec3& reverse();
00078 inline RVec3& zero();
00079 inline T length();
00080 inline RVec3& normalize();
00081
00082 inline static RVec3 cross(const RVec3& a, const RVec3& b);
00083 inline static T dot(const RVec3& a, const RVec3& b);
00084 inline static T spat(const RVec3& a, const RVec3& b, const RVec3& c);
00085 inline static RVec3 projection(const RVec3& a, const RVec3& b);
00086
00087 inline AXIS minDim() const;
00088 inline AXIS maxDim() const;
00089 inline AXIS absMinDim() const;
00090 inline AXIS absMaxDim() const;
00091
00092 inline void operator+=(const RVec3& b);
00093 inline void operator-=(const RVec3& b);
00094 inline void operator*=(T scalar);
00095
00096 inline bool operator==(const RVec3& other);
00097 inline bool operator!=(const RVec3& other);
00098 inline bool equal(const RVec3& vec, T delta);
00099
00100 private:
00101 T m_data[3];
00102 };
00103
00104
00105
00106
00107 #include "RVec3.inl"
00108
00109 #endif