@ujjwalvivek/tinyts
    Preparing search index...

    Class Vec2

    2D vector class for position, velocity, and size calculations.

    Index

    Constructors

    • Parameters

      • x: number = 0

        X component.

      • y: number = 0

        Y component.

      Returns Vec2

    Properties

    x: number = 0

    X component.

    y: number = 0

    Y component.

    Methods

    • Angle of the vector in radians.

      Returns number

    • Calculate dot product with another vector.

      Parameters

      Returns number

    • Check if components are equal to another vector.

      Parameters

      Returns boolean

    • Calculate length of the vector.

      Returns number

    • Calculate squared length of the vector.

      Returns number

    • Linear interpolation towards another vector.

      Parameters

      Returns this

    • Scale vector to unit length (length of 1).

      Returns this

    • Rotate the vector 90 degrees counter-clockwise.

      Returns this

    • Rotate the vector by an angle in radians.

      Parameters

      • angle: number

      Returns this

    • Multiply components by a scalar.

      Parameters

      • s: number

      Returns this

    • Set vector components.

      Parameters

      • x: number
      • y: number

      Returns this

    • Subtract another vector from this one.

      Parameters

      Returns this