μMath
    Preparing search index...

    Interface Vector

    A quantity with magnitude and direction.

    interface Vector {
        add: (vector: Readonly<Vector4Like>) => VectorLike;
        ceil: () => VectorLike;
        clone: () => VectorLike;
        copy: (vector: Readonly<Vector4Like>) => this;
        distance: (vector: Readonly<Vector4Like>) => number;
        divide: (vector: Readonly<Vector4Like>) => VectorLike;
        dot: (vector: Readonly<Vector4Like>) => number;
        equals: (vector: Readonly<Vector4Like>) => boolean;
        exactEquals: (vector: Readonly<Vector4Like>) => boolean;
        floor: () => VectorLike;
        invert: () => VectorLike;
        lerp: (vector: Readonly<Vector4Like>, t: number) => VectorLike;
        max: (vector: Readonly<Vector4Like>) => VectorLike;
        min: (vector: Readonly<Vector4Like>) => VectorLike;
        multiply: (vector: Readonly<Vector4Like>) => VectorLike;
        negate: () => VectorLike;
        normalize: () => VectorLike;
        pow: (exponent: number) => VectorLike;
        random: (magnitude: number) => this;
        round: () => VectorLike;
        scale: (scalar: number) => VectorLike;
        scaleAndAdd: (vector: Readonly<Vector4Like>, scalar: number) => VectorLike;
        squaredDistance: (vector: Readonly<Vector4Like>) => number;
        subtract: (vector: Readonly<Vector4Like>) => VectorLike;
        zero: () => this;
        get magnitude(): number;
        get squaredMagnitude(): number;
        [key: number]: number;
    }

    Hierarchy (View Summary)

    Implemented by

    Indexable

    • [key: number]: number
    Index

    Properties

    add: (vector: Readonly<Vector4Like>) => VectorLike

    Add two vectors of the same size.

    Type Declaration

    ceil: () => VectorLike

    Round up the components of this vector.

    Type Declaration

    clone: () => VectorLike

    Create a copy of this vector.

    Type Declaration

    copy: (vector: Readonly<Vector4Like>) => this

    Copy the values of another vector into this one.

    Type Declaration

    distance: (vector: Readonly<Vector4Like>) => number

    Calculate the Euclidean distance between this vector and another.

    Type Declaration

    divide: (vector: Readonly<Vector4Like>) => VectorLike

    Divide this vector by another.

    Type Declaration

    dot: (vector: Readonly<Vector4Like>) => number

    Calculate the dot product of this and another vector.

    Type Declaration

    equals: (vector: Readonly<Vector4Like>) => boolean

    Determine whether this vector is roughly equivalent to another.

    Type Declaration

    exactEquals: (vector: Readonly<Vector4Like>) => boolean

    Determine whether this vector is exactly equivalent to another.

    Type Declaration

    floor: () => VectorLike

    Round down the components of this vector.

    Type Declaration

    invert: () => VectorLike

    Calculate the multiplicative inverse of the components of this vector.

    Type Declaration

    lerp: (vector: Readonly<Vector4Like>, t: number) => VectorLike

    Perform a linear interpolation between this and another vector.

    Type Declaration

    max: (vector: Readonly<Vector4Like>) => VectorLike

    Return the maximum of this and another vector.

    Type Declaration

    min: (vector: Readonly<Vector4Like>) => VectorLike

    Return the minimum of this and another vector.

    Type Declaration

    multiply: (vector: Readonly<Vector4Like>) => VectorLike

    Multiply this vector by another.

    Type Declaration

    negate: () => VectorLike

    Negate this vector.

    Type Declaration

    normalize: () => VectorLike

    Normalize this vector.

    Type Declaration

    pow: (exponent: number) => VectorLike

    Raise each component of this vector to the given power.

    Type Declaration

      • (exponent: number): VectorLike
      • Parameters

        • exponent: number

          The exponent (power) to raise each component to.

        Returns VectorLike

        The power (result of the exponentiation).

    random: (magnitude: number) => this

    Set this vector to a random value with the given magnitude.

    Type Declaration

      • (magnitude: number): this
      • Parameters

        • magnitude: number

          The magnitude.

        Returns this

        This vector.

    round: () => VectorLike

    Round the components of this vector.

    Type Declaration

    scale: (scalar: number) => VectorLike

    Scale this vector by a scalar.

    Type Declaration

      • (scalar: number): VectorLike
      • Parameters

        • scalar: number

          The scalar.

        Returns VectorLike

        The scaled vector.

    scaleAndAdd: (vector: Readonly<Vector4Like>, scalar: number) => VectorLike

    Add another vector to this one after scaling the other by a scalar.

    Type Declaration

    squaredDistance: (vector: Readonly<Vector4Like>) => number

    Calculate the squared Euclidean distance between this vector and another.

    Type Declaration

    subtract: (vector: Readonly<Vector4Like>) => VectorLike

    Subtract another vector from this one.

    Type Declaration

    zero: () => this

    Set this to the zero vector.

    Type Declaration

      • (): this
      • Returns this

        This vector.

    Accessors

    • get squaredMagnitude(): number

      Get the squared magnitude (length) of this vector.

      Returns number