gophergfx
    Preparing search index...

    Class Vector2

    Index
    • Constructor for Vector2 class

      Parameters

      • x: number = 0

        The initial x coordinate of the Vector2

      • y: number = 0

        The initial y coordinate of the Vector2

      Returns Vector2

    x: number
    y: number
    DOWN: Vector2 = ...
    LEFT: Vector2 = ...
    ONE: Vector2 = ...
    RIGHT: Vector2 = ...
    UP: Vector2 = ...
    X_AXIS: Vector2 = Vector2.RIGHT
    Y_AXIS: Vector2 = Vector2.UP
    ZERO: Vector2 = ...
    • Adds the components of a given Vector2 to this Vector2

      Parameters

      • v: Vector2

        The Vector2 to add to this Vector2

      Returns void

    • Calculates the angle between this Vector2 and another Vector2

      Parameters

      • v: Vector2

        The Vector2 to calculate the angle between

      Returns number

      The angle between the two Vector2 objects

    • Calculates the signed angle between this Vector2 and another Vector2

      Parameters

      • v: Vector2

        The Vector2 to calculate the angle between

      Returns number

      The signed angle between the two Vector2 objects

    • Calculates the distance between this Vector2 and another Vector2

      Parameters

      • v: Vector2

        The Vector2 to calculate the distance to

      Returns number

      The distance between the two Vector2 objects

    • Divides the components of this Vector2 by a given Vector2

      Parameters

      • v: Vector2

        The Vector2 to divide this Vector2 by

      Returns void

    • Divides the Vector2 by a scalar value

      Parameters

      • n: number

        The scalar value to divide by

      Returns void

    • Calculates the dot product of this Vector2 and another Vector2

      Parameters

      • v: Vector2

        The Vector2 to calculate the dot product with

      Returns number

      The dot product of the two Vector2 objects

    • Checks if two Vector2 objects have the same coordinates

      Parameters

      • v: Vector2

        The Vector2 object to compare

      Returns boolean

      true if the coordinates of both Vector2 objects are the same, false otherwise

    • Calculates the length of this Vector2

      Returns number

      The length of this Vector2

    • Calculates the linear interpolation between two Vector2 objects

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      • alpha: number

        The interpolation value between 0 and 1

      Returns void

    • Multiplies the components of a given Vector2 by this Vector2

      Parameters

      • v: Vector2

        The Vector2 to multiply this Vector2 by

      Returns void

    • Multiplies the Vector2 by a scalar value

      Parameters

      • n: number

        The scalar value to multiply by

      Returns void

    • Rotates this Vector2 by a given angle

      Parameters

      • angle: number

        The angle to rotate by in radians

      Returns void

    • Sets the coordinates of the Vector2

      Parameters

      • x: number

        The new x coordinate of the Vector2

      • y: number

        The new y coordinate of the Vector2

      Returns void

    • Sets the position of this Vector2 from a Matrix3

      Parameters

      • m: Matrix3

        The Matrix3 to get the position from

      Returns void

    • Sets the scale of this Vector2 from a Matrix3

      Parameters

      • m: Matrix3

        The Matrix3 to get the scale from

      Returns void

    • Subtracts the components of a given Vector2 from this Vector2

      Parameters

      • v: Vector2

        The Vector2 to subtract from this Vector2

      Returns void

    • Transforms this Vector2 object with a Matrix3

      Parameters

      • m: Matrix3

        The Matrix3 to transform this Vector2 with

      Returns void

    • Transforms this Vector2 object with a Matrix3, ignoring the translation component

      Parameters

      • m: Matrix3

        The Matrix3 to transform this Vector2 with

      Returns void

    • Computes the angle between two Vector2 objects

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      Returns number

      The angle between the two input vectors

    • Computes the angle between two Vector2 objects with sign

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      Returns number

      The signed angle between the two input vectors

    • Computes the distance between two Vector2 objects

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      Returns number

      The distance between the two input vectors

    • Divides a Vector2 object by a scalar and returns the result in a new Vector2

      Parameters

      • v: Vector2

        The Vector2 object

      • n: number

        The scalar

      Returns Vector2

      A new Vector2 object with the result of the division

    • Computes the dot product of two Vector2 objects

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      Returns number

      The dot product of the two input vectors

    • Linearly interpolates between two Vector2 objects

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      • alpha: number

        The interpolation value between 0 and 1

      Returns Vector2

      The interpolated Vector2

    • Multiplies two Vector2 objects and returns the result in a new Vector2

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      Returns Vector2

      A new Vector2 object with the result of the multiplication

    • Multiplies a Vector2 object by a scalar and returns the result in a new Vector2

      Parameters

      • v: Vector2

        The Vector2 object

      • n: number

        The scalar

      Returns Vector2

      A new Vector2 object with the result of the multiplication

    • Rotates an input Vector2 by a given angle

      Parameters

      • v: Vector2

        The Vector2 object to be rotated

      • angle: number

        The angle to rotate the Vector2 by

      Returns Vector2

      The rotated Vector2

    • Subtracts two Vector2 objects and returns the result in a new Vector2

      Parameters

      • v1: Vector2

        The first Vector2 object

      • v2: Vector2

        The second Vector2 object

      Returns Vector2

      A new Vector2 object with the result of the subtraction

    • Transforms an input Vector2 as a direction by a given Matrix3, ignoring the translation component

      Parameters

      • v: Vector2

        The Vector2 object to be transformed

      • m: Matrix3

        The Matrix3 to transform the Vector2 by

      Returns Vector2

      The transformed Vector2