rhodonite
    Preparing search index...

    Interface IVector2

    Interface for immutable 2D vectors. Provides operations specific to 2-component vectors.

    interface IVector2 {
        _v: TypedArray;
        bytesPerComponent: number;
        className: string;
        glslStrAsFloat: string;
        glslStrAsInt: string;
        glslStrAsUint: string;
        wgslStrAsFloat: string;
        wgslStrAsInt: string;
        wgslStrAsUint: string;
        x: number;
        y: number;
        at(i: number): number;
        clone(): IVector2;
        dot(vec: IVector2): number;
        flattenAsArray(): number[];
        isDummy(): boolean;
        isEqual(vec: IVector2, delta?: number): boolean;
        isStrictEqual(vec: IVector2): boolean;
        isTheSourceSame(arrayBuffer: ArrayBuffer): boolean;
        length(): number;
        lengthSquared(): number;
        lengthTo(vec: IVector2): number;
        toString(): string;
        toStringApproximately(): string;
        v(i: number): number;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    The underlying typed array containing vector components

    bytesPerComponent: number

    Number of bytes per component in the underlying array

    className: string

    The class name identifier

    glslStrAsFloat: string

    GLSL string representation for float type

    glslStrAsInt: string

    GLSL string representation for integer type

    glslStrAsUint: string

    GLSL string representation for unsigned integer type

    wgslStrAsFloat: string

    WGSL string representation for float type

    wgslStrAsInt: string

    WGSL string representation for integer type

    wgslStrAsUint: string

    WGSL string representation for unsigned integer type

    x: number

    The x component

    y: number

    The y component

    • Gets component at index.

      Parameters

      • i: number

        Component index (0=x, 1=y)

      Returns number

      Component value

    • Creates a copy of this vector.

      Returns IVector2

      New Vector2 instance

    • Calculates dot product with another Vector2.

      Parameters

      Returns number

      Dot product

    • Converts the vector to a flat array.

      Returns number[]

      Array containing [x, y]

    • Checks if this is a dummy vector.

      Returns boolean

      True if dummy

    • Checks equality with another Vector2 within tolerance.

      Parameters

      • vec: IVector2

        Vector to compare with

      • Optionaldelta: number

        Optional tolerance

      Returns boolean

      True if approximately equal

    • Checks strict equality with another Vector2.

      Parameters

      Returns boolean

      True if exactly equal

    • Checks if this vector shares the same source array buffer.

      Parameters

      • arrayBuffer: ArrayBuffer

        The array buffer to check

      Returns boolean

      True if using the same source buffer

    • Calculates vector length.

      Returns number

      Vector magnitude

    • Calculates squared length.

      Returns number

      Squared magnitude

    • Calculates distance to another Vector2.

      Parameters

      Returns number

      Distance

    • Returns a string representation of the vector.

      Returns string

      String representation

    • Returns an approximate string representation with rounded values.

      Returns string

      Approximate string representation

    • Gets the component value at the specified index (alias for at).

      Parameters

      • i: number

        The component index

      Returns number

      The component value