Mercurial > hg > tvii
view tvii/bb.py @ 82:c05ce6b7f941
test distance calculations
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 17 Dec 2017 13:45:44 -0800 |
parents | 16bd13cd58bc |
children |
line wrap: on
line source
#!/usr/bin/env python # -*- coding: utf-8 -*- """ bounding box """ import argparse import sys from .transpose import transpose def bounding_box(*points): return [(min(col), max(col)) for col in transpose(points)] def overlap(bb1, bb2): """determines if two bounding boxes overlap""" # Note: this concludes they are linearly separably, # but the converse is not true for (min1, max1), (min2, max2) in zip(bb1, bb2): if min1 <= min2 <= max1: continue if min2 <= max1 <= max2: continue return False return True # TODO: this currently returns True and False; # it would be much more useful to return the intersection def main(args=sys.argv[1:]): """CLI""" # parse command line parser = argparse.ArgumentParser(description=__doc__) options = parser.parse_args(args) if __name__ == '__main__': main()