DubiousEngine
0.2.0
Simple Game Engine
|
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) |
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)
|
default |
Default Constructor.
Creates a Vector of 0 length
|
inline |
Constructor.
Creates the vector with the given X, Y, and Z
x | - [in] X component |
y | - [in] Y component |
z | - [in] Z component |
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
u | - [in] Unit Vector to copy |
float Dubious::Math::VectorT< T >::length | ( | ) | const |
Length.
The length of the vector
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
VectorT< T > & Dubious::Math::VectorT< T >::operator+= | ( | const VectorT< T > & | rhs | ) |
|
inline |
VectorT< T > & Dubious::Math::VectorT< T >::operator-= | ( | const VectorT< T > & | rhs | ) |
|
inline |
X accessor.
|
inline |
Y accessor.
|
inline |
Z accessor.
|
friend |