#ifndef __PolyVox_Vector_H__ #define __PolyVox_Vector_H__ #include #include "boost/cstdint.hpp" #include namespace PolyVox { //template class Matrix; //Forward declaration ///Represents a vector in space. template class Vector : boost::addable< Vector // Vector + Vector , boost::subtractable< Vector // Vector - Vector , boost::dividable2< Vector, Type // Vector / Type , boost::multipliable2< Vector, Type // Vector * Type, Type * Vector , boost::equality_comparable1< Vector // Vector != Vector > > > > > { public: ///Constructor. Vector(Type x, Type y) throw(); ///Constructor. Vector(Type x, Type y, Type z) throw(); ///Constructor. Vector(Type x, Type y, Type z, Type w) throw(); ///Constructor Vector(void) throw(); ///Copy Constructor. Vector(const Vector& vector) throw(); ///Copy Constructor which performs casting. template explicit Vector(const Vector& vector) throw(); ///Destructor. ~Vector(void) throw(); ///Assignment Operator. Vector& operator=(const Vector& rhs) throw(); ///Equality Operator. bool operator==(const Vector& rhs) const throw(); ///Addition and Assignment Operator. Vector& operator+=(const Vector &rhs) throw(); ///Subtraction and Assignment Operator. Vector& operator-=(const Vector &rhs) throw(); ///Multiplication and Assignment Operator. Vector& operator*=(const Type& rhs) throw(); ///Division and Assignment Operator. Vector& operator/=(const Type& rhs) throw(); ///Element Access Type operator()(boost::uint32_t index) const throw(); ///Get the x component of the vector. Type x(void) const throw(); ///Get the y component of the vector. Type y(void) const throw(); ///Get the z component of the vector. Type z(void) const throw(); ///Get the w component of the vector. Type w(void) const throw(); ///Element Access void set(boost::uint32_t index, Type tValue) throw(); ///Set the x component of the vector. void setX(Type tX) throw(); ///Set the y component of the vector. void setY(Type tY) throw(); ///Set the z component of the vector. void setZ(Type tZ) throw(); ///Set the w component of the vector. void setW(Type tW) throw(); ///Get the length of the vector. double length(void) const throw(); ///Get the squared length of the vector. double lengthSquared(void) const throw(); ///Find the angle between this vector and that which is passed as a parameter. double angleTo(const Vector& vector) const throw(); ///Find the cross product between this vector and the vector passed as a parameter. Vector cross(const Vector& vector) const throw(); ///Find the dot product between this vector and the vector passed as a parameter. Type dot(const Vector& rhs) const throw(); ///Normalise the vector. void normalise(void) throw(); private: //Values for the vector Type m_tElements[Size]; }; //Non-member overloaded operators. //!Multiplication operator. //template //Vector operator*(const Vector& lhs, const Matrix& rhs) throw(); //!Multiplication operator. //template //Vector operator*(const Matrix& lhs, const Vector& rhs) throw(); ///Stream insertion operator. template std::ostream& operator<<(std::ostream& os, const Vector& vector) throw(); //Some handy typedefs typedef Vector<2,float> Vector2DFloat; typedef Vector<2,double> Vector2DDouble; typedef Vector<2,boost::int32_t> Vector2DInt32; typedef Vector<2,boost::uint32_t> Vector2DUint32; typedef Vector<3,float> Vector3DFloat; typedef Vector<3,double> Vector3DDouble; typedef Vector<3,boost::int32_t> Vector3DInt32; typedef Vector<3,boost::uint32_t> Vector3DUint32; }//namespace Thermite #include "Vector.inl" #endif