Class Vector3d

a generic 3D Vector Object

Hierarchy (view full)

Constructors

  • Parameters

    • Optionalx: number = 0

      x value of the vector

    • Optionaly: number = 0

      y value of the vector

    • Optionalz: number = 0

      z value of the vector

    Returns Vector3d

Properties

x: undefined | number

x value of the vector

y: undefined | number

y value of the vector

z: undefined | number

z value of the vector

Methods

  • Clamp this vector value within the specified value range

    Parameters

    • low: number
    • high: number

    Returns Vector3d

    Reference to this object for method chaining

  • Divide this vector values by the passed value

    Parameters

    • n: number

      the value to divide the vector by

    Returns Vector3d

    Reference to this object for method chaining

  • return true if this vector is equal to the given values or vector

    Parameters

    • Rest...args: any[]

    Returns boolean

    true if both vectros are equals

  • return the length (magnitude) of this vector

    Returns number

    the length of this vector

  • return the square length of this vector

    Returns number

    The length^2 of this vector.

  • Linearly interpolate between this vector and the given one.

    Parameters

    • v: Vector3d
    • alpha: number

      distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).

    Returns Vector3d

    Reference to this object for method chaining

  • interpolate the position of this vector on the x and y axis towards the given one by the given maximum step.

    Parameters

    • target: Vector2d | Vector3d
    • step: number

      the maximum step per iteration (Negative values will push the vector away from the target)

    Returns Vector3d

    Reference to this object for method chaining

  • change this vector to be perpendicular to what it was before.
    (Effectively rotates it 90 degrees in a clockwise direction around the z axis)

    Returns Vector3d

    Reference to this object for method chaining

  • Project this vector onto a vector of unit length.
    This is slightly more efficient than project when dealing with unit vectors.

    Parameters

    Returns Vector3d

    Reference to this object for method chaining

  • Rotate this vector (counter-clockwise) by the specified angle (in radians) around the z axis

    Parameters

    • angle: number

      The angle to rotate (in radians)

    • Optionalv: Vector2d

      an optional point to rotate around (on the same z axis)

    Returns Vector3d

    Reference to this object for method chaining

  • Multiply this vector values by the given scalar

    Parameters

    • x: number
    • Optionaly: number = x
    • Optionalz: number = 1

    Returns Vector3d

    Reference to this object for method chaining

  • set the Vector x and y properties to the given values

    Parameters

    • x: number
    • y: number
    • Optionalz: number

    Returns Vector3d

    Reference to this object for method chaining