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

A 3D Unit Vector. More...

#include <Unit_quaternion.h>

Public Member Functions

 Unit_vectorT ()=default
 Constructor. More...
 
 Unit_vectorT (float x, float y, float z)
 Constructor. More...
 
 Unit_vectorT (const VectorT< T > &v)
 Constructor. More...
 
float x () const
 X accessor. More...
 
float y () const
 Y accessor. More...
 
float z () const
 Z accessor. More...
 
Unit_vectorT< T > operator- () const
 

Friends

bool operator== (const Unit_vectorT< T > &a, const Unit_vectorT< T > &b)
 
bool operator!= (const Unit_vectorT< T > &a, const Unit_vectorT< T > &b)
 
VectorT< T > operator* (const Unit_vectorT< T > &a, float b)
 
VectorT< T > operator* (float a, const Unit_vectorT< T > &b)
 
VectorT< T > operator+ (const Unit_vectorT< T > &a, const Unit_vectorT< T > &b)
 
VectorT< T > operator- (const Unit_vectorT< T > &a, const Unit_vectorT< T > &b)
 

Detailed Description

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

A 3D Unit Vector.

This class represents a 3D Unit Vector. The template parameter is only so the compiler can enforce different meanings for Unit Vectors (ie local versus global)

Constructor & Destructor Documentation

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

Constructor.

This is primarily an optimization. In some cases you need to create an empty UnitVector so that you can assign it or pass it as an out parameter to something. In this case you don't really care what value it holds. Creating one with dummy args causes a painful normalization. So this function will create one as 1,0,0 and not call normalization

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

Constructor.

Creates the unit vector with the given X, Y, and Z converted to a length of 1

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

Constructor.

Creates a Unit Vector from the passed in Vector. This serves as a Normalize function

Parameters
v- [in] Vector to copy

Member Function Documentation

template<int T>
Unit_vectorT<T> Dubious::Math::Unit_vectorT< T >::operator- ( ) const
inline
template<int T>
float Dubious::Math::Unit_vectorT< T >::x ( ) const
inline

X accessor.

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

Y accessor.

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

Z accessor.

Returns
Z coordinate

Friends And Related Function Documentation

template<int T>
bool operator!= ( const Unit_vectorT< T > &  a,
const Unit_vectorT< T > &  b 
)
friend
template<int T>
VectorT<T> operator* ( const Unit_vectorT< T > &  a,
float  b 
)
friend
template<int T>
VectorT<T> operator* ( float  a,
const Unit_vectorT< T > &  b 
)
friend
template<int T>
VectorT<T> operator+ ( const Unit_vectorT< T > &  a,
const Unit_vectorT< T > &  b 
)
friend
template<int T>
VectorT<T> operator- ( const Unit_vectorT< T > &  a,
const Unit_vectorT< T > &  b 
)
friend
template<int T>
bool operator== ( const Unit_vectorT< T > &  a,
const Unit_vectorT< T > &  b 
)
friend

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