forked from sixthgear/quadtreeterrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshapes.py
35 lines (30 loc) · 944 Bytes
/
shapes.py
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
29
30
31
32
33
34
35
class Point(object):
__slots__ = ['x', 'y']
def __init__(self, x=0.0, y=0.0):
self.x = float(x)
self.y = float(y)
class AABB(object):
__slots__ = ['x', 'y', 'width', 'height']
def __init__(self, x, y, width, height):
self.x = float(x)
self.y = float(y)
self.width = float(width)
self.height = float(height)
@property
def x2(self): return self.x + self.width
@property
def y2(self): return self.y + self.height
@property
def corners(self):
return [
self.x, self.y,
self.x, self.y + self.height,
self.x + self.width, self.y + self.height,
self.x + self.width, self.y,
]
class Circle(object):
__slots__ = ['x', 'y', 'radius']
def __init__(self, x, y, radius):
self.x = x
self.y = y
self.radius = radius