Skip to content

ipygame.math

ipygame.math — Vector2 / Vector3 classes.

class Vector2()

2D vector compatible with pygame.math.Vector2.

def __init__(x=0.0, y=None)

def copy() -> "Vector2"

def length() -> float

def length_squared() -> float

def magnitude() -> float

def normalize() -> "Vector2"

def normalize_ip() -> None

def is_normalized() -> bool

def dot(other) -> float

def cross(other) -> float

def distance_to(other) -> float

def distance_squared_to(other) -> float

def angle_to(other) -> float

Angle in degrees from self to other.

def as_polar() -> tuple[float, float]

def from_polar(polar: tuple[float, float]) -> None

def rotate(angle: float) -> "Vector2"

Return rotated copy (angle in degrees).

def rotate_ip(angle: float) -> None

def rotate_rad(angle: float) -> "Vector2"

def rotate_rad_ip(angle: float) -> None

def reflect(normal) -> "Vector2"

def reflect_ip(normal) -> None

def lerp(other, t: float) -> "Vector2"

def slerp(other, t: float) -> "Vector2"

def move_towards(target, max_distance: float) -> "Vector2"

def move_towards_ip(target, max_distance: float) -> None

def clamp_magnitude(max_length: float, min_length: float = 0) -> "Vector2"

def clamp_magnitude_ip(max_length: float, min_length: float = 0) -> None

def update(*args) -> None

def epsilon_compare(other, epsilon: float) -> bool

class Vector3()

Minimal Vector3 stub — not fully implemented.

def __init__(x=0.0, y=0.0, z=0.0)