Math related functions
from_polar(angle: float, radius: float) → Vec2from_polar(angle: float, radius: float) → Vec2Convert polar coordinates to a Cartesian vector.
Args
angle : The angle in radians.radius : The radius/distance from origin.Returns
Vec2 : The equivalent Cartesian vector.
remap(in_min: float, in_max: float, out_min: float, out_max: float, value: float) → floatremap(in_min: float, in_max: float, out_min: float, out_max: float, value: float) → floatRemap a value from one range to another.
Args
in_min : Input range minimum.in_max : Input range maximum.out_min : Output range minimum.out_max : Output range maximum.value : The value to remap.Returns
float : The remapped value in the output range.
Raises
ValueError : If in_min equals in_max.dot(a: Vec2, b: Vec2) → floatdot(a: Vec2, b: Vec2) → floatCalculate the dot product of two vectors.
Args
a : The first vector.b : The second vector.Returns
float : The dot product (a.x * b.x + a.y * b.y).
cross(a: Vec2, b: Vec2) → floatcross(a: Vec2, b: Vec2) → floatCalculate the 2D cross product of two vectors. (a.x * b.y - a.y * b.x)
Args
a : The first vector.b : The second vector.Returns
float : The 2D cross product.
angle_between(a: Vec2, b: Vec2) → floatangle_between(a: Vec2, b: Vec2) → floatCalculate the angle between two vectors.
Args
a : The first vector.b : The second vector.Returns
float : The angle between the vectors in radians [0, π].
move_toward(current: float, target: float, delta: float) → floatmove_toward(current: float, target: float, delta: float) → floatMove a value toward a target by a maximum delta.
Args
current : The current value.target : The target value.delta : The maximum amount to move toward the target.Returns
float : The new value after moving toward the target.