19 lines
313 B
C
19 lines
313 B
C
#include "tools.h"
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
sign(int x)
|
|
{
|
|
return (x > 0) - (x < 0); /* from jtmm2 */
|
|
}
|
|
|
|
int
|
|
length(int x1, int y1, int x2, int y2)
|
|
{
|
|
const int dist_x = abs(x1 - x2);
|
|
const int dist_y = abs(y1 - y1);
|
|
const float dist = sqrt(dist_x * dist_x + dist_y * dist_y);
|
|
return dist;
|
|
}
|