All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kanzi::Vector3 Class Reference

Vector with 3 floating point components: (x, y, z). More...

#include <kanzi/math/vector3.hpp>

Public Member Functions

 Vector3 ()
 Default constructor, initializes the vector to (0.0, 0.0, 0.0). More...
 
 Vector3 (float x, float y, float z)
 Constructor, initializes the vector to (x, y, z). More...
 
const float & operator[] (size_t index) const
 Access to individual elements of the vector. More...
 
float & operator[] (size_t index)
 Access to individual elements of the vector. More...
 
Vector3operator*= (float scalar)
 Multiplies each vector element with a scalar. More...
 
Vector3operator/= (float scalar)
 Divides each vector element with a scalar. More...
 
Vector3operator+= (const Vector3 &v)
 Modifies this vector by adding another vector. More...
 
Vector3operator-= (const Vector3 &v)
 Modifies this vector by subtracting another vector from this vector. More...
 
float getX () const
 Returns the x element of the vector. More...
 
float getY () const
 Returns the y element of the vector. More...
 
float getZ () const
 Returns the z element of the vector. More...
 
void setX (float value)
 Sets the x element of the vector. More...
 
void setY (float value)
 Sets the y element of the vector. More...
 
void setZ (float value)
 Sets the z element of the vector. More...
 
float length () const
 Calculates the length a vectors. More...
 
float squaredLength () const
 Calculates the squared length a vectors. More...
 
Vector3 normalized () const
 Normalizes the vector and returns the resulting vector. More...
 
bool isNaN () const
 Returns true if and only if at least one of the vector values is NaN. More...
 

Static Public Member Functions

static Vector3 lowestValue ()
 Returns the vector with each element having the most negative float value. More...
 
static Vector3 highestValue ()
 Returns the vector with each element having the most positive float value. More...
 
static Vector3 nan ()
 Returns the vector with each element being NaN. More...
 
static Vector3 positiveInfinity ()
 Returns the vector with each element being the positive infinity. More...
 
static Vector3 negativeInfinity ()
 Returns the vector with each element being the negative infinity. More...
 
static Vector3 right ()
 Returns the unit vector pointing right. More...
 
static Vector3 up ()
 Returns the unit vector pointing up. More...
 
static Vector3 backward ()
 Returns the unit vector pointing backward. More...
 
static Vector3 left ()
 Returns the unit vector pointing left. More...
 
static Vector3 down ()
 Returns the unit vector pointing down. More...
 
static Vector3 forward ()
 Returns the unit vector pointing forward. More...
 

Detailed Description

Vector with 3 floating point components: (x, y, z).

Constructor & Destructor Documentation

kanzi::Vector3::Vector3 ( )
inlineexplicit

Default constructor, initializes the vector to (0.0, 0.0, 0.0).

kanzi::Vector3::Vector3 ( float  x,
float  y,
float  z 
)
inlineexplicit

Constructor, initializes the vector to (x, y, z).

Parameters
xx component of the vector.
yy component of the vector.
zz component of the vector.

Member Function Documentation

const float& kanzi::Vector3::operator[] ( size_t  index) const
inline

Access to individual elements of the vector.

Parameters
indexIndex of the accessed element. Should be either 0, 1, or 2.
Returns
If index is 0, x element. If index is 1, y element. If index is 2, z element.
float& kanzi::Vector3::operator[] ( size_t  index)
inline

Access to individual elements of the vector.

Parameters
indexIndex of the accessed element. Should be either 0, 1, or 2.
Returns
If index is 0, reference to x element. If index is 1, reference to y element. If index is 2, reference to z element.
Vector3& kanzi::Vector3::operator*= ( float  scalar)
inline

Multiplies each vector element with a scalar.

Parameters
scalarMultiplier for each vector element.
Returns
This vector.
Vector3& kanzi::Vector3::operator/= ( float  scalar)
inline

Divides each vector element with a scalar.

Parameters
scalarDivider for each vector element.
Returns
This vector.
Vector3& kanzi::Vector3::operator+= ( const Vector3 v)
inline

Modifies this vector by adding another vector.

Parameters
vAnother vector.
Returns
This vector.
Vector3& kanzi::Vector3::operator-= ( const Vector3 v)
inline

Modifies this vector by subtracting another vector from this vector.

Parameters
vAnother vector.
Returns
This vector.
float kanzi::Vector3::getX ( ) const
inline

Returns the x element of the vector.

Returns
The x element.
float kanzi::Vector3::getY ( ) const
inline

Returns the y element of the vector.

Returns
The y element.
float kanzi::Vector3::getZ ( ) const
inline

Returns the z element of the vector.

Returns
The z element.
void kanzi::Vector3::setX ( float  value)
inline

Sets the x element of the vector.

Parameters
valueThe new value of the x element.
void kanzi::Vector3::setY ( float  value)
inline

Sets the y element of the vector.

Parameters
valueThe new value of the y element.
void kanzi::Vector3::setZ ( float  value)
inline

Sets the z element of the vector.

Parameters
valueThe new value of the z element.
float kanzi::Vector3::length ( ) const

Calculates the length a vectors.

Returns
sqrt(x*x + y*y + z*z)
float kanzi::Vector3::squaredLength ( ) const
inline

Calculates the squared length a vectors.

Returns
x*x + y*y + z*z
Vector3 kanzi::Vector3::normalized ( ) const
inline

Normalizes the vector and returns the resulting vector.

Returns
The normalized vector.
Vector3 kanzi::Vector3::lowestValue ( )
inlinestatic

Returns the vector with each element having the most negative float value.

Returns
Vector with the lowest possible value.
Vector3 kanzi::Vector3::highestValue ( )
inlinestatic

Returns the vector with each element having the most positive float value.

Returns
Vector with the highest possible value.
Vector3 kanzi::Vector3::nan ( )
inlinestatic

Returns the vector with each element being NaN.

Returns
Vector with NaN elements.
bool kanzi::Vector3::isNaN ( ) const
inline

Returns true if and only if at least one of the vector values is NaN.

Vector3 kanzi::Vector3::positiveInfinity ( )
inlinestatic

Returns the vector with each element being the positive infinity.

Returns
Vector with positive infinity elements.
Vector3 kanzi::Vector3::negativeInfinity ( )
inlinestatic

Returns the vector with each element being the negative infinity.

Returns
Vector with negative infinity elements.
Vector3 kanzi::Vector3::right ( )
inlinestatic

Returns the unit vector pointing right.

Returns
Vector3(1.0f, 0.0f, 0.0f).
Vector3 kanzi::Vector3::up ( )
inlinestatic

Returns the unit vector pointing up.

Returns
Vector3(0.0f, 1.0f, 0.0f).
Vector3 kanzi::Vector3::backward ( )
inlinestatic

Returns the unit vector pointing backward.

Returns
Vector3(0.0f, 0.0f, 1.0f).
Vector3 kanzi::Vector3::left ( )
inlinestatic

Returns the unit vector pointing left.

Returns
Vector3(-1.0f, 0.0f, 0.0f).
Vector3 kanzi::Vector3::down ( )
inlinestatic

Returns the unit vector pointing down.

Returns
Vector3(0.0f, -1.0f, 0.0f).
Vector3 kanzi::Vector3::forward ( )
inlinestatic

Returns the unit vector pointing forward.

Returns
Vector3(0.0f, 0.0f, -1.0f).

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