summaryrefslogtreecommitdiffstats
path: root/geometry.cpp
blob: 2bdad8c54f4223855be3fb46dca25702280318a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "balls.h"

Point
ptAddVec(Point p, Vector v) {
	p.x += v.x;
	p.y += v.y;
	return p;
}

Point
Pt(double x, double y) {
	Point p = {x, y};
	return p;
}

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

Point
randPtInRect(Rectangle r) {
	return Pt(randDouble(r.min.x, r.max.x), randDouble(r.min.y, r.max.y));
}