-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbbox.py
32 lines (24 loc) · 892 Bytes
/
bbox.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
class BBox(object):
def __init__(self, coords):
self.xmin = self.xmax = coords["X"]
self.ymin = self.ymax = coords["Y"]
self.zmin = self.zmax = coords["Z"]
def dx(self):
return self.xmax - self.xmin
def dy(self):
return self.ymax - self.ymin
def dz(self):
return self.zmax - self.zmin
def cx(self):
return (self.xmax + self.xmin)/2
def cy(self):
return (self.ymax + self.ymin)/2
def cz(self):
return (self.zmax + self.zmin)/2
def extend(self, coords):
self.xmin = min(self.xmin, coords["X"])
self.xmax = max(self.xmax, coords["X"])
self.ymin = min(self.ymin, coords["Y"])
self.ymax = max(self.ymax, coords["Y"])
self.zmin = min(self.zmin, coords["Z"])
self.zmax = max(self.zmax, coords["Z"])