The Vector2 class is used to represent a 2D vector or point.
The x (or horizontal) coordinate of the vector.
The y (or vertical) coordinate of the vector.
Set the value of a vector. This function is an alternative to setting the x and y values individually.
x (float): the x value you wish to set y (float): the y value you wish to set Return value: noneSet the value of a vector by copying an existing vector.
vec (Vector2): another Vector2 object whose value you wish to copy Return value: noneComputes the dot product of this vector and a second one.
vec (Vector2): a Vector2 object Return value (float): the dot product of the calling vector and the passed in argumentComputes the magnitude of a vector.
Return value (float): the vector's magnitude (length)Computes the squared magnitude of a vector.
Return value (float): the vector's squared magnitudeReturns a normalized copy of the vector. The vector object is unchanged, and normalized copy is returned. The normalized vector will have a length of 1.0.
Return value (Vector2): a normalized copy of the original vectorNormalizes a vector. The vector is normalized (adjusted so that it points in the same direction, but has a length of one) in place, adjusting the x and y values as necessary.
Return value: noneReturns a vector that points 90 degrees away from the orignal vector.
Return value (Vector2): a new vector, pointing 90 degrees away from the originalRotates the vector by the specified angle.
angle (float): the angle (in radians) to rotate the vector Return value: noneAdds two vectors and returns the result as a new vector. This operator makes it possible to add two vectors as if they were regular numbers. Example: c = a + b.
vec (Vector2): a vector to add to the first one Return value (Vector2): the sum of two vectorsSubtracts one vector from another and returns the result as a new vector. This operator makes it possible to subtract vectors as if they were regular numbers. Example: c = a - b.
vec (Vector2): a vector to subtract from the first one Return value (Vector2): the difference of two vectorsMultiplies a vector by a number, returning the result as a new vector. Example: v2 = v * 3.
num (float): a number to multiply the vector by Return value (Vector2): the original vector, multiplied by the number "num"Divides a vector by a number, returning the result as a new vector. Example: v2 = v / 3.
num (float): a number to divide the vector by Return value (Vector2): the original vector, divided by the number "num"