PokéRogue
    Preparing search index...

    A four-component vector (x, y, z, w) for use in 3D mathematics and transformations.

    Vector4 is commonly used to represent homogeneous coordinates in 3D space, where the w component acts as a scaling factor, making it compatible with 4x4 matrix multiplication via Matrix4. It is also used to represent RGBA color values, quaternion components, and any other quantity that requires four independent scalar values. The class supports the standard vector operations you would expect: addition, subtraction, scaling, normalization, dot product, linear interpolation, and transformation by both Matrix4 and Quaternion objects.

    Index
    • Parameters

      • Optionalx: number

        The x component.

      • Optionaly: number

        The y component.

      • Optionalz: number

        The z component.

      • Optionalw: number

        The w component.

      Returns Vector4

    w: number

    The w component of this Vector.

    x: number

    The x component of this Vector.

    y: number

    The y component of this Vector.

    z: number

    The z component of this Vector.

    • Add a given Vector to this Vector. Addition is component-wise.

      Parameters

      Returns Vector4

      This Vector4.

    • Make a clone of this Vector4.undefined

      Returns Vector4

      A clone of this Vector4.

    • Copy the components of a given Vector into this Vector.

      Parameters

      • src: Vector4

        The Vector to copy the components from.

      Returns Vector4

      This Vector4.

    • Calculate the distance between this Vector and the given Vector.

      Parameters

      Returns number

      The distance from this Vector to the given Vector.

    • Calculate the distance between this Vector and the given Vector, squared.

      Parameters

      Returns number

      The distance from this Vector to the given Vector, squared.

    • Perform a component-wise division between this Vector and the given Vector.

      Divides this Vector by the given Vector.

      Parameters

      Returns Vector4

      This Vector4.

    • Calculate the dot product of this Vector and the given Vector.

      Parameters

      • v: Vector4

        The Vector4 to dot product with this Vector4.

      Returns number

      The dot product of this Vector and the given Vector.

    • Check whether this Vector is equal to a given Vector.

      Performs a strict equality check against each Vector's components.

      Parameters

      • v: Vector4

        The vector to check equality with.

      Returns boolean

      A boolean indicating whether the two Vectors are equal or not.

    • Calculate the length (or magnitude) of this Vector.undefined

      Returns number

      The length of this Vector.

    • Calculate the length of this Vector squared.undefined

      Returns number

      The length of this Vector, squared.

    • Linearly interpolate between this Vector and the given Vector.

      Interpolates this Vector towards the given Vector.

      Parameters

      • v: Vector4

        The Vector4 to interpolate towards.

      • Optionalt: number

        The interpolation percentage, between 0 and 1. Default 0.

      Returns Vector4

      This Vector4.

    • Perform a component-wise multiplication between this Vector and the given Vector.

      Multiplies this Vector by the given Vector.

      Parameters

      Returns Vector4

      This Vector4.

    • Negate the x, y, z and w components of this Vector.undefined

      Returns Vector4

      This Vector4.

    • Normalize this Vector.

      Makes the vector a unit length vector (magnitude of 1) in the same direction.undefined

      Returns Vector4

      This Vector4.

    • Make this Vector the zero vector (0, 0, 0, 0).undefined

      Returns Vector4

      This Vector4.

    • Scale this Vector by the given value.

      Parameters

      • scale: number

        The value to scale this Vector by.

      Returns Vector4

      This Vector4.

    • Set the x, y, z and w components of the this Vector to the given x, y, z and w values.

      Parameters

      • x: number | object

        The x value to set for this Vector, or an object containing x, y, z and w components.

      • y: number

        The y value to set for this Vector.

      • z: number

        The z value to set for this Vector.

      • w: number

        The w value to set for this Vector.

      Returns Vector4

      This Vector4.

    • Subtract the given Vector from this Vector. Subtraction is component-wise.

      Parameters

      Returns Vector4

      This Vector4.

    • Transform this Vector with the given Matrix.

      Parameters

      • mat: Matrix4

        The Matrix4 to transform this Vector4 with.

      Returns Vector4

      This Vector4.

    • Transform this Vector with the given Quaternion.

      Parameters

      • q: Quaternion

        The Quaternion to transform this Vector with.

      Returns Vector4

      This Vector4.