Creates a new Vector2d instance.
The typed array containing the vector components
Gets the number of bytes per component in the underlying typed array.
The number of bytes per component
Gets the class name of this vector instance.
The constructor name of the class
Converts the vector to a GLSL vec2 string representation with float precision.
GLSL-compatible vec2 string
Converts the vector to a GLSL ivec2 string representation with integer precision.
GLSL-compatible ivec2 string
Converts the vector to a WGSL vec2f string representation with float precision.
WGSL-compatible vec2f string
Converts the vector to a WGSL vec2i string representation with integer precision.
WGSL-compatible vec2i string
Gets the X component of the vector.
The X component value
Gets the Y component of the vector.
The Y component value
StaticcompositionGets the composition type of this vector.
The composition type (Vec2)
Gets the component at the specified index.
The index (0 for x, 1 for y)
The component value at the specified index
Calculates the dot product with another vector.
The vector to calculate dot product with
The dot product result
Converts the vector to a flat array representation.
Array containing [x, y] components
Checks if this vector is a dummy (empty) vector.
True if the vector has no components, false otherwise
Checks if this vector is approximately equal to another vector within a tolerance.
The vector to compare with
The tolerance value (default: Number.EPSILON)
True if vectors are approximately equal, false otherwise
Checks if this vector is strictly equal to another vector (exact comparison).
The vector to compare with
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.
The ArrayBuffer to compare against
True if the same ArrayBuffer is used, false otherwise
Calculates the length (magnitude) of the vector.
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.
The squared length of the vector
Calculates the distance from this vector to another vector.
The target vector
The distance between the vectors
Converts the vector to a string representation.
String representation in the format "(x, y)"
Converts the vector to an approximate string representation with financial precision.
String representation with reduced decimal places
Gets the component value at the specified index. Alias for the at() method for convenience.
The index of the component to retrieve
The component value at the given index
Static_Adds two vectors component-wise (static version).
The left vector operand
The right vector operand
The typed array constructor
A new vector containing the sum
Static_Divides a vector by a scalar value (static version).
The vector to divide
The scalar value to divide by
The typed array constructor
A new vector containing the divided result
Static_Divides the left vector by the right vector component-wise (static version).
The left vector operand (dividend)
The right vector operand (divisor)
The typed array constructor
A new vector containing the component-wise division result
Static_Creates a dummy vector with no components.
The typed array constructor
A new dummy vector
Static_Creates a vector from individual x and y components.
The x component
The y component
The typed array constructor
A new vector instance
Static_Creates a vector from an array, taking the first 2 elements.
The array containing components
The typed array constructor
A new vector instance
Static_Creates a vector from a 2-element array.
The array containing [x, y] components
The typed array constructor
A new vector instance
Static_Creates a vector by copying components from another IVector2.
The source vector
The typed array constructor
A new vector instance
Static_Creates a vector by copying the first 2 components from a 3D vector.
The source 3D vector
The typed array constructor
A new vector instance
Static_Creates a vector by copying the first 2 components from a 4D vector.
The source 4D vector
The typed array constructor
A new vector instance
Static_Creates a vector from another IVector2 by sharing the underlying array.
The source vector
The typed array constructor
A new vector instance
Static_Multiplies a vector by a scalar value (static version).
The vector to multiply
The scalar value to multiply by
The typed array constructor
A new vector containing the scaled result
Static_Multiplies two vectors component-wise (static version).
The left vector operand
The right vector operand
The typed array constructor
A new vector containing the component-wise product
Static_Normalizes a vector to unit length (static version).
The vector to normalize
The typed array constructor
A new normalized vector
Static_Creates a one vector (1, 1).
The typed array constructor
A new one vector
Static_Subtracts the right vector from the left vector component-wise (static version).
The left vector operand
The right vector operand
The typed array constructor
A new vector containing the difference
Static_Creates a zero vector (0, 0).
The typed array constructor
A new zero vector
StaticaddStaticaddAdds two vectors component-wise and stores the result in the output vector.
The left vector operand
The right vector operand
The output vector to store the result
The output vector containing the sum
StaticangleStaticdivideStaticdivideDivides a vector by a scalar value and stores the result in the output vector.
The vector to divide
The scalar value to divide by
The output vector to store the result
The output vector containing the divided result
StaticdivideStaticdivideDivides the left vector by the right vector component-wise and stores the result in the output vector.
The left vector operand (dividend)
The right vector operand (divisor)
The output vector to store the result
The output vector containing the component-wise division result
StaticdotStaticdummyStaticfromCreates a vector from an ArrayBuffer.
The ArrayBuffer containing the vector data
A new Vector2d instance
StaticfromCreates a vector from individual x and y components.
The x component
The y component
A new Vector2d instance
StaticfromCreates a vector from an array, taking the first 2 elements.
The array containing components
A new Vector2d instance
StaticfromStaticfromCreates a vector from a Float64Array.
The Float64Array containing the vector data
A new Vector2d instance
StaticlengthStaticlengthCalculates the squared length of a vector (static version). This is more efficient than calculating the actual length when only comparison is needed.
The vector to calculate squared length for
The squared length of the vector
StaticmultiplyStaticmultiplyMultiplies a vector by a scalar value and stores the result in the output vector.
The vector to multiply
The scalar value to multiply by
The output vector to store the result
The output vector containing the scaled result
StaticmultiplyStaticmultiplyMultiplies two vectors component-wise and stores the result in the output vector.
The left vector operand
The right vector operand
The output vector to store the result
The output vector containing the component-wise product
StaticnormalizeStaticoneStaticsubtractStaticsubtractSubtracts the right vector from the left vector component-wise and stores the result in the output vector.
The left vector operand
The right vector operand
The output vector to store the result
The output vector containing the difference
Staticzero
Immutable 2D vector class with 64-bit float components. This class provides high-precision vector operations for applications requiring double precision. All operations return new vector instances, preserving immutability.