00001 #ifndef _CTB3vec_HXX
00002 #define _CTB3vec_HXX 1
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016 template <class T>
00017 class CTB3vec {
00018 public:
00019 CTB3vec();
00020 explicit CTB3vec(T rhs);
00021 CTB3vec(T x, T y, T z);
00022 CTB3vec(const CTB3vec<T>& rhs);
00023
00024 T& X();
00025 const T& X() const;
00026
00027 T& Y();
00028 const T& Y() const;
00029
00030 T& Z();
00031 const T& Z() const;
00032
00033 void X(T x);
00034 void Y(T y);
00035 void Z(T z);
00036
00037 T Length() const;
00038 T Dot(const CTB3vec<T>& rhs) const;
00039
00040 CTB3vec<T> Cross(const CTB3vec<T>& rhs) const;
00041
00042 CTB3vec<T> Project(const CTB3vec<T>& x,
00043 const CTB3vec<T>& y,
00044 const CTB3vec<T>& z) const;
00045 CTB3vec<T> UnProject(const CTB3vec<T>& x,
00046 const CTB3vec<T>& y,
00047 const CTB3vec<T>& z) const;
00048
00049 T& operator[](CTBint i_ind);
00050 const T& operator[](CTBint i_ind) const;
00051
00052 operator T*();
00053 operator const T*() const;
00054
00055 CTB3vec<T> operator-() const;
00056
00057 CTB3vec<T>& operator+=(const CTB3vec<T>& rhs);
00058 CTB3vec<T>& operator-=(const CTB3vec<T>& rhs);
00059 CTB3vec<T>& operator*=(T rhs);
00060 CTB3vec<T>& operator/=(T rhs);
00061
00062 CTB3vec<T>& operator=(T rhs);
00063 CTB3vec<T>& operator=(const CTB3vec<T>& rhs);
00064
00065 protected:
00066
00067 T m_data[3];
00068 };
00069
00070 typedef CTB3vec<float> CTB3vec_f;
00071 typedef CTB3vec<double> CTB3vec_d;
00072
00073 template <class T>
00074 CTB3vec<T> operator+(const CTB3vec<T>& lhs, const CTB3vec<T>& rhs);
00075 template <class T>
00076 CTB3vec<T> operator+(const CTB3vec<T>& lhs, T f_rhs);
00077 template <class T>
00078 CTB3vec<T> operator+(T f_lhs, const CTB3vec<T>& rhs);
00079
00080 template <class T>
00081 CTB3vec<T> operator-(const CTB3vec<T>& lhs, const CTB3vec<T>& rhs);
00082 template <class T>
00083 CTB3vec<T> operator-(const CTB3vec<T>& lhs, T f_rhs);
00084 template <class T>
00085 CTB3vec<T> operator-(T f_lhs, const CTB3vec<T>& rhs);
00086
00087 template <class T>
00088 T operator*(const CTB3vec<T>& lhs, const CTB3vec<T>& rhs);
00089 template <class T>
00090 CTB3vec<T> operator*(const CTB3vec<T>& lhs, T f_rhs);
00091 template <class T>
00092 CTB3vec<T> operator*(T f_lhs, const CTB3vec<T>& rhs);
00093
00094 template <class T>
00095 CTB3vec<T> operator/(const CTB3vec<T>& lhs, T f_rhs);
00096
00097 template <class T>
00098 bool operator==(const CTB3vec<T>& lhs, const CTB3vec<T>& rhs);
00099 template <class T>
00100 bool operator==(const CTB3vec<T>& lhs, T f_rhs);
00101 template <class T>
00102 bool operator==(T f_lhs, const CTB3vec<T>& rhs);
00103
00104 template <class T>
00105 ostream& operator<<(ostream& os, const CTB3vec<T>& obj);
00106
00107 template <class T>
00108 T CTBabs(const CTB3vec<T>& vec);
00109
00110
00111 #include "CTB3vec.icc"
00112
00113 #endif