blob: d412b41d34411f9116345ed5bdd40fb1cc6b8c3e (
plain)
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
|
#ifndef _CIRCLE_H
#define _CIRCLE_H
#include "point.h"
// Billards and pockets are both circles
// The collison detection code likes to deal with circles, not billards and pockets
class circle : public point {
public:
circle(double x, double y, double r) : point(x, y) { _radius = r; }
~circle() {}
// Accessors
double radius() { return _radius; }
void setRadius(double radius) { _radius = radius; }
// Returns true if we intersect the other circle
double intersects(const circle &other_circle) { return (distance(other_circle) - other_circle._radius) <= _radius; }
// Returns the distance from the edge of this circle to the edge of the other
double edgeDistance(const circle &other_circle) { return distance(other_circle) - _radius - other_circle._radius; }
protected:
double _radius;
};
#endif
|