#include "tools.h" #include #include int sign(int x) { return (x > 0) - (x < 0); /* from jtmm2 */ } int length(struct Vec2 *a, struct Vec2 *b) { const int dist_x = abs(a->x - b->x); const int dist_y = abs(a->y - b->y); const float dist = sqrt(dist_x * dist_x + dist_y * dist_y); return dist; }