ChainableThe Vector Class constructor
The x and y coordinates
(getter) Vector area.
(getter) Returns the basic array representation of this vector.
(getter/setter) Vector slope.
ChainableAdds a scalar to the vector, modifying both the x and y
The scalar to add to the vector
Returns itself, modified
ChainableClones the vector and adds the scalar to it instead
The scalar to add to the vector
Returns the clone of itself, modified
Calculates the cross product between this and the supplied vector.
The vector object against which to calculate the cross product
The cross product of the two vectors
Calculates the distance between this and the supplied vector
The vector to calculate the distance from
The distance between this and the supplied vector
Calculates the distance on the X axis between this and the supplied vector
The vector to calculate the distance from
The distance, along the x axis, between this and the supplied vector
Calculated the distance on the Y axis between this and the supplied vector
The vector to calculate the distance from
The distance, along the y axis, between this and the supplied vector
ChainableDivides the vector by a scalar.
The scalar to divide both x and y by
Returns itself, modified
ChainableClones the vector and divides it by the provided scalar.
The scalar to divide both x and y by
Returns the clone of itself, modified
Calculates the dot product between this and a supplied vectorT
The vector object against which to calculate the dot product
The dot product of the two vectors
ChainableMultiplies the vector by a scalar.
The scalar to multiply both x and y by
Returns itself, modified
ChainableClones the vector and multiplies it by the provided scalar.
The scalar to multiply both x and y by
Returns the clone of itself, modified
ChainableResets the vector coordinates
The x and y coordinates
ChainableRotates a vecor by a given amount, provided in radians.
The angle, in radians, to rotate the vector by
Returns itself, modified
ChainableRotates a vecor by a given amount, provided in degrees. Converts the degree value to radians and runs the rotaet method.
The angle, in degrees, to rotate the vector by
Returns itself, modified
ChainableClones the vector and rotates it by the supplied degree value
The angle, in degrees, to rotate the vector by
Returns the clone of itself, modified
ChainableClones the vector and rotates it by the supplied radian value
The angle, in radians, to rotate the vector by
Returns the clone of itself, modified
ChainableRotates a vector to a specific angle
The angle, in radians, to rotate the vector to
Returns itself, modified
ChainableRotates a vecor to a given amount, provided in degrees. Converts the degree value to radians and runs the rotateTo method.
The angle, in degrees, to rotate the vector to
Returns itself, modified
ChainableClones the vector and rotates it to the supplied degree value
The angle, in degrees, to rotate the vector to
Returns the clone of itself, modified
ChainableClones the vector and rotates it to the supplied radian value
The angle, in radians, to rotate the vector to
Returns the clone of itself, modified
ChainableSubtracts a scalar from the vector, modifying both the x and y
The scalar to subtract from the vector
Returns itself, modified
ChainableClones the vector and subtracts the scalar from it instead
The scalar to add to the vector
Returns the clone of itself, modified
StaticgetStaticinterpolateStaticlerp
A basic 2D Vector class that provides simple algebraic functionality in the form of 2D Vectors.
We use Getters/setters for both principle properties (x & y) as well as virtual properties (rotation, length etc.).
Vec2
Author
Liam Egan liam@wethecollective.com
Version
1.0.0
Created
Jan 07, 2020