Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::VectorN Class Referencefinal

N-dimensional vector class. More...

#include <VectorN.h>

Public Member Functions

 AZ_TYPE_INFO (VectorN, "{3C5A461A-3412-4D97-9CBC-856EE737B6DB}")
 
 VectorN (AZStd::size_t numElements)
 
 VectorN (AZStd::size_t numElements, float x)
 
 VectorN (const VectorN &v)=default
 
 VectorN (VectorN &&v)
 
VectorNoperator= (VectorN &&)=default
 
VectorNoperator= (const VectorN &)=default
 
AZStd::size_t GetDimensionality () const
 Returns the dimensionality of the vector.
 
void Resize (AZStd::size_t size)
 Changes the dimensionality of the vector.
 
float GetElement (AZStd::size_t index) const
 Returns the value at the requested index.
 
void SetElement (AZStd::size_t index, float value)
 Returns the value at the requested index.
 
bool IsClose (const VectorN &v, float tolerance=0.001f) const
 Checks whether two vectors of equal dimensionality are equal to each other within a floating point tolerance.
 
bool IsZero (float tolerance=AZ::Constants::FloatEpsilon) const
 Checks if the vector is a zero vector, within the provided tolerance for zero.
 
float L1Norm () const
 Returns L1 norm (Manhattan distance) of the vector, full accuracy.
 
float L2Norm () const
 Returns L2 norm (Euclidean distance) of the vector, full accuracy.
 
VectorN GetNormalized () const
 Returns normalized vector, full accuracy.
 
void Normalize ()
 Normalizes the vector in-place, full accuracy.
 
VectorN GetAbs () const
 Returns a new VectorN containing the absolute value of all elements in the source VectorN.
 
void Absolute ()
 Absolute value in-place.
 
VectorN GetSquare () const
 Returns a new VectorN containing the square of all elements in the source VectorN.
 
void Square ()
 Square value in-place.
 
float Dot (const VectorN &rhs) const
 Returns the dot product of two vectors of equal dimension.
 
void SetZero ()
 Quickly zeros all elements of the vector to create a zero vector.
 
VectorNoperator+= (const VectorN &rhs)
 
VectorNoperator-= (const VectorN &rhs)
 
VectorNoperator*= (const VectorN &rhs)
 
VectorNoperator/= (const VectorN &rhs)
 Hadamard product, not dot product.
 
VectorNoperator+= (float sum)
 
VectorNoperator-= (float difference)
 
VectorNoperator*= (float multiplier)
 
VectorNoperator/= (float divisor)
 
VectorN operator- () const
 
VectorN operator+ (const VectorN &rhs) const
 
VectorN operator- (const VectorN &rhs) const
 
VectorN operator* (const VectorN &rhs) const
 
VectorN operator/ (const VectorN &rhs) const
 Hadamard product, not dot product.
 
VectorN operator* (float multiplier) const
 
VectorN operator/ (float divisor) const
 
const AZStd::vector< Vector4 > & GetVectorValues () const
 Returns the raw Vector4's that represent this vector instance.
 
AZStd::vector< Vector4 > & GetVectorValues ()
 
void FixLastVectorElement ()
 Zeros out unused components of the last vector element.
 
bool IsLessThan (const VectorN &v) const
 
bool IsLessEqualThan (const VectorN &v) const
 
bool IsGreaterThan (const VectorN &v) const
 
bool IsGreaterEqualThan (const VectorN &v) const
 
VectorN GetFloor () const
 
VectorN GetCeil () const
 
VectorN GetRound () const
 
VectorN GetMin (const VectorN &v) const
 
VectorN GetMax (const VectorN &v) const
 
VectorN GetClamp (const VectorN &min, const VectorN &max) const
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static VectorN CreateZero (AZStd::size_t numElements)
 Creates a vector with all components set to zero, more efficient than calling VectorN(0.0f).
 
static VectorN CreateOne (AZStd::size_t numElements)
 Creates a vector with all components set to one.
 
static VectorN CreateFromFloats (AZStd::size_t numElements, const float *inputs)
 Creates a vector with all components set to the provided input values.
 
static VectorN CreateRandom (AZStd::size_t numElements)
 Creates a vector with all elements set to random numbers in the range [0, 1).
 

Detailed Description

N-dimensional vector class.

Member Function Documentation

◆ GetFloor()

AZ_MATH_INLINE VectorN AZ::VectorN::GetFloor ( ) const

Floor/Ceil/Round functions, operate on each component individually, result will be stored in output.

◆ GetMin()

AZ_MATH_INLINE VectorN AZ::VectorN::GetMin ( const VectorN v) const

Min/Max functions, operate on each component individually, result will be stored in output.

◆ IsLessThan()

AZ_MATH_INLINE bool AZ::VectorN::IsLessThan ( const VectorN v) const

Comparison functions, not implemented as operators since that would probably be a little dangerous. These functions return true only if all components pass the comparison test.

◆ Reflect()

static void AZ::VectorN::Reflect ( ReflectContext context)
static

AzCore Reflection.

Parameters
contextreflection context

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