Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vector

Represents a 2D Vector

Hierarchy

  • Vector

Index

Constructors

constructor

Properties

_x

_x: number

_y

_y: number

Static RAD_TO_DEGREES

RAD_TO_DEGREES: number = 180 / Math.PI

Ratio between Radians and degrees

Accessors

x

  • get x(): number

y

  • get y(): number

Methods

add

  • Adds coordinates of a Vector

    Parameters

    • coordX: number

      Addition on X-Axis

    • coordY: number

      Addition on Y-Axis

    Returns Vector

    Current Vector

  • Adds coordinates of a Vector

    Parameters

    • newVector: Vector

      Addition on X-Axis

    Returns Vector

    Current Vector

clone

getAngle

  • getAngle(v?: Vector): number
  • Returns the direction of the Vector. A zero-length Vector has an angle of 0

    Parameters

    • Optional v: Vector

      Relative to this vector

    Returns number

    The direction of the Vector in degrees

getAngleRad

  • getAngleRad(v?: Vector): number
  • Returns the direction of the Vector. A zero-length Vector has an angle of 0

    Parameters

    • Optional v: Vector

      Relative to this vector

    Returns number

    The direction of the Vector in radians

getDotProduct

  • getDotProduct(v: Vector): number
  • Returns the dot product of vectors

    Parameters

    Returns number

    dot product

getLength

  • getLength(): number
  • Returns length of Vector

    Returns number

    length (magnitude) of the Vector

getMagnitude

  • getMagnitude(): number

getNormal

getProjection

  • Returns the orthogonal projection on provided vector

    Parameters

    • v: Vector

      Projection Vector. Resulting Vector is collinear to this one

    Returns Vector

isZeroLength

  • isZeroLength(): boolean
  • Checks if vector is a zero Vector

    Returns boolean

    true only if the length of the Vector is zero

multiply

  • multiply(value: number): Vector
  • Multiplies the length of the Vector

    Parameters

    • value: number

      Multiplier

    Returns Vector

    Current Vector

normalize

rotate

  • rotate(degrees: number): Vector
  • Rotates Vector

    Parameters

    • degrees: number

      Rotation angle in degrees

    Returns Vector

    Current Vector

rotateRad

  • rotateRad(rad: number): Vector
  • Rotates Vector

    Parameters

    • rad: number

      Rotation angle in radians

    Returns Vector

    Current Vector

scale

  • scale(value: number): Vector

set

  • set(newX: number, newY: number): Vector
  • Sets new values for Vector

    Parameters

    • newX: number

      New X-Axis value

    • newY: number

      New Y-Axis value

    Returns Vector

    Current Vector

sub

  • Substracts coordinates of a Vector

    Parameters

    • coordX: number

      Substraction on X-Axis

    • coordY: number

      Substraction on Y-Axis

    Returns Vector

    Current Vector

  • Substracts coordinates of a Vector

    Parameters

    • newVector: Vector

      Addition on X-Axis

    Returns Vector

    Current Vector

truncate

  • truncate(maxLength: number): Vector
  • Limits the length of a Vector, trucates it if necessary

    Parameters

    • maxLength: number

      The maximum length (magnitude) allowed for the Vector

    Returns Vector

    current Vector

Generated using TypeDoc