19 lines
321 B
C
19 lines
321 B
C
#include "tools.h"
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
|
|
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;
|
|
}
|