summaryrefslogtreecommitdiffstats
path: root/geo.c
blob: 84c73cf7b3d069c6c69c6212eecf74236e33be70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "balls.h"

int
isCollision(float2 p1, float r1, float2 p2, float r2) {
	float2 dist;
	float rhs;

	dist = p1 - p2;
	rhs = r1 + r2;
	return (dist[0]*dist[0] + dist[1]*dist[1]) <= rhs*rhs;
}

Rectangle
insetRect(Rectangle r, float n) {
	r.min += n;
	r.max -= n;
	return r;
}