Skip to content
Obtuse Studios edited this page Jun 14, 2016 · 1 revision

vecMath

For apply static functions such as multiplication to one or more vectors.

Info

Used for when a mathematical operation needs to be applied to one or two vectors. The vecMath functions will then return the resulting calculated vector.

Functions

float vecMath.distance(vector a, vector b);

Finds the floating point distance between the two vectors a and b. Based on Pythagoras triangle theorem, where the result is the hypotenuse of a right angled triangle formed from the two points. Here is a diagram:

Finding distance using triangle

(X1, Y1) is point A. (X2, Y2) is point B. The result of the function is hypotenuse of this triangle.

vector vecMath.normalize(vec)

Returns the normalized form of the parameter vector. The normalized form of a vector is when the magnitude is equal to one. And the result stores the direction from the origin. Normalizing vectors is very important in moving from one point to another, or to find the direction of a point.

float vecMath.angle(vector from, vector to)

Returns the angle in degrees from the 'from' vector to the 'to' vector. Use mathematics.degToRad to convert into radians.

float vecMath.length(vec)

Returns the length of the parameter vector. The result is a vector with a magnitude but no direction.

bool vecMath.checkType(vector other);

Will return true if the parameter parsed is of the type vector. If not a vector false will returned.

vector vecMath.random(vector min, vector max);

Will return a randomly generated vector where the result is in-between the min and max vector. Note: min and max are inclusive

bool vecMath.isEqual(vector a, vector b);

Check if the two parsed vectors are identical, returns boolean result.

Usage

Clone this wiki locally