PokéRogue
    Preparing search index...

    The Matter.Vector module contains methods for creating and manipulating vectors. Vectors are the basis of all the geometry related operations in the engine. A Matter.Vector object is of the form { x: 0, y: 0 }.

    See the included usage examples.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    x: number
    y: number

    Methods

    • Adds the two vectors.

      Parameters

      Returns Vector

      A new vector of vectorA and vectorB added

      add

    • Returns the angle in radians between the two vectors relative to the x-axis.

      Parameters

      Returns number

      The angle in radians

      angle

    • Returns a new vector with x and y copied from the given vector.

      Parameters

      Returns Vector

      A new cloned vector

      clone

    • Creates a new vector.

      Parameters

      • Optionalx: number
      • Optionaly: number

      Returns Vector

      A new vector

      create

    • Returns the cross-product of two vectors.

      Parameters

      Returns number

      The cross product of the two vectors

      cross

    • Returns the cross-product of three vectors.

      Parameters

      Returns number

      The cross product of the three vectors

      cross3

    • Divides a vector and a scalar.

      Parameters

      Returns Vector

      A new vector divided by scalar

      div

    • Returns the dot-product of two vectors.

      Parameters

      Returns Number

      The dot product of the two vectors

      dot

    • Returns the magnitude (length) of a vector.

      Parameters

      Returns number

      The magnitude of the vector

      magnitude

    • Returns the magnitude (length) of a vector (therefore saving a sqrt operation).

      Parameters

      Returns number

      The squared magnitude of the vector

      magnitudeSquared

    • Multiplies a vector and a scalar.

      Parameters

      Returns Vector

      A new vector multiplied by scalar

      mult

    • Negates both components of a vector such that it points in the opposite direction.

      Parameters

      Returns Vector

      The negated vector

      neg

    • Normalises a vector (such that its magnitude is 1).

      Parameters

      Returns Vector

      A new vector normalised

      normalise

    • Returns the perpendicular vector. Set negate to true for the perpendicular in the opposite direction.

      Parameters

      • vector: Vector
      • Optionalnegate: boolean

      Returns Vector

      The perpendicular vector

      perp

    • Rotates the vector about (0, 0) by specified angle.

      Parameters

      Returns Vector

      A new vector rotated about (0, 0)

      rotate

    • Rotates the vector about a specified point by specified angle.

      Parameters

      Returns Vector

      A new vector rotated about the point

      rotateAbout

    • Subtracts the two vectors.

      Parameters

      Returns Vector

      A new vector of vectorA and vectorB subtracted

      sub