Returns the scalar product of the vector with rhs
Returns the scalar product of the vector with rhs
Returns the scalar product of the vector with rhs
Returns the scalar product of the vector with rhs
Returns the scalar product of the vector with rhs
Returns the scalar product of the vector with rhs
Returns the sum of the vector and rhs
.
Returns the sum of the vector and rhs
.
Returns the difference of the vector and rhs
.
Returns the difference of the vector and rhs
.
Returns the vector divided by the scalar rhs
Returns the vector divided by the scalar rhs
The x coordinate.
The y coordinate.
Returns the dot product of the vector with rhs
.
Returns the dot product of the vector with rhs
.
Returns true if none of the components of the vectors are +-infinity or NaN, otherwise false.
Returns true if none of the components of the vectors are +-infinity or NaN, otherwise false.
Returns the magnitude of the vector
Returns the magnitude of the vector
Returns the square of the magnitude of the vector
Returns the square of the magnitude of the vector
Returns the sum of this vector and rhs
.
Returns the sum of this vector and rhs
.
Returns a new vector with the same direction and whose magnitude is equal to 1
Returns a new vector with the same direction and whose magnitude is equal to 1
Returns the angle in radians of the vector and the x-axis.
Returns the angle in radians of the vector and the x-axis. This value is always between 0 and 2 * Pi.
Returns the sum of this vector and rhs
.
Returns the sum of this vector and rhs
.
Returns the vector rotated by an angle of angle
radians.
Returns the vector rotated by an angle of angle
radians.
Returns the scalar product of the vector with rhs
Returns the scalar product of the vector with rhs
Returns the additive inverse of the vector.
Returns the additive inverse of the vector.
Returns the x-coordinate
Returns the x-coordinate
Returns the y-coordinate
Returns the y-coordinate
Immutable 2D Vector.
There are two ways to create vectors:
Vector2(x, y)
will create a vector with components x and y andVector2(a)
will create a unit vector rotated by an angle ofa
radians. (In the JavaScript version, create vectors usingGame.vector2(x, y)
.) Addition, subtraction, multiplication and division work as expected:If you are using Java, you can use the methods
plus
,times
andminus
in place of the symbolic operators.The x coordinate.
The y coordinate.