rhodonite
    Preparing search index...

    Class MutableVector2_<T>Internal

    Base class for mutable 2D vectors with generic typed array support. Provides mutable operations for vector manipulation that modify the vector in place.

    Type Parameters

    Hierarchy (View Summary)

    Index
    _v: TypedArray = ...

    Internal typed array storage for vector components

    • get bytesPerComponent(): number

      Gets the number of bytes per component in the underlying typed array.

      Returns number

      The number of bytes per element

    • get className(): string

      Gets the class name of this vector instance.

      Returns string

      The constructor name of the class

    • get glslStrAsFloat(): string

      Converts the vector to a GLSL vec2 string representation with float precision.

      Returns string

      GLSL-compatible vec2 string

    • get glslStrAsInt(): string

      Converts the vector to a GLSL ivec2 string representation with integer precision.

      Returns string

      GLSL-compatible ivec2 string

    • get glslStrAsUint(): string

      Gets the GLSL string representation of the vector as unsigned integer values.

      Returns string

      GLSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get w(): number

      Gets the w component of the vector (always 1 for homogeneous coordinates).

      Returns number

      Always returns 1

    • get wgslStrAsFloat(): string

      Converts the vector to a WGSL vec2f string representation with float precision.

      Returns string

      WGSL-compatible vec2f string

    • get wgslStrAsInt(): string

      Converts the vector to a WGSL vec2i string representation with integer precision.

      Returns string

      WGSL-compatible vec2i string

    • get wgslStrAsUint(): string

      Gets the WGSL string representation of the vector as unsigned integer values.

      Returns string

      WGSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get x(): number

      Gets the x component of the vector.

      Returns number

      The x component value

    • set x(x: number): void

      Sets the x component of the vector.

      Parameters

      • x: number

        The new x component value

      Returns void

    • get y(): number

      Gets the y component of the vector.

      Returns number

      The y component value

    • set y(y: number): void

      Sets the y component of the vector.

      Parameters

      • y: number

        The new y component value

      Returns void

    • get z(): number

      Gets the z component of the vector (always 0 for 2D vectors).

      Returns number

      Always returns 0

    • get compositionType(): CompositionTypeClass<"VEC2">

      Gets the composition type of this vector.

      Returns CompositionTypeClass<"VEC2">

      The composition type (Vec2)

    • Adds another vector to this vector (modifies this vector in place).

      Parameters

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Gets the component at the specified index.

      Parameters

      • i: number

        The index (0 for x, 1 for y)

      Returns number

      The component value at the specified index

    • Creates a clone of this vector.

      Returns any

      A new vector with the same components

    • Copies components from another vector to this vector.

      Parameters

      • vec: IVector2

        The source vector to copy from

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Divides this vector by a scalar value (modifies this vector in place). If the divisor is zero, sets components to 0 and logs an error.

      Parameters

      • value: number

        The scalar value to divide by

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Divides this vector component-wise by another vector (modifies this vector in place). If any component of the divisor is zero, sets that component to 0 and logs an error.

      Parameters

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Calculates the dot product with another vector.

      Parameters

      • vec: IVector2

        The vector to calculate dot product with

      Returns number

      The dot product result

    • Converts the vector to a flat array representation.

      Returns number[]

      Array containing [x, y] components

    • Checks if this vector is a dummy (empty) vector.

      Returns boolean

      True if the vector has no components, false otherwise

    • Checks if this vector is approximately equal to another vector within a tolerance.

      Parameters

      • vec: IVector2

        The vector to compare with

      • delta: number = Number.EPSILON

        The tolerance value (default: Number.EPSILON)

      Returns boolean

      True if vectors are approximately equal, false otherwise

    • Checks if this vector is strictly equal to another vector (exact comparison).

      Parameters

      • vec: IVector2

        The vector to compare with

      Returns boolean

      True if vectors are exactly equal, false otherwise

    • Checks if the internal storage shares the same ArrayBuffer as the provided one. Useful for determining if vectors share underlying memory.

      Parameters

      • arrayBuffer: ArrayBuffer

        The ArrayBuffer to compare against

      Returns boolean

      True if the same ArrayBuffer is used, false otherwise

    • Calculates the length (magnitude) of the vector.

      Returns number

      The length of the vector

    • Calculates the squared length of the vector. This is more efficient than calculating the actual length when only comparison is needed.

      Returns number

      The squared length of the vector

    • Calculates the distance from this vector to another vector.

      Parameters

      Returns number

      The distance between the vectors

    • Multiplies this vector by a scalar value (modifies this vector in place).

      Parameters

      • value: number

        The scalar value to multiply by

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Multiplies this vector component-wise by another vector (modifies this vector in place).

      Parameters

      • vec: IVector2

        The vector to multiply by

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Normalizes this vector to unit length (modifies the vector in place). If the vector has zero length, the result is undefined.

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Sets both components to one.

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Returns the raw typed array containing the vector components.

      Returns TypedArray

      The underlying typed array

    • Sets the value at the specified index.

      Parameters

      • i: number

        The component index (0 for x, 1 for y)

      • value: number

        The value to set

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Sets both x and y components of the vector.

      Parameters

      • x: number

        The x component value

      • y: number

        The y component value

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Subtracts another vector from this vector (modifies this vector in place).

      Parameters

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Converts the vector to a string representation.

      Returns string

      String representation in the format "(x, y)"

    • Converts the vector to an approximate string representation with financial precision.

      Returns string

      String representation with reduced decimal places

    • Gets the component value at the specified index. Alias for the at() method for convenience.

      Parameters

      • i: number

        The index of the component to retrieve

      Returns number

      The component value at the given index

    • Sets both components to zero.

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Calculates the angle between two vectors in radians.

      Parameters

      Returns number

      The angle between the vectors in radians

    • Calculates the dot product of two vectors (static version).

      Parameters

      • l_vec: IVector2

        The left vector operand

      • r_vec: IVector2

        The right vector operand

      Returns number

      The dot product of the two vectors

    • Calculates the distance between two vectors.

      Parameters

      Returns number

      The distance between the vectors

    • Calculates the squared length of a vector (static version). This is more efficient than calculating the actual length when only comparison is needed.

      Parameters

      • vec: IVector2

        The vector to calculate squared length for

      Returns number

      The squared length of the vector