A helper object for performing 2D and 3D vector math.
None.
vector(x, y, z); vector(x, y);
Constructor for creating a 2D or 3D vector.
(object) a Vector3.
distacne(v1, v2);
Returns the cartesian distance between two points in space.
(float) distance between v1 and v2.
add(v1, v2);
Adds two vectors component-wise.
(object) a Vector2 or Vector3.
sub(v1, v2);
Substracts v2 from v1 component-wise.
mul(scaler, v);
Multiply a scaler with a vector component-wise.
dot(v1, v2);
Returns the dot product between v1 and v2.
(float)
cross(v1, v2);
Returns the cross product between v1 and v2.
len(v);
Returns the length of v.
normalize(v);
Normalize input vector so that its length is 1.