Ocular Engine
Ocular::Math::Vector2< T > Class Template Reference

Public Member Functions

 Vector2 (T const *values)
 
 Vector2 (T const &pX, T const &pY)
 
T & operator[] (unsigned const &index)
 
operator[] (unsigned const &index) const
 
Vector2< T > operator- ()
 
Vector2< T > & operator= (Vector2< T > const &rhs)
 
Vector2< T > & operator+= (Vector2< T > const &rhs)
 
Vector2< T > & operator+= (T const &rhs)
 
Vector2< T > & operator-= (Vector2< T > const &rhs)
 
Vector2< T > & operator-= (T const &rhs)
 
Vector2< T > & operator*= (Vector2< T > const &rhs)
 
Vector2< T > & operator*= (T const &rhs)
 
Vector2< T > & operator/= (Vector2< T > const &rhs)
 
Vector2< T > & operator/= (T const &rhs)
 
getMagnitude () const
 
getLength () const
 
void normalize ()
 
Vector2< T > getNormalized () const
 
getDeterminant (Vector2< T > const &rhs)
 
dot (Vector2< T > const &rhs) const
 
double angleBetween (Vector2< T > const &rhs) const
 
double distanceTo (Vector2< T > const &rhs) const
 

Public Attributes

union {
   T   x
 
   T   u
 
   T   s
 
}; 
 
union {
   T   y
 
   T   v
 
   T   t
 
}; 
 

Static Public Attributes

static bool OCULAR_INTERNAL_Force = false
 

Member Function Documentation

template<typename T>
double Ocular::Math::Vector2< T >::angleBetween ( Vector2< T > const &  rhs) const
inline

This is equivalent to taking the acos of the dot product.
The returned angle is the acute angle, i.e the smallest of the two angles.

Parameters
[in]rhsThe second vector to calculate the angle with
Returns
The angle, in radians, between the vectors
template<typename T>
double Ocular::Math::Vector2< T >::distanceTo ( Vector2< T > const &  rhs) const
inline
Parameters
[in]rhsThe second vector to calculate the distance with
Returns
The distance between the two vectors
template<typename T>
T Ocular::Math::Vector2< T >::dot ( Vector2< T > const &  rhs) const
inline

The dot product is a value equal to the magnitudes of the two vectors multiplied together and then multiplied by the cosine of the angle between them.

Parameters
[in]rhsThe second vector dot multiply with
Returns
The dot product of the two vectors (in radians)
template<typename T>
T Ocular::Math::Vector2< T >::getLength ( ) const
inline
Returns
The length of the vector.
template<typename T>
T Ocular::Math::Vector2< T >::getMagnitude ( ) const
inline
Returns
The magnitude (length) of the vector.
template<typename T>
Vector2<T> Ocular::Math::Vector2< T >::getNormalized ( ) const
inline

Returns the normalized form of this vector

template<typename T>
void Ocular::Math::Vector2< T >::normalize ( )
inline

Normalizes the vector. When normalized, a vector maintains its direction but its magnitude is set to 1.0.

Note
This method modifies the internal data stored in the vector. See getNormalized if this is not desired.

The documentation for this class was generated from the following files: