Skip to content

Vector4

Jesusemora edited this page Apr 1, 2023 · 2 revisions

Vector4

Variables

Variable Description
float pos[4] naked array containing the values of Vector4
float &x reference to the first element of pos[]. can be used as myVector4.x.
float &y reference to the second element of pos[]. can be used as myVector4.y.
float &z reference to the third element of pos[]. can be used as myVector4.z.
float &w reference to the fourth element of pos[]. can be used as myVector4.w.

public methods

Function Description
float *toArray() returns a float array of size 4 with the values of the current Vector4
float Magnitude() returns non sqr magnitude of current Vector4
float sqrMagnitude() returns sqr magnitude of current Vector4
void Normalize() normalizes current Vector4
void QNormalize() normalizes current Vector4 treating it as a quaternion
Vector3 normalized returns the normalized version of current Vector3

static methods

Function Description
float fastDistance(Vector4 a, Vector4 b) returns the distance between a and b in a tiled space ( like chess ). probably useless since it measures in 4 dimensions
float Distance(Vector4 a, Vector4 b) returns the exact distance between a and b. probably useless since it measures in 4 dimensions
float Dot(Vector4 a, Vector4 b) returns the dot product of a and b

constructors

Vector4(float x, float y, float z, float w) generates a Vector4 containing the values x, y, z and w.
Vector4 generates a Vector4 filled with (0, 0, 0, 1) wihtout parameters
Vector4(float (&obj)[4]) initializes Vector4 from an array of float of size 4

operators

operator+ adds two Vector4s

operator- substracts two Vector4s

operator+= adds the values of Vector4 to current

operator-= substracts the values of Vector4 from current

operator* multiplies current Vector4 by a float

operator/ divides current Vector4 by a float

operator+ adds float to every value of current Vector4

operator- substracts float from every value of current Vector4

operator*= multiplies every value of current Vector4 by float

operator/= divides every value of current Vector4 by float

operator== returns true if two Vector4s are equal and false if they are different

operator= assigns a Vector4 or array of float of size 4 or Vector3 to the current Vector4

operator[i] returns the value at position i. read only

Clone this wiki locally