Kanzi 3.9.10
kanzi::Vector3 Class Reference

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

#include <kanzi/core/math/vector3.hpp>

Public Member Functions

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

Static Public Member Functions

static Vector3 highestValue ()
 Returns the vector with each element having the most positive float value.
 
static Vector3 lowestValue ()
 Returns the vector with each element having the most negative float value.
 
static Vector3 nan ()
 Returns the vector with each element being NaN.
 
static Vector3 negativeInfinity ()
 Returns the vector with each element being the negative infinity.
 
static Vector3 negativeX ()
 Returns the unit vector pointing left.
 
static Vector3 negativeY ()
 Returns the unit vector pointing down.
 
static Vector3 negativeZ ()
 Returns the unit vector pointing forward.
 
static KZ_NO_DISCARD const Vector3 one ()
 Returns the vector with each element being one.
 
static Vector3 positiveInfinity ()
 Returns the vector with each element being the positive infinity.
 
static Vector3 positiveX ()
 Returns the unit vector pointing right.
 
static Vector3 positiveY ()
 Returns the unit vector pointing up.
 
static Vector3 positiveZ ()
 Returns the unit vector pointing backward.
 
static KZ_NO_DISCARD const Vector3 zero ()
 Returns the vector with each element being zero.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Vector3() [1/3]

kanzi::Vector3::Vector3 ( )
inlineexplicit

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

◆ Vector3() [2/3]

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.

◆ Vector3() [3/3]

kanzi::Vector3::Vector3 ( float v)
inlineexplicit

Constructor, initializes the vector to (v, v, v).

Parameters
vx, y and z components of the vector.

Member Function Documentation

◆ operator[]() [1/2]

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.

◆ operator[]() [2/2]

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.

◆ operator*=()

Vector3 & kanzi::Vector3::operator*= ( float scalar)
inline

Multiplies each vector element with a scalar.

Parameters
scalarMultiplier for each vector element.
Returns
This vector.

◆ operator/=()

Vector3 & kanzi::Vector3::operator/= ( float scalar)
inline

Divides each vector element with a scalar.

Parameters
scalarDivider for each vector element.
Returns
This vector.

◆ operator+=() [1/2]

Vector3 & kanzi::Vector3::operator+= ( float scalar)
inline

Adds a scalar to each vector element.

Parameters
scalarAddition to each vector element.
Returns
This vector.

◆ operator+=() [2/2]

Vector3 & kanzi::Vector3::operator+= ( const Vector3 & v)
inline

Modifies this vector by adding another vector.

Parameters
vAnother vector.
Returns
This vector.

◆ operator-=()

Vector3 & kanzi::Vector3::operator-= ( const Vector3 & v)
inline

Modifies this vector by subtracting another vector from this vector.

Parameters
vAnother vector.
Returns
This vector.

◆ zero()

static KZ_NO_DISCARD const Vector3 kanzi::Vector3::zero ( )
inlinestatic

Returns the vector with each element being zero.

Returns
Vector with zeroed elements.

◆ one()

static KZ_NO_DISCARD const Vector3 kanzi::Vector3::one ( )
inlinestatic

Returns the vector with each element being one.

Returns
Vector with unit element values.

◆ getX()

float kanzi::Vector3::getX ( ) const
inline

Returns the x element of the vector.

Returns
The x element.

◆ getY()

float kanzi::Vector3::getY ( ) const
inline

Returns the y element of the vector.

Returns
The y element.

◆ getZ()

float kanzi::Vector3::getZ ( ) const
inline

Returns the z element of the vector.

Returns
The z element.

◆ setX()

void kanzi::Vector3::setX ( float value)
inline

Sets the x element of the vector.

Parameters
valueThe new value of the x element.

◆ setY()

void kanzi::Vector3::setY ( float value)
inline

Sets the y element of the vector.

Parameters
valueThe new value of the y element.

◆ setZ()

void kanzi::Vector3::setZ ( float value)
inline

Sets the z element of the vector.

Parameters
valueThe new value of the z element.

◆ minimumAxis()

Vector3 kanzi::Vector3::minimumAxis ( ) const
inline

Returns axis based on the minimum component of Vector3.

Returns
If X component is smallest, (1, 0, 0), else if Y component is smallest, (0, 1, 0), else (0, 0, 1).

◆ maximumAxis()

Vector3 kanzi::Vector3::maximumAxis ( ) const
inline

Returns axis based on the largest component of Vector3.

Returns
If X component is largest, (1, 0, 0), else if Y component is largest, (0, 1, 0), else (0, 0, 1).

◆ length()

float kanzi::Vector3::length ( ) const
inline

Calculates the length a vectors.

Returns
sqrt(x*x + y*y + z*z)

◆ squaredLength()

float kanzi::Vector3::squaredLength ( ) const
inline

Calculates the squared length a vectors.

Returns
x*x + y*y + z*z

◆ normalized()

KZ_NO_DISCARD Vector3 kanzi::Vector3::normalized ( ) const
inline

Normalizes the vector and returns the resulting vector.

Returns
The normalized vector.

◆ lowestValue()

Vector3 kanzi::Vector3::lowestValue ( )
inlinestatic

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

Returns
Vector with the lowest possible value.

◆ highestValue()

Vector3 kanzi::Vector3::highestValue ( )
inlinestatic

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

Returns
Vector with the highest possible value.

◆ nan()

Vector3 kanzi::Vector3::nan ( )
inlinestatic

Returns the vector with each element being NaN.

Returns
Vector with NaN elements.

◆ hasNan()

bool kanzi::Vector3::hasNan ( ) const
inline

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

◆ positiveInfinity()

Vector3 kanzi::Vector3::positiveInfinity ( )
inlinestatic

Returns the vector with each element being the positive infinity.

Returns
Vector with positive infinity elements.

◆ negativeInfinity()

Vector3 kanzi::Vector3::negativeInfinity ( )
inlinestatic

Returns the vector with each element being the negative infinity.

Returns
Vector with negative infinity elements.

◆ positiveX()

Vector3 kanzi::Vector3::positiveX ( )
inlinestatic

Returns the unit vector pointing right.

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

◆ positiveY()

Vector3 kanzi::Vector3::positiveY ( )
inlinestatic

Returns the unit vector pointing up.

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

◆ positiveZ()

Vector3 kanzi::Vector3::positiveZ ( )
inlinestatic

Returns the unit vector pointing backward.

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

◆ negativeX()

Vector3 kanzi::Vector3::negativeX ( )
inlinestatic

Returns the unit vector pointing left.

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

◆ negativeY()

Vector3 kanzi::Vector3::negativeY ( )
inlinestatic

Returns the unit vector pointing down.

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

◆ negativeZ()

Vector3 kanzi::Vector3::negativeZ ( )
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: