Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::Vector3 Class Reference

3D vector class. More...

#include <aeongames/Vector3.hpp>

Collaboration diagram for AeonGames::Vector3:
Collaboration graph

Public Member Functions

DLL Vector3 ()
 Default constructor.
DLL Vector3 (const float *const aVector)
 Constructor.
DLL Vector3 (const void *const aVector, const uint32_t aStride)
 Constructor from raw memory with stride.
DLL Vector3 (float aX, float aY, float aZ)
 Constructor.
DLL void Get (float *aData) const
 Copy vector data to an external float array.
DLL const float *const GetVector3 () const
 Get a pointer to the internal vector data.
DLL const float & GetX () const
 Get the X component.
DLL const float & GetY () const
 Get the Y component.
DLL const float & GetZ () const
 Get the Z component.
DLL void SetVector3 (const float *const aVector)
 Set the vector from a float array.
DLL void SetVector3 (const void *const aVector, const uint32_t aStride)
 Set the vector from raw memory with stride.
DLL float GetLenghtSquared () const
 Get the squared length of the vector.
DLL float GetLenght () const
 Get the length of the vector.
DLL size_t GetMaxAxisIndex () const
 Get the index of the axis with the largest absolute value.
DLL size_t GetMinAxisIndex () const
 Get the index of the axis with the smallest absolute value.
DLL float GetMaxAxisLenght () const
 Get the absolute value of the largest axis component.
DLL float GetMinAxisLenght () const
 Get the absolute value of the smallest axis component.
DLL float GetDistanceToPlane (const Plane &aPlane) const
 Get the signed distance from this point to a plane.
DLL bool IsZero () const
 Check whether all components are zero.

Operators

float mVector [3]
 X,Y,Z.
DLL Vector3operator= (const float *aLhs)
 Assign from a raw float array.
DLL Vector3operator-= (const Vector3 &aLhs)
 Subtract a vector from this vector.
DLL Vector3operator+= (const Vector3 &aLhs)
 Add a vector to this vector.
DLL Vector3operator*= (const float aLhs)
 Scale this vector by a scalar.
DLL Vector3operator*= (const Vector3 &aLhs)
 Component-wise multiply by another vector.
DLL Vector3operator/= (const float aLhs)
 Divide this vector by a scalar.
DLL float operator[] (const size_t aIndex) const
 Access a component by index (const).
DLL float & operator[] (const size_t aIndex)
 Access a component by index.

Detailed Description

3D vector class.

Definition at line 31 of file Vector3.hpp.

Constructor & Destructor Documentation

◆ Vector3() [1/4]

AeonGames::Vector3::Vector3 ( )

Default constructor.

Definition at line 22 of file Vector3.cpp.

◆ Vector3() [2/4]

AeonGames::Vector3::Vector3 ( const float *const aVector)

Constructor.

Parameters
aVectora float pointer or array containing vector data.
Note
This is the same format the values are internally stored and what Vector3::GetVector3 returns.

Definition at line 27 of file Vector3.cpp.

◆ Vector3() [3/4]

AeonGames::Vector3::Vector3 ( const void *const aVector,
const uint32_t aStride )

Constructor from raw memory with stride.

Parameters
aVectorPointer to raw memory containing vector data.
aStrideByte stride between consecutive float components.

Definition at line 37 of file Vector3.cpp.

◆ Vector3() [4/4]

AeonGames::Vector3::Vector3 ( float aX,
float aY,
float aZ )

Constructor.

Parameters
aXX component.
aYY component.
aZZ component.

Definition at line 90 of file Vector3.cpp.

Member Function Documentation

◆ Get()

void AeonGames::Vector3::Get ( float * aData) const

Copy vector data to an external float array.

Parameters
[out]aDataPointer to a float array of at least 3 elements.

Definition at line 97 of file Vector3.cpp.

◆ GetDistanceToPlane()

float AeonGames::Vector3::GetDistanceToPlane ( const Plane & aPlane) const

Get the signed distance from this point to a plane.

Parameters
aPlaneThe plane to measure distance to.
Returns
Signed distance to the plane.

Definition at line 85 of file Vector3.cpp.

◆ GetLenght()

float AeonGames::Vector3::GetLenght ( ) const

Get the length of the vector.

Returns
Magnitude of the vector.

Definition at line 54 of file Vector3.cpp.

◆ GetLenghtSquared()

float AeonGames::Vector3::GetLenghtSquared ( ) const

Get the squared length of the vector.

Returns
Squared magnitude of the vector.

Definition at line 49 of file Vector3.cpp.

◆ GetMaxAxisIndex()

size_t AeonGames::Vector3::GetMaxAxisIndex ( ) const

Get the index of the axis with the largest absolute value.

Returns
Index (0=X, 1=Y, 2=Z) of the largest axis.

Definition at line 59 of file Vector3.cpp.

◆ GetMaxAxisLenght()

float AeonGames::Vector3::GetMaxAxisLenght ( ) const

Get the absolute value of the largest axis component.

Returns
Absolute value of the largest component.

Definition at line 75 of file Vector3.cpp.

◆ GetMinAxisIndex()

size_t AeonGames::Vector3::GetMinAxisIndex ( ) const

Get the index of the axis with the smallest absolute value.

Returns
Index (0=X, 1=Y, 2=Z) of the smallest axis.

Definition at line 67 of file Vector3.cpp.

◆ GetMinAxisLenght()

float AeonGames::Vector3::GetMinAxisLenght ( ) const

Get the absolute value of the smallest axis component.

Returns
Absolute value of the smallest component.

Definition at line 80 of file Vector3.cpp.

◆ GetVector3()

const float *const AeonGames::Vector3::GetVector3 ( ) const

Get a pointer to the internal vector data.

Returns
Pointer to the float array containing X,Y,Z components.

Definition at line 102 of file Vector3.cpp.

◆ GetX()

const float & AeonGames::Vector3::GetX ( ) const

Get the X component.

Returns
Reference to the X component.

Definition at line 107 of file Vector3.cpp.

◆ GetY()

const float & AeonGames::Vector3::GetY ( ) const

Get the Y component.

Returns
Reference to the Y component.

Definition at line 112 of file Vector3.cpp.

◆ GetZ()

const float & AeonGames::Vector3::GetZ ( ) const

Get the Z component.

Returns
Reference to the Z component.

Definition at line 118 of file Vector3.cpp.

◆ IsZero()

bool AeonGames::Vector3::IsZero ( ) const

Check whether all components are zero.

Returns
true if the vector is the zero vector.

Definition at line 205 of file Vector3.cpp.

◆ operator*=() [1/2]

Vector3 & AeonGames::Vector3::operator*= ( const float aLhs)

Scale this vector by a scalar.

Definition at line 181 of file Vector3.cpp.

◆ operator*=() [2/2]

Vector3 & AeonGames::Vector3::operator*= ( const Vector3 & aLhs)

Component-wise multiply by another vector.

Definition at line 189 of file Vector3.cpp.

◆ operator+=()

Vector3 & AeonGames::Vector3::operator+= ( const Vector3 & aLhs)

Add a vector to this vector.

Definition at line 166 of file Vector3.cpp.

◆ operator-=()

Vector3 & AeonGames::Vector3::operator-= ( const Vector3 & aLhs)

Subtract a vector from this vector.

Definition at line 149 of file Vector3.cpp.

◆ operator/=()

Vector3 & AeonGames::Vector3::operator/= ( const float aLhs)

Divide this vector by a scalar.

Definition at line 197 of file Vector3.cpp.

◆ operator=()

Vector3 & AeonGames::Vector3::operator= ( const float * aLhs)

Assign from a raw float array.

Definition at line 143 of file Vector3.cpp.

◆ operator[]() [1/2]

float & AeonGames::Vector3::operator[] ( const size_t aIndex)

Access a component by index.

Definition at line 137 of file Vector3.cpp.

◆ operator[]() [2/2]

float AeonGames::Vector3::operator[] ( const size_t aIndex) const

Access a component by index (const).

Definition at line 131 of file Vector3.cpp.

◆ SetVector3() [1/2]

void AeonGames::Vector3::SetVector3 ( const float *const aVector)

Set the vector from a float array.

Parameters
aVectorPointer to a float array containing X,Y,Z values.

Definition at line 32 of file Vector3.cpp.

◆ SetVector3() [2/2]

void AeonGames::Vector3::SetVector3 ( const void *const aVector,
const uint32_t aStride )

Set the vector from raw memory with stride.

Parameters
aVectorPointer to raw memory containing vector data.
aStrideByte stride between consecutive float components.

Definition at line 42 of file Vector3.cpp.

Member Data Documentation

◆ mVector

float AeonGames::Vector3::mVector[3]
protected

X,Y,Z.

Definition at line 135 of file Vector3.hpp.


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