The x-coordinate of the vector.
The y-coordinate of the vector.
Clamps the length of the vector to a specified value. If the length of the vector is greater than the specified value, the vector is scaled down. If the length of the vector is less than or equal to the specified value, the vector remains unchanged.
The maximum length to clamp the vector to. Default value is 1.
A new vector with the clamped length.
Calculates the cross product of this vector and the given vector.
The vector to calculate the cross product with.
The cross product of the two vectors.
Calculates the Euclidean distance between this vector and the given vector.
The vector to calculate the distance to.
The Euclidean distance between the two vectors.
Calculates the squared distance between this vector and the given vector.
The vector to calculate the distance to.
The squared distance between this vector and the given vector.
Divides the vector by either another vector or a number. If the argument is a number, it divides each component of the vector by that number. If the argument is a vector, it divides the corresponding components of the vector by the components of the argument vector.
The vector or number to divide by.
A new vector resulting from the division.
Calculates the dot product between this vector and the given vector.
The vector to calculate the dot product with.
The dot product of the two vectors.
Checks if the current vector is within the range of the specified size.
The size vector to compare against.
true
if the current vector is within the range, false
otherwise.
Normalizes the vector to a specified length. If the vector's length is zero, a new vector with the specified length is returned.
The desired length of the normalized vector. Default is 1.
A new Vector instance representing the normalized vector.
Represents a 2D vector with x and y components.