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

src/util/header/v4.h

Go to the documentation of this file.
00001 
00005 template<typename Real = RV_PRECISSION_TYPENAME>
00006 class v4 {
00007 public:
00008         union {
00009                 struct{ Real x,y,z,w; };
00010                 struct{ Real v[4]; };
00011         };
00012 
00015         v4(){}
00016 
00021         v4(const v4<Real>& vec) {VecOpVec(v, =, vec, 4);}
00022 
00025         v4(const Real x, const Real y, const Real z, const Real w = 1.0f) : x(x), y(y), z(z), w(w) {}
00026 
00029         v4(const v3<Real>& v, const Real w = 1.0f) : x(v.x), y(v.y), z(v.z), w(w) {}
00030 
00031         inline v4<Real>& set(const Real x, const Real y, const Real z, const Real w);
00032         inline v4<Real>& get(Real& x, Real& y, Real& z, Real& w);
00033 
00034         inline v4<Real>& zero(void);
00035         inline v4<Real>& identity(void);
00036         inline Real modulus(void);
00037         inline Real modulus2(void);
00038         inline v4<Real>& normalize(void);
00039 
00040         inline v4<Real>& operator = (const v4<Real>& vec);
00041         inline v4<Real>& operator += (const v4<Real>& vec);
00042         inline v4<Real>& operator -= (const v4<Real>& vec);
00043         inline v4<Real>& operator *= (const Real f);
00044         inline v4<Real>& operator /= (const Real f);
00045         inline bool operator == (const v4<Real>& vec);
00046         inline bool operator != (const v4<Real>& vec);
00047 
00048         inline Real& operator [] (const unsigned char i);
00049         inline const Real operator [] (const unsigned char i) const;
00050         inline Real& operator () (const unsigned char i);
00051         inline const Real operator () (const unsigned char i) const;
00052 };
00053 
00054 template<typename Real> inline v4<Real> Zero4(void);
00055 template<typename Real> inline v4<Real> Identity4(void);
00056 template<typename Real> inline Real modulus(const v4<Real>& v);
00057 template<typename Real> inline Real modulus2(const v4<Real>& v);
00058 template<typename Real> inline Real dot(const v4<Real>& a, const v4<Real>& b);
00059 template<typename Real> inline v4<Real> cross(const v4<Real>& a, const v4<Real>& b, const v4<Real>& c);
00060 template<typename Real> inline v4<Real> normalize(const v4<Real>& v);
00061 
00062 template<typename Real> inline v4<Real> operator + (const v4<Real>& a, const v4<Real>& b);
00063 template<typename Real> inline v4<Real> operator - (const v4<Real>& a, const v4<Real>& b);
00064 template<typename Real> inline Real operator * (const v4<Real>& a, const v4<Real>& b);
00065 template<typename Real> inline v4<Real> operator * (Real f, const v4<Real>& v);
00066 template<typename Real> inline v4<Real> operator * (const v4<Real>& v, Real f);
00067 template<typename Real> inline v4<Real> operator / (Real f, const v4<Real>& v);
00068 template<typename Real> inline v4<Real> operator / (const v4<Real>& v, Real f);
00069 template<typename Real> inline v4<Real> operator - (const v4<Real>& v);
00070 
00071 typedef v4<float> float4;
00072 typedef v4<double> double4;
00073 typedef v4<int> int4;
00074 typedef v4<uint> uint4;

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