TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Math::Vector3 Class Reference

#include <tb_vector.hpp>

Public Member Functions

 Vector3 (const SkipInitialization &fastAndStupid)
 
 Vector3 (void)
 
 Vector3 (const float valueX, const float valueY, const float valueZ)
 
 Vector3 (const Vector2 &other, const float valueZ)
 
 Vector3 (const float *componentArray)
 
 Vector3 (const Vector3 &other)
 
 ~Vector3 (void)
 
Vector3operator= (const Vector3 &other)
 
bool operator== (const Vector3 &other) const
 
bool operator!= (const Vector3 &other) const
 
 operator const float * (void) const
 
 operator float * (void)
 
const float & operator[] (const int index) const
 
float & operator[] (const int index)
 

Static Public Member Functions

static Vector3 Zero (void)
 

Public Attributes

union {
   float   mComponents [3]
 
   struct {
      float   x
 
      float   y
 
      float   z
 
   } 
 
}; 
 

Detailed Description

The Vector3 object is a three component mathematical vector of floats packed together with some functionality to perform basic vector math.

Constructor & Destructor Documentation

TurtleBrains::Math::Vector3::Vector3 ( const SkipInitialization fastAndStupid)
inlineexplicit

Constructs a Vector3 object leaving the members uninitialized and must be initialized manually before the object is used.

Note
Should be used only if the consequences are understood, and even then only sparingly.
TurtleBrains::Math::Vector3::Vector3 ( void  )
inline

Constructs a default Vector3 object with all components set to 0.0f.

TurtleBrains::Math::Vector3::Vector3 ( const float  valueX,
const float  valueY,
const float  valueZ 
)
inline

Constructs a Vector3 object with each component initialized with the values provided.

Parameters
valueXThe value to initialize the x component as.
valueYThe value to initialize the y component as.
valueZThe value to initialize the z component as.
TurtleBrains::Math::Vector3::Vector3 ( const Vector2 other,
const float  valueZ 
)
inlineexplicit

Constructs a Vector3 object by copying a Vector2 object and providing a value for the Z component.

Parameters
otherThe Vector2 object to initialize the x and y component values to.
valueZThe value to initialize the z component as.
TurtleBrains::Math::Vector3::Vector3 ( const float *  componentArray)
inlineexplicit

Constructs a Vector3 object with the supplied float array, which must contain at least 3 floats.

Parameters
componentArrayMust have at least 3 floats, one for each component in the Vector3.
TurtleBrains::Math::Vector3::Vector3 ( const Vector3 other)
inline

Constructs a Vector3 object by copying another Vector3 object, each component will be initialized to the value of the other components.

Parameters
otherThe Vector3 object to initialize component values to.
TurtleBrains::Math::Vector3::~Vector3 ( void  )
inline

Nothing needs to happen to destroy a Vector3 object.

Member Function Documentation

TurtleBrains::Math::Vector3::operator const float * ( void  ) const
inlineexplicit

Returns a float array of the Vector3 components.

TurtleBrains::Math::Vector3::operator float * ( void  )
inlineexplicit

Returns a float array of the Vector3 components. If modified the internal components will also be modified as well.

bool TurtleBrains::Math::Vector3::operator!= ( const Vector3 other) const
inline

Inequality operator, returns the opposite of the equality operator, which compares each value in one Vector3 object to another using IsEqual to compare the floating point component values.

Vector3& TurtleBrains::Math::Vector3::operator= ( const Vector3 other)
inline

Assignment operator, sets each component of the Vector3 object to the values of the other object.

Parameters
otherThe Vector3 object to set the components to.
bool TurtleBrains::Math::Vector3::operator== ( const Vector3 other) const
inline

Equality operator, compares each component of the Vector3 object to the values of another Vector3 returning true if all components are equal, or false if any of the components are not equal.

Parameters
otherThe Vector3 object to compare against.
Note
Because the components are floating point values tbMath::IsEqual is used to compare the components for equality using the default tolerance: kTolerance.
const float& TurtleBrains::Math::Vector3::operator[] ( const int  index) const
inline

Returns a reference to one of the Vector3 components by an index provided by the VectorComponent enum.

float& TurtleBrains::Math::Vector3::operator[] ( const int  index)
inline

Returns a reference to one of the Vector3 components by an index provided by the VectorComponent enum. If the reference returned is modified, the internal components will also be modified as well.

static Vector3 TurtleBrains::Math::Vector3::Zero ( void  )
inlinestatic

Creates and returns a Vector3 object representing 0.0f, 0.0f, 0.0f.