• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/util/header/v3.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 
00004 
00005 template<typename Real = RV_PRECISSION_TYPENAME>
00006 class v3 {
00007 public:
00008         union {
00009                 struct{ Real x,y,z; };
00010                 struct{ Real v[3]; };
00011         };
00012 
00016         v3(){}
00021         v3(const v3& a) : x(a[0]), y(a[1]), z(a[2]) {}
00024         v3(const Real* a) : x(a[0]), y(a[1]), z(a[2]) {}
00027         v3(const Real x, const Real y, const Real z) : x(x), y(y), z(z) {}
00028 
00029         inline v3<Real>& set(const Real x, const Real y, const Real z);
00030         inline v3<Real>& get(Real& x, Real& y, Real& z);
00031 
00032         inline v3<Real>& zero(void);
00033         inline v3<Real>& identity(void);
00034 
00035         inline Real length(void);
00036         inline Real length2(void);
00037 
00038         inline v3<Real>& normalize(void);
00039 
00040         inline v3<Real>& operator = (const v3<Real>& a);
00041         inline v3<Real>& operator += (const v3<Real>& a);
00042         inline v3<Real>& operator -= (const v3<Real>& a);
00043         inline v3<Real>& operator *= (const Real a);
00044         inline v3<Real>& operator /= (const Real a);
00045         inline bool operator == (const v3<Real>& a);
00046         inline bool operator != (const v3<Real>& a);
00047 
00048         inline Real& operator [] (const uchar i);
00049         inline const Real operator [] (const uchar i) const;
00050         inline Real& operator () (const uchar i);
00051         inline const Real operator () (const uchar i) const;
00052 };
00053 
00054 template<typename Real> inline v3<Real> Zero3(void);
00055 template<typename Real> inline v3<Real> Identity3(void);
00056 template<typename Real> inline v3<Real> cross(const v3<Real>& a, const v3<Real>& b);
00057 template<typename Real> inline Real     length(const v3<Real>& a);
00058 template<typename Real> inline Real     length2(const v3<Real>& a);
00059 template<typename Real> inline Real     length(const v3<Real>& from, const v3<Real>& to);
00060 template<typename Real> inline Real     length2(const v3<Real>& from, const v3<Real>& to);
00061 template<typename Real> inline v3<Real> proj(const v3<Real>& a, const v3<Real>& on);
00062 template<typename Real> inline v3<Real> projU(const v3<Real>& a, const v3<Real>& on);
00063 template<typename Real> inline v3<Real> normalize(const v3<Real>& v);
00064 template<typename Real> inline Real     dot(const v3<Real>& a, const v3<Real>& b);
00065 
00066 template<typename Real> inline Real     operator * (const v3<Real>& a, const v3<Real>& b);
00067 template<typename Real> inline v3<Real> operator * (const Real a, const v3<Real>& b);
00068 template<typename Real> inline v3<Real> operator * (const v3<Real>& a, const Real b);
00069 template<typename Real> inline v3<Real> operator / (const Real a, const v3<Real>& b);
00070 template<typename Real> inline v3<Real> operator / (const v3<Real>& a, const Real b);
00071 template<typename Real> inline v3<Real> operator + (const v3<Real>& a, const v3<Real>& b);
00072 template<typename Real> inline v3<Real> operator - (const v3<Real>& a);
00073 template<typename Real> inline v3<Real> operator - (const v3<Real>& a, const v3<Real>& b);
00074 
00075 typedef v3<float> float3;
00076 typedef v3<double> double3;
00077 typedef v3<int> int3;
00078 typedef v3<uint> uint3;
00079 
00086 template<typename Real = RV_PRECISSION_TYPENAME>
00087 class Orientation{
00088 public:
00089         Orientation(){}
00090         Orientation(Real x, Real y, Real z, Real upx, Real upy, Real upz) :
00091                 dir(x,y,z), up(upx, upy, upz){}
00092         v3<Real> dir;
00093         v3<Real> up;
00094 };

Generated on Fri Jun 18 2010 17:48:40 for Cannonball by  doxygen 1.7.0