DubiousEngine  0.2.0
Simple Game Engine
Dubious::Math::VectorT< T > Class Template Reference

A 3D Vector. More...

#include <Unit_vector.h>

Public Member Functions

 VectorT ()=default
 Default Constructor. More...
 
 VectorT (float x, float y, float z)
 Constructor. More...
 
 VectorT (const Unit_vectorT< T > &u)
 Construct from Unit Vector. More...
 
float length_squared () const
 Length Squared. More...
 
float length () const
 Length. More...
 
float x () const
 X accessor. More...
 
float y () const
 Y accessor. More...
 
float z () const
 Z accessor. More...
 
VectorT< T > operator- () const
 
VectorT< T > & operator+= (const VectorT< T > &rhs)
 
VectorT< T > & operator-= (const VectorT< T > &rhs)
 

Friends

bool operator== (const VectorT< T > &a, const VectorT< T > &b)
 
bool operator!= (const VectorT< T > &a, const VectorT< T > &b)
 
VectorT< T > operator+ (const VectorT< T > &a, const VectorT< T > &b)
 
VectorT< T > operator- (const VectorT< T > &a, const VectorT< T > &b)
 
VectorT< T > operator* (const VectorT< T > &a, float b)
 
VectorT< T > operator* (float a, const VectorT< T > &b)
 
VectorT< T > operator/ (const VectorT< T > &a, float b)
 
std::ostream & operator<< (std::ostream &o, const VectorT< T > &a)
 

Detailed Description

template<int T>
class Dubious::Math::VectorT< T >

A 3D Vector.

This class represents a 3D vector. This is for non-unit vectors. The template parameter is only so the compiler can enforce different meanings for Vectors (ie local versus global)

Constructor & Destructor Documentation

template<int T>
Dubious::Math::VectorT< T >::VectorT ( )
default

Default Constructor.

Creates a Vector of 0 length

template<int T>
Dubious::Math::VectorT< T >::VectorT ( float  x,
float  y,
float  z 
)
inline

Constructor.

Creates the vector with the given X, Y, and Z

Parameters
x- [in] X component
y- [in] Y component
z- [in] Z component
template<int T>
Dubious::Math::VectorT< T >::VectorT ( const Unit_vectorT< T > &  u)

Construct from Unit Vector.

A simple construction from a Unit Vector. Note that the template parameter must match, so Local Vectors can be constructed from Local Unit Vectors, but not Global Unit Vectors

Parameters
u- [in] Unit Vector to copy

Member Function Documentation

template<int T>
float Dubious::Math::VectorT< T >::length ( ) const

Length.

The length of the vector

Returns
The Vector length
template<int T>
float Dubious::Math::VectorT< T >::length_squared ( ) const

Length Squared.

Often we don't need the actual length, but we may need to compare the relative lengths of 2 vectors. The length squared is a good way to do that as it doesn't require the costly sqrt function

Returns
The length of the vector squared
template<int T>
VectorT< T > & Dubious::Math::VectorT< T >::operator+= ( const VectorT< T > &  rhs)
template<int T>
VectorT<T> Dubious::Math::VectorT< T >::operator- ( ) const
inline
template<int T>
VectorT< T > & Dubious::Math::VectorT< T >::operator-= ( const VectorT< T > &  rhs)
template<int T>
float Dubious::Math::VectorT< T >::x ( ) const
inline

X accessor.

Returns
X coordinate
template<int T>
float Dubious::Math::VectorT< T >::y ( ) const
inline

Y accessor.

Returns
Y coordinate
template<int T>
float Dubious::Math::VectorT< T >::z ( ) const
inline

Z accessor.

Returns
Z coordinate

Friends And Related Function Documentation

template<int T>
bool operator!= ( const VectorT< T > &  a,
const VectorT< T > &  b 
)
friend
template<int T>
VectorT<T> operator* ( const VectorT< T > &  a,
float  b 
)
friend
template<int T>
VectorT<T> operator* ( float  a,
const VectorT< T > &  b 
)
friend
template<int T>
VectorT<T> operator+ ( const VectorT< T > &  a,
const VectorT< T > &  b 
)
friend
template<int T>
VectorT<T> operator- ( const VectorT< T > &  a,
const VectorT< T > &  b 
)
friend
template<int T>
VectorT<T> operator/ ( const VectorT< T > &  a,
float  b 
)
friend
template<int T>
std::ostream& operator<< ( std::ostream &  o,
const VectorT< T > &  a 
)
friend
template<int T>
bool operator== ( const VectorT< T > &  a,
const VectorT< T > &  b 
)
friend

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