Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vector

The main Vector class

Hierarchy

  • Vector

Implements

Index

Constructors

constructor

  • new Vector(x?: number, y?: number): Vector
  • Parameters

    • Default value x: number = 0
    • Default value y: number = 0

    Returns Vector

Properties

x

x: number

y

y: number

Accessors

angle

  • get angle(): number
  • Get the angle of the instance Vector in radiants

    Returns number

length

  • get length(): number
  • Get the length of the vector (alias for magnitude)

    Returns number

magnitude

  • get magnitude(): number
  • Get the magnitude of the vector

    Returns number

max

  • get max(): number

min

  • get min(): number

Methods

add

angleTo

  • Get the angle from the instance to another Vector in radians

    Parameters

    Returns number

clone

crossProduct

  • Cross product of the instance and some Vector or Point

    Parameters

    Returns number

divide

  • Divide the instance with a Vector or scalar

    Parameters

    Returns Vector

dotProduct

  • Scalar product of the instance and some Vector or Point

    Parameters

    Returns number

equals

  • Checks if an Vector or Point is equal to the instance

    Parameters

    Returns boolean

inverse

multiply

  • Multiply the instance with a Vector or scalar

    Parameters

    Returns Vector

normalize

set

  • set(x: number, y: number): Vector
  • Set the scalars of the Vector

    Parameters

    • x: number
    • y: number

    Returns Vector

sub

  • Subtract a Vector or scalar from the instance

    Parameters

    Returns Vector

toArray

  • toArray(): number[]
  • Return a array with the scalars of the instance Vector

    Returns number[]

Static add

Static angleBetween

Static closestPointBetween

Static crossProduct

Static distance

Static divide

Static dotProduct

Static equals

Static fromArray

  • fromArray(array: number[]): Vector
  • Create a Vector from the first two values of a array

    Parameters

    • array: number[]

    Returns Vector

Static inverse

Static isOnLine

Static multiply

Static normalize

Static pointBetween

Static sub

Generated using TypeDoc