Untold Engine  Beta v0.0.16
docs
U4DEngine::U4DVector2n Class Reference

The U4DVector2n class is in charge of implementing a 2D vector representation. The class contains several linear algebra operations such as addition, subtraction, scalar multiplication, dot product, etc. More...

Public Member Functions

 U4DVector2n ()
 Constructor that creates a 2D vector with components equal to zero.
 
 U4DVector2n (float uX, float uY)
 Constructor that creates a 2D vector with given x and y components.
 
 ~U4DVector2n ()
 Destructor of the class.
 
 U4DVector2n (const U4DVector2n &a)
 Copy constructor for the 2D vector class.
 
U4DVector2noperator= (const U4DVector2n &a)
 Copy constructor for the 2D vector class. More...
 
void operator+= (const U4DVector2n &v)
 Method that adds two 2D vectors. More...
 
U4DVector2n operator+ (const U4DVector2n &v) const
 Method that adds two 2D vectors. More...
 
void operator-= (const U4DVector2n &v)
 Method that subtracts two 2D vectors. More...
 
U4DVector2n operator- (const U4DVector2n &v) const
 Method that subtracts two 2D vectors. More...
 
void operator*= (const float s)
 Method that multiplies a 2D vector by a scalar. More...
 
U4DVector2n operator* (const float s) const
 Method that multiplies a 2D vector by a scalar. More...
 
void operator/= (const float s)
 Method that divides a 2D vector by a scalar. More...
 
U4DVector2n operator/ (const float s) const
 Method that divides a 2D vector by a scalar. More...
 
float operator* (const U4DVector2n &v) const
 Method which computes the dot product between two 2D vectors. More...
 
float dot (const U4DVector2n &v) const
 Method which computes the dot product between two 2D vectors. More...
 
void conjugate ()
 Method which conjugates the 2D vector.
 
void normalize ()
 Method which normalized the 2D vector.
 
float magnitude ()
 Method which computes the magnitude (distance) of the 2D vector. More...
 
float squareMagnitude ()
 Method which computes the square magnitude of the 2D vector. More...
 
void zero ()
 Method to set the current 2D vector to a zero-value 2D vector. That is, it sets all its components to zero.
 
void show ()
 Method which prints the components value of the 2D vector to the console log window.
 

Public Attributes

float x
 x-component
 
float y
 y-component
 

Detailed Description

The U4DVector2n class is in charge of implementing a 2D vector representation. The class contains several linear algebra operations such as addition, subtraction, scalar multiplication, dot product, etc.

Member Function Documentation

◆ dot()

float U4DEngine::U4DVector2n::dot ( const U4DVector2n v) const

Method which computes the dot product between two 2D vectors.

Parameters
v2D vector to compute dot product with
Returns
Returns the dot product between two 2D vectors

◆ magnitude()

float U4DEngine::U4DVector2n::magnitude ( )

Method which computes the magnitude (distance) of the 2D vector.

Returns
Returns the magnitude of the 2D vector

◆ operator*() [1/2]

U4DVector2n U4DEngine::U4DVector2n::operator* ( const float  s) const

Method that multiplies a 2D vector by a scalar.

Parameters
sScalar value to multiply
Returns
Returns the product of a 2D vector by a scalar

◆ operator*() [2/2]

float U4DEngine::U4DVector2n::operator* ( const U4DVector2n v) const

Method which computes the dot product between two 2D vectors.

Parameters
v2D vector to compute dot product with
Returns
Returns the dot product between two 2D vectors

◆ operator*=()

void U4DEngine::U4DVector2n::operator*= ( const float  s)

Method that multiplies a 2D vector by a scalar.

Parameters
sScalar value to multiply
Returns
Returns the product of a 2D vector by a scalar

◆ operator+()

U4DVector2n U4DEngine::U4DVector2n::operator+ ( const U4DVector2n v) const

Method that adds two 2D vectors.

Parameters
v2D vector to add
Returns
Returns the addition of two 2D vectors

◆ operator+=()

void U4DEngine::U4DVector2n::operator+= ( const U4DVector2n v)

Method that adds two 2D vectors.

Parameters
v2D vector to add
Returns
Returns the addition of two 2D vectors

◆ operator-()

U4DVector2n U4DEngine::U4DVector2n::operator- ( const U4DVector2n v) const

Method that subtracts two 2D vectors.

Parameters
v2D vector to subract
Returns
Returns the difference between two 2D vectors

◆ operator-=()

void U4DEngine::U4DVector2n::operator-= ( const U4DVector2n v)

Method that subtracts two 2D vectors.

Parameters
v2D vector to subract
Returns
Returns the difference between two 2D vectors

◆ operator/()

U4DVector2n U4DEngine::U4DVector2n::operator/ ( const float  s) const

Method that divides a 2D vector by a scalar.

Parameters
sScalar value to divide
Returns
Returns the division of a 2D vector by a scalar

◆ operator/=()

void U4DEngine::U4DVector2n::operator/= ( const float  s)

Method that divides a 2D vector by a scalar.

Parameters
sScalar value to divide
Returns
Returns the division of a 2D vector by a scalar

◆ operator=()

U4DVector2n & U4DEngine::U4DVector2n::operator= ( const U4DVector2n a)

Copy constructor for the 2D vector class.

Parameters
a2D vector to copy
Returns
Returns a copy of the 2D vector

◆ squareMagnitude()

float U4DEngine::U4DVector2n::squareMagnitude ( )

Method which computes the square magnitude of the 2D vector.

Returns
Returns the square magnitude of the 2D vector. That is, it does not compute the square root of the magnitude