Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 882 Bytes

util.md

File metadata and controls

46 lines (34 loc) · 882 Bytes

util

import tank_wars_iit.util

Contains three utility functions that may be of use to you.

distance

distance(
    x1: float,
    y1: float,
    x2: float,
    y2: float
) -> float

Calculates the Euclidean distance between two points (x1, y1) and (x2, y2).

angle_to

angle_to(
    x1: float,
    y1: float,
    x2: float,
    y2: float
) -> float

Calculates the angle, in radians, for an object located at (x1, y1) to be facing an object located at (x2, y2).

angle_difference

angle_difference(
    angle1: float,
    angle2: float
) -> float

Returns the angle, in radians, that should be added to angle1 (in radians) to direct it towards angle2 (also in radians).

Note: This value is signed, so if you want the absolute angle difference between two angles, be sure to apply abs!