Hierarchy

Implements

Constructors

  • Protected

    Vector constructor, creating an instance with the given coordinates

    Parameters

    • xOrCoords: number | ICoordinates3d

      X coordinate or the whole ICoordinates object

    • Optional y: number

      Y coordinate

    • Optional z: number

      Z coordinate

    Returns Vector3d

Properties

x: number

X coordinate of the vector

y: number

Y coordinate of the vector

z: number

Z coordinate

Accessors

  • get angle(): number
  • Returns the current vector angle, based on x,y values

    Returns number

  • set angle(angle: number): void
  • Sets the x,y values using an angle, length must be greater than 0

    Parameters

    • angle: number

      the angle to set

    Returns void

  • get length(): number
  • Returns the current vector length, based on x,y values

    Returns number

  • set length(length: number): void
  • Sets the x,y values using the length

    Parameters

    • length: number

      the length to set

    Returns void

  • get origin(): Vector3d
  • A new vector, with coordinates in the origin point

    Returns Vector3d

Methods

  • Adds the current and the given vector together, without modifying them

    Returns

    the sum vector

    Parameters

    • v: Vector

      the vector used for the sum operation

    Returns Vector

  • Adds the given vector to the current one, modifying it

    Parameters

    • v: Vector

      the vector to add to the current one

    Returns void

  • Calculates the distance between the current vector and the given one

    Returns

    the distance between the vectors

    Parameters

    • v: Vector

      the vector used for calculating the distance from the current one

    Returns number

  • Get the distance squared between two vectors

    Returns

    the distance squared between the vectors

    Parameters

    • v: Vector

      the vector used for calculating the distance from the current one

    Returns number

  • Divides the given scalar and the current vector together, without modifying it

    Parameters

    • n: number

      the scalar value to divide from the current vector

    Returns Vector

  • Divides the given scalar from the current vector, modifying it

    Parameters

    • n: number

      the scalar value to divide from the current vector

    Returns void

  • Get the squared length value

    Returns

    the squared length value

    Returns number

  • Returns the Manhattan distance between all vectors

    Returns

    the Manhattan distance between the vectors

    Parameters

    • v: Vector

      the vector used for calculating the distance from the current one

    Returns number

  • Multiplies the given scalar and the current vector together, without modifying it

    Returns

    the multiplied vector

    Parameters

    • n: number

      the scalar value to multiply to the vector

    Returns Vector

  • Multiplies the given scalar to the current vector, modifying it

    Parameters

    • n: number

      the scalar value to multiply to the vector

    Returns void

  • Creates a new vector, rotating the current one, without modifying it

    Parameters

    • angle: number

      the rotation angle

    Returns Vector

  • Set the vector to the specified velocity

    Parameters

    Returns void

  • Subtracts the current and the given vector together, without modifying them

    Returns

    the subtracted vector

    Parameters

    • v: Vector

      the vector used for the subtract operation

    Returns Vector

  • Subtracts the given vector from the current one, modifying it

    Parameters

    • v: Vector

      the vector to subtract from the current one

    Returns void

  • Creates a new vector instance

    Returns

    the new vector created

    Parameters

    • x: number | ICoordinates3d

      X coordinate

    • Optional y: number

      Y coordinate

    • Optional z: number

      Z coordinate

    Returns Vector3d