Stores and manipulates a fourdimensional vector comprised of the components x, y, z and w.

Authors

Jonas Plotzky, HFU, 2023

Hierarchy (view full)

Implements

Constructors

Properties

w: number
x: number
y: number
z: number

Accessors

  • get magnitudeSquared(): number
  • The squared magnitude (length) of the vector. Faster for simple proximity evaluation.

    Returns number

  • get type(): string
  • Retrieves the type of this mutable subclass as the name of the runtime class

    Returns string

    The type of the mutable

Methods

  • Calls a defined callback function on each component of the vector and assigns the result to the component. Similar to Vector4.map but mutates this vector instead of creating a new one.

    Parameters

    • _function: ((_value, _index, _component, _vector) => number)
        • (_value, _index, _component, _vector): number
        • Parameters

          • _value: number
          • _index: number
          • _component: "x" | "y" | "z" | "w"
          • _vector: Vector4

          Returns number

    Returns Vector4

    A reference to this vector.

  • Returns true if this vector is equal to the given vector within the given tolerance.

    Parameters

    • _compare: Vector4
    • _tolerance: number = Number.EPSILON

    Returns boolean

  • Set the values of this object from the given array starting at the given offset.

    Parameters

    • _array: ArrayLike<number>

      The array to read the values from.

    • _offset: number = 0

      (optional) The offset to start reading from.

    Returns this

    A reference to this instance.

  • Collect applicable attributes of the instance and copies of their values in a Mutator-object. By default, a mutator cannot be extended, since extensions are not available in the object the mutator belongs to. A mutator may be reduced by the descendants of Mutable to contain only the properties needed.

    Parameters

    • _extendable: boolean = false

    Returns Mutator

  • Calls a defined callback function on each component of the vector, and returns a new vector that contains the results. Similar to Array.map.

    Parameters

    • _function: ((_value, _index, _component, _vector) => number)
        • (_value, _index, _component, _vector): number
        • Parameters

          • _value: number
          • _index: number
          • _component: "x" | "y" | "z" | "w"
          • _vector: Vector4

          Returns number

    • _out: Vector4 = ...

      Optional vector to store the result in.

    Returns Vector4

  • Updates the attribute values of the instance according to the state of the mutator. The mutation may be restricted to a subset of the mutator and the event dispatching suppressed. Uses mutateBase, but can be overwritten in subclasses

    Parameters

    Returns void

  • Copy the values of this object into the given array starting at the given offset. Creates a new array if none is provided.

    Type Parameters

    • T extends {
          [n: number]: number;
      }

    Parameters

    • _out: T = ...

      (optional) The receiving array.

    • _offset: number = 0

      (optional) The offset to start writing to.

    Returns T

    _out or a new array if none is provided.

  • Creates and returns a vector which is a copy of the given vector scaled to the given length.

    Parameters

    • _vector: Vector4
    • _length: number = 1
    • _out: Vector4 = ...

      Optional vector to store the result in.

    Returns Vector4