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

  • default

Constructors

Properties

_temp: IVector[] = ...

Temporary vector pool (not thread-safe).

Methods

  • Returns the angle between the vector vectorB - vectorA and the x-axis in radians.

    Parameters

    Returns number

    The angle in radians

    Method

    angle

  • Returns the cross-product of two vectors.

    Parameters

    Returns number

    The cross product of the two vectors

  • Returns the cross-product of three vectors.

    Parameters

    Returns number

    The cross product of the three vectors

  • Returns the dot-product of two vectors.

    Parameters

    Returns number

    The dot product of the two vectors

  • Returns the magnitude (length) of a vector.

    Parameters

    Returns number

    The magnitude of the vector

    Method

    magnitude

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

    Parameters

    Returns number

    The squared magnitude of the vector

    Method

    magnitudeSquared

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

    Parameters

    • vector: IVector
    • negate: boolean = false

    Returns IVector

    The perpendicular vector

    Method

    perp

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

    Parameters

    Returns IVector

    A new vector rotated about the point

    Method

    rotateAbout

Generated using TypeDoc