Skip to content

Instantly share code, notes, and snippets.

@masci
Created September 10, 2012 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masci/3691024 to your computer and use it in GitHub Desktop.
Save masci/3691024 to your computer and use it in GitHub Desktop.
Bounding Box
Point = namedtuple('Point', 'x, y, z')
class BoundingBox(object):
def __init__(self,bottom,top):
self.top = Point._make(top)
self.bot = Point._make(bottom)
def _point_contained(self, other_point):
over_bot = all(map(lambda x: x[0]<=x[1], zip(self.bot,other_point)))
under_top = all(map(lambda x: x[0]>=x[1], zip(self.top,other_point)))
return over_bot and under_top
def contains(self, other):
return self._point_contained(other.bot) and \
self._point_contained(other.top)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment