Type Vector

Vector type

Methods

add (v) Add vector - Modifies self.
cross (v) Calculates the cross product of the 2 vectors, creates a unique perpendicular vector to both input vectors.
dot (v) Dot product is the cosine of the angle between both vectors multiplied by their lengths.
getAngle () Get the vector's angle.
getAngleEx (v) Returns the Angle between two vectors.
getDistance (v) Returns the pythagorean distance between the vector and the other vector.
getDistanceSqr (v) Returns the squared distance of 2 vectors, this is faster Vector:getDistance as calculating the square root is an expensive process.
getLength () Get the vector's Length.
getLength2D () Returns the length of the vector in two dimensions, without the Z axis.
getLength2DSqr () Returns the length squared of the vector in two dimensions, without the Z axis.
getLengthSqr () Get the vector's length squared ( Saves computation by skipping the square root ).
getNormalized () Returns a new vector with the same direction by length of 1.
isEqualTol (v, t) Is this vector and v equal within tolerance t.
isZero () Are all fields zero.
mul (n) Scalar Multiplication of the vector.
normalize () Normalise the vector, same direction, length 0.
rotate (a) Rotate the vector by Angle a.
set (v) Copies the values from the second vector to the first vector.
setZero () Set's all vector fields to 0.
sub (v) Subtract v from this Vector.
toScreen () Translates the vectors position into 2D user screen coordinates.
withinAABox (v1, v2) Returns whenever the given vector is in a box created by the 2 other vectors.


Methods

vec_methods:add (v)
Add vector - Modifies self.

Parameters:

  • v: Vector to add

Return value:

    nil
vec_methods:cross (v)
Calculates the cross product of the 2 vectors, creates a unique perpendicular vector to both input vectors.

Parameters:

  • v: Second Vector

Return value:

    Vector
vec_methods:dot (v)
Dot product is the cosine of the angle between both vectors multiplied by their lengths. A.B = ||A||||B||cosA.

Parameters:

  • v: Second Vector

Return value:

    Number
vec_methods:getAngle ()
Get the vector's angle.

Return value:

    Angle
vec_methods:getAngleEx (v)
Returns the Angle between two vectors.

Parameters:

  • v: Second Vector

Return value:

    Angle
vec_methods:getDistance (v)
Returns the pythagorean distance between the vector and the other vector.

Parameters:

  • v: Second Vector

Return value:

    Number
vec_methods:getDistanceSqr (v)
Returns the squared distance of 2 vectors, this is faster Vector:getDistance as calculating the square root is an expensive process.

Parameters:

  • v: Second Vector

Return value:

    Number
vec_methods:getLength ()
Get the vector's Length.

Return value:

    number Length.
vec_methods:getLength2D ()
Returns the length of the vector in two dimensions, without the Z axis.

Return value:

    number length
vec_methods:getLength2DSqr ()
Returns the length squared of the vector in two dimensions, without the Z axis. ( Saves computation by skipping the square root )

Return value:

    number length squared.
vec_methods:getLengthSqr ()
Get the vector's length squared ( Saves computation by skipping the square root ).

Return value:

    number length squared.
vec_methods:getNormalized ()
Returns a new vector with the same direction by length of 1.

Return value:

    Vector Normalised
vec_methods:isEqualTol (v, t)
Is this vector and v equal within tolerance t.

Parameters:

  • v: Second Vector
  • t: Tolerance number.

Return value:

    bool True/False.
vec_methods:isZero ()
Are all fields zero.

Return value:

    bool True/False
vec_methods:mul (n)
Scalar Multiplication of the vector. Self-Modifies.

Parameters:

  • n: Scalar to multiply with.

Return value:

    nil
vec_methods:normalize ()
Normalise the vector, same direction, length 0. Self-Modifies.

Return value:

    nil
vec_methods:rotate (a)
Rotate the vector by Angle a. Self-Modifies.

Parameters:

  • a: Angle to rotate by.

Return value:

    nil.
vec_methods:set (v)
Copies the values from the second vector to the first vector. Self-Modifies.

Parameters:

  • v: Second Vector

Return value:

    nil
vec_methods:setZero ()
Set's all vector fields to 0.

Return value:

    nil
vec_methods:sub (v)
Subtract v from this Vector. Self-Modifies.

Parameters:

  • v: Second Vector.

Return value:

    nil
vec_methods:toScreen ()
Translates the vectors position into 2D user screen coordinates. Self-Modifies.

Return value:

    nil
vec_methods:withinAABox (v1, v2)
Returns whenever the given vector is in a box created by the 2 other vectors.

Parameters:

  • v1: Vector used to define AABox
  • v2: Second Vector to define AABox

Return value:

    bool True/False.

Valid XHTML 1.0!