Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vector

Contains math for common vector operations.

Hierarchy

  • Vector

Index

Methods

Static add

Static areEqual

  • Returns true if two vectors have the same x and y values.

    Parameters

    Returns boolean

Static getCenter

  • Will find the center of an area by averaging all Vectors in the area. This point may not be in the area itself, for example in a donut shaped area.

    Parameters

    Returns Vector2

Static getClosest

  • Will find the position in the area closest to the target

    Parameters

    • area: Vector2[]

      Vector2[]

    • target: Vector2

      Vector2

    • Default value topology: "four" | "eight" = "four"

      Either 'four' or 'eight'. Default 'four'

    Returns Vector2

Static getDistance

  • getDistance(start: Vector2, end: Vector2, topology?: "four" | "eight"): number
  • Returns the distance between two vectors.

    If no topology is given, diagonal distance is sqrt(2). If topology is four, diagonal distance is 2. If topology is eight, diagonal distance is 1.

    Parameters

    • start: Vector2

      The starting Vector2.

    • end: Vector2

      The ending Vector2.

    • Optional topology: "four" | "eight"

      Can use "four" or "eight" for non-cartesian distances.

    Returns number

Static subtract

Generated using TypeDoc