Class Vector

Vector type

Info:

  • Author: Ennis Massey

Tables

Vector.__propget Contains properties of the Vector type

Methods

Vector:Normalize () Normalises the given Vector
Vector:Normalized () Returns the Vector, normalised
Vector:Dot (second) Returns the Dot product (Scalar) of two vectors
Vector:Cross (second) Returns the Cross product of two vectors This is entirely useless, as it returns the Z coordinate, or height, which cannot be used.
Vector:Lerp (first, second, t) Returns a lerped version of the two vectors Doesn’t seem to work, always returns nil
Vector:Clamp (MinX, MinY, MaxX, MaxY) Clamps the vector based on given boundings.
Vector:Clamped (MinX, MinY, MaxX, MaxY) Returns the clamped version of the current Vector
Vector:Distance (second) Returns the distance between two Vector’s
Vector:DistanceSquared (second) Returns the squared distance between two Vector’s
Vector:FromAngle (AngleDegrees) Constructs a Vector from a given angle
Vector:GetAngleDegrees () Returns the angle the vector is facing
Vector:Length () Returns the length of the vector
Vector:LengthSquared () Returns the length squared of the vector
Vector:Resize (NewLength) Resizes a vector
Vector:Resized (NewLength) Returns a resized vector
Vector:Rotated (AngleDegrees) Returns a rotated version of the Vector

Metamethods

Vector:__call (x, y) Constructs a new Vector
Vector:__add (Right) Addition metamethod, allows addition of one Vector to another
Vector:__sub (Right) Subtraction metamethod, allows addition of one Vector to another
Vector:__unm () Unary minus (negation) metamethod, allows negation of a Vector
Vector:__div (Modifier) Division metamethod, allows division of one Vector by a float
Vector:__mul (Modifier) Multiplication metamethod, allows multiplication of one Vector by a float


Tables

Vector.__propget
Contains properties of the Vector type

Fields:

Methods

Vector:Normalize ()
Normalises the given Vector This is an instance only method, it cannot be called directly from Vector

Returns:

    nil nil
Vector:Normalized ()
Returns the Vector, normalised This is an instance only method, it cannot be called directly from Vector

Returns:

    Vector Normalised Vector
Vector:Dot (second)
Returns the Dot product (Scalar) of two vectors This is an instance only method, it cannot be called directly from Vector

Parameters:

  • second Vector Second vector in the dot product equation

Returns:

    float dot product of the two Vector 's
Vector:Cross (second)

Returns the Cross product of two vectors This is entirely useless, as it returns the Z coordinate, or height, which cannot be used.

This is an instance only method, it cannot be called directly from Vector

Parameters:

  • second Vector Second vector in the cross product equation
Vector:Lerp (first, second, t)
Returns a lerped version of the two vectors Doesn’t seem to work, always returns nil This is an instance only method, it cannot be called directly from Vector

Parameters:

  • first Vector first vector in calculation
  • second Vector second vector in calculation
  • t float percentage to multiply vectors by
Vector:Clamp (MinX, MinY, MaxX, MaxY)

Clamps the vector based on given boundings. Direction is not kept

This is an instance only method, it cannot be called directly from Vector

Parameters:

  • MinX float Minimum X bounding
  • MinY float Minimum Y bounding
  • MaxX float Maximum X bounding
  • MaxY float Maximum Y bounding

Usage:

    local tempVector = Vector(30, 20)
    tempVector:Clamp(0, 0, 20, 10)
    tempVector == Vector(20, 10)
Vector:Clamped (MinX, MinY, MaxX, MaxY)
Returns the clamped version of the current Vector This is an instance only method, it cannot be called directly from Vector

Parameters:

  • MinX float Minimum X bounding
  • MinY float Minimum Y bounding
  • MaxX float Maximum X bounding
  • MaxY float Maximum Y bounding

Returns:

    Vector clamped vector

Usage:

    local tempVector = Vector(30, 20)
    local newTemp = tempVector:Clamp(0, 0, 20, 10)
    newTempVector == Vector(20, 10)
    tempVector == Vector(30, 20)
Vector:Distance (second)
Returns the distance between two Vector’s This is an instance only method, it cannot be called directly from Vector

Parameters:

Usage:

    Vector(2,0):Distance(Vector(0,2)) == 2
Vector:DistanceSquared (second)
Returns the squared distance between two Vector’s This is an instance only method, it cannot be called directly from Vector

Parameters:

Usage:

    Vector(2,0):DistanceSquared(Vector(0,2)) == 8
Vector:FromAngle (AngleDegrees)
Constructs a Vector from a given angle This is a static method, it cannot be called from an instance of Vector

Parameters:

  • AngleDegrees float Angle in degrees to use when creating Vector
Vector:GetAngleDegrees ()
Returns the angle the vector is facing This is an instance only method, it cannot be called directly from Vector

Returns:

    float Angle
Vector:Length ()
Returns the length of the vector This is an instance only method, it cannot be called directly from Vector

Returns:

    float the length of the vector
Vector:LengthSquared ()
Returns the length squared of the vector This is an instance only method, it cannot be called directly from Vector

Returns:

    float squared length of the vector
Vector:Resize (NewLength)
Resizes a vector This is an instance only method, it cannot be called directly from Vector

Parameters:

  • NewLength float new length for vector
Vector:Resized (NewLength)
Returns a resized vector This is an instance only method, it cannot be called directly from Vector

Parameters:

  • NewLength float new length for vector

Returns:

    Vector resized vector
Vector:Rotated (AngleDegrees)
Returns a rotated version of the Vector This is an instance only method, it cannot be called directly from Vector

Parameters:

  • AngleDegrees float angle to rotate by

Returns:

    Vector rotated vector

Metamethods

Vector:__call (x, y)
Constructs a new Vector

Parameters:

  • x float X coordinate the Vector represents
  • y float Y coordinate the Vector represents

Returns:

    Vector new vector

Usage:

    local spawnPosition = Vector(0, 20)
Vector:__add (Right)
Addition metamethod, allows addition of one Vector to another

Parameters:

Returns:

    Vector result of addition

Usage:

    Vector(0,0) + Vector(0,2)
Vector:__sub (Right)
Subtraction metamethod, allows addition of one Vector to another

Parameters:

  • Right Vector Vector to subtract

Returns:

    Vector result of subtraction

Usage:

    Vector(0,0) - Vector(0,2)
Vector:__unm ()
Unary minus (negation) metamethod, allows negation of a Vector

Returns:

    Vector negated vector

Usage:

    -Vector(0,2)
Vector:__div (Modifier)
Division metamethod, allows division of one Vector by a float

Parameters:

  • Modifier float Number to divide by

Usage:

    Vector(2, 2) / 2
Vector:__mul (Modifier)
Multiplication metamethod, allows multiplication of one Vector by a float

Parameters:

  • Modifier float Number to multiply by

Usage:

    Vector(2, 2) * 2
generated by LDoc 1.4.6 Last updated 2017-07-17 09:37:29