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

The U4DVector3n class is in charge of implementing 3D Linear Algebra Vector operations. These operations include: Addition, subtraction, scalar multiplication, dot product, cross product, among others. More...

Public Member Functions

 U4DVector3n ()
 Constructor which creates a default 3D vector. That is, it creates a vector with x, y and z components equal to zero.
 
 U4DVector3n (float nx, float ny, float nz)
 Constructor which creates a 3D vector with x,y, and z components. More...
 
 ~U4DVector3n ()
 Default destructor of a vector.
 
 U4DVector3n (const U4DVector3n &a)
 Copy Constructor for a 3D vector. More...
 
U4DVector3noperator= (const U4DVector3n &a)
 Copy Constructor for 3D vector. More...
 
bool operator== (const U4DVector3n &a)
 Method which compares if two 3D vectors are equal. More...
 
void operator+= (const U4DVector3n &v)
 Method that calculates the addition of two vectors. More...
 
U4DVector3n operator+ (const U4DVector3n &v) const
 Method that calculates the addition of two vectors. More...
 
void operator-= (const U4DVector3n &v)
 Method that Calculates the difference between of two vectors. More...
 
U4DVector3n operator- (const U4DVector3n &v) const
 Method that calculates the difference of two vectors. More...
 
void operator*= (const float s)
 Method which multiplies a 3D vector by a scalar. More...
 
U4DVector3n operator* (const float s) const
 Method which multiplies a 3D vector by a scalar. More...
 
U4DQuaternion operator* (U4DQuaternion &q) const
 Method which multiplies a 3D vector by a quaternion. More...
 
void operator/= (const float s)
 Method which divides a 3D vector by a scalar. More...
 
U4DVector3n operator/ (const float s) const
 Method which divides a 3D vector by a scalar. More...
 
float operator* (const U4DVector3n &v) const
 Method that calculates the dot product between two 3D vectors. More...
 
float dot (const U4DVector3n &v) const
 Method that calculates the dot product between two 3D vectors. More...
 
float angle (const U4DVector3n &v)
 Method that calculates the angle between two 3D vectors. More...
 
void operator%= (const U4DVector3n &v)
 Method that calculates the cross product of two 3D vectors. More...
 
U4DVector3n operator% (const U4DVector3n &v) const
 Method that calculates the cross product of two 3D vectors. More...
 
U4DVector3n cross (const U4DVector3n &v) const
 Method that calculates the cross product of two 3D vectors. More...
 
void conjugate ()
 Method that computes the conjugate of a 3D vector. More...
 
void normalize ()
 Method that computes that normalizes a 3D vector. More...
 
float magnitude ()
 Method which calculates the magnitude of a 3D vector. More...
 
float magnitudeSquare ()
 Method which calculates the magnitude square of vector. That is, the square root of the magnitude is not computed. More...
 
U4DPoint3n toPoint ()
 Method to convert 3D vector to a 3D point. More...
 
void zero ()
 Method to set the current 3D vector to a zero-value 3D vector. That is, it sets all its components to zero. More...
 
void absolute ()
 Method which calculates absolute value of a 3D vector. More...
 
U4DVector3n rotateVectorAboutAngleAndAxis (float uAngle, U4DVector3n &uAxis)
 Method which rotates the 3D vector about an axis by the specified angle amount. More...
 
void computeOrthonormalBasis (U4DVector3n &uTangent1, U4DVector3n &uTangent2)
 Method which computes the Orthonormal Basis of the 3D vector given two tangential 3D vectors. More...
 
void negate ()
 Method which negates the 3D vector components of the vector.
 
float getX ()
 returns the x component of the vector More...
 
float getY ()
 returns the y component of the vector More...
 
float getZ ()
 returns the z component of the vector More...
 
void show ()
 Method which prints the components value of the 3D vector to the console log window.
 
void show (std::string uString)
 Method which prints the components value of the 3D vector to the console log window with a user message. More...
 

Public Attributes

float x
 x vector component
 
float y
 y vector component
 
float z
 z vector component
 

Detailed Description

The U4DVector3n class is in charge of implementing 3D Linear Algebra Vector operations. These operations include: Addition, subtraction, scalar multiplication, dot product, cross product, among others.

Constructor & Destructor Documentation

◆ U4DVector3n() [1/2]

U4DEngine::U4DVector3n::U4DVector3n ( float  nx,
float  ny,
float  nz 
)

Constructor which creates a 3D vector with x,y, and z components.

Parameters
nxx component
nyy component
nzz component
Returns
Constructs a vector with the given x,y and z components

◆ U4DVector3n() [2/2]

U4DEngine::U4DVector3n::U4DVector3n ( const U4DVector3n a)

Copy Constructor for a 3D vector.

Parameters
3Dvector to copy
Returns
A copy of the 3D vector

Member Function Documentation

◆ absolute()

void U4DEngine::U4DVector3n::absolute ( )

Method which calculates absolute value of a 3D vector.

◆ angle()

float U4DEngine::U4DVector3n::angle ( const U4DVector3n v)

Method that calculates the angle between two 3D vectors.

Parameters
vA 3D vector to compute the dot product with
Returns
Returns the angle between two 3D vectors in degrees.

◆ computeOrthonormalBasis()

void U4DEngine::U4DVector3n::computeOrthonormalBasis ( U4DVector3n uTangent1,
U4DVector3n uTangent2 
)

Method which computes the Orthonormal Basis of the 3D vector given two tangential 3D vectors.

Parameters
uTangent1Tangential 3D Vector
uTangent2Tangential 3D Vector

◆ conjugate()

void U4DEngine::U4DVector3n::conjugate ( )

Method that computes the conjugate of a 3D vector.

◆ cross()

U4DVector3n U4DEngine::U4DVector3n::cross ( const U4DVector3n v) const

Method that calculates the cross product of two 3D vectors.

Parameters
vA 3D vector to compute the cross product with
Returns
Returns the cross product between two 3D vectors

◆ dot()

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

Method that calculates the dot product between two 3D vectors.

Parameters
vA 3D vector to compute the dot product with
Returns
Returns the dot product between two 3D vectors

◆ getX()

float U4DEngine::U4DVector3n::getX ( )

returns the x component of the vector

Returns
x-component of vector

◆ getY()

float U4DEngine::U4DVector3n::getY ( )

returns the y component of the vector

Returns
y-component of vector

◆ getZ()

float U4DEngine::U4DVector3n::getZ ( )

returns the z component of the vector

Returns
z-component of vector

◆ magnitude()

float U4DEngine::U4DVector3n::magnitude ( )

Method which calculates the magnitude of a 3D vector.

Returns
Returns the magnitude(distance) of a 3D vector

◆ magnitudeSquare()

float U4DEngine::U4DVector3n::magnitudeSquare ( )

Method which calculates the magnitude square of vector. That is, the square root of the magnitude is not computed.

Returns
Returns the magnitude square of a 3D vector. That is, the square root of the magnitude is not computed

◆ normalize()

void U4DEngine::U4DVector3n::normalize ( )

Method that computes that normalizes a 3D vector.

◆ operator%()

U4DVector3n U4DEngine::U4DVector3n::operator% ( const U4DVector3n v) const

Method that calculates the cross product of two 3D vectors.

Parameters
vA 3D vector to compute the cross product with
Returns
Returns the cross product between two 3D vectors

◆ operator%=()

void U4DEngine::U4DVector3n::operator%= ( const U4DVector3n v)

Method that calculates the cross product of two 3D vectors.

Parameters
vA 3D vector to compute the cross product with
Returns
Returns the cross product between two 3D vectors

◆ operator*() [1/3]

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

Method which multiplies a 3D vector by a scalar.

Parameters
sScalar value to multiply
Returns
Returns the multiplication product betweent the 3D vector and scalar

◆ operator*() [2/3]

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

Method that calculates the dot product between two 3D vectors.

Parameters
vA 3D vector to compute the dot product with
Returns
Returns the dot product between two 3D vectors

◆ operator*() [3/3]

U4DQuaternion U4DEngine::U4DVector3n::operator* ( U4DQuaternion q) const

Method which multiplies a 3D vector by a quaternion.

Parameters
qQuaternion to multiply
Returns
Returns a quaternion representing the product of a 3D vector by a quaternion

◆ operator*=()

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

Method which multiplies a 3D vector by a scalar.

Parameters
sScalar value to multiply
Returns
Returns the multiplication product betweent the 3D vector and scalar

◆ operator+()

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

Method that calculates the addition of two vectors.

Parameters
v3D vector to add
Returns
Returns a third vector representing the addition of two 3D vectors

◆ operator+=()

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

Method that calculates the addition of two vectors.

Parameters
vVector to add.
Returns
Returns the addition of two vectors.

◆ operator-()

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

Method that calculates the difference of two vectors.

Parameters
v3D vector to subtract
Returns
Returns a third vector representing the subtraction of two 3D vectors

◆ operator-=()

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

Method that Calculates the difference between of two vectors.

Parameters
v3D vector to subtract
Returns
Returns the subtraction of two 3D vectors

◆ operator/()

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

Method which divides a 3D vector by a scalar.

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

◆ operator/=()

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

Method which divides a 3D vector by a scalar.

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

◆ operator=()

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

Copy Constructor for 3D vector.

Parameters
3Dvector to copy
Returns
A copy of the 3D vector

◆ operator==()

bool U4DEngine::U4DVector3n::operator== ( const U4DVector3n a)

Method which compares if two 3D vectors are equal.

Parameters
a3D vector to compare to
Returns
Returs true if both vectors contain the same components

◆ rotateVectorAboutAngleAndAxis()

U4DVector3n U4DEngine::U4DVector3n::rotateVectorAboutAngleAndAxis ( float  uAngle,
U4DVector3n uAxis 
)

Method which rotates the 3D vector about an axis by the specified angle amount.

Parameters
uAngleAngle in degrees to rotate
uAxisAxis to rotate vector about
Returns
Rotation of the vector about a given axis by the angle amount

◆ show()

void U4DEngine::U4DVector3n::show ( std::string  uString)

Method which prints the components value of the 3D vector to the console log window with a user message.

Parameters
uStringMessage to pring along with the vector components

◆ toPoint()

U4DPoint3n U4DEngine::U4DVector3n::toPoint ( )

Method to convert 3D vector to a 3D point.

Returns
3D point representation of a 3D vector

◆ zero()

void U4DEngine::U4DVector3n::zero ( )

Method to set the current 3D vector to a zero-value 3D vector. That is, it sets all its components to zero.