Vector2¶
Vector2
class does handle two dimensional vector operations required
by the colliders. It’s not very efficient and using this class in you own
code is not advised.
-
class
pygame_colliders.
Vector2
(x: Union[float, int], y: Union[float, int])[source]¶ A class to handle 2 dimensional vector operations.
Example of usage:
vec_a = Vector2(12.1, 23.4) vec_b = Vector2(2.5, 11.73) vec_c = vec_b - vec_a
Parameters: - x (float, int) – x component of the vector
- y (float, int) – y component of the vector
-
normalize
() → pygame_colliders.vector.Vector2[source]¶ Normalizes vector (makes it as a unit vector) :return: Normalized vector :rtype: Vector2
-
normalize_ip
() → pygame_colliders.vector.Vector2[source]¶ Normalizes vector (makes it as a unit vector) in-place modifying this vector itself.
Returns: self Return type: Vector2
-
x
¶ Return x component of the vector.
Getter: a component value. Setter: a new component value. Type: float, int
-
xy
¶ Return x and y component of the vector as a tuple.
Getter: a component value as a tuple. Setter: a new component value. Type: tuple(float/int, float/int)
-
y
¶ Return y component of the vector.
Getter: a component value. Setter: a new component value. Type: float, int