# HG changeset patch # User Panos Mavrogiorgos # Date 1349706369 -10800 # Node ID d688699cc9dc989d60cc5186470966ee0cf1bd33 # Parent 3f9cfb6cfd919db7be54e2f6212ed81c9e7f26d4 Remove definition of function "left_of_line" from geoalg.convexhull.py and import it from geoalg.base.py diff --git a/geoalg/convexhull.py b/geoalg/convexhull.py --- a/geoalg/convexhull.py +++ b/geoalg/convexhull.py @@ -11,6 +11,8 @@ __all__ = ['ConvexHull'] +from geoalg import left_of_line + class ConvexHull(object): def __init__(self, points): self._points = ConvexHull._construct(points) @@ -48,28 +50,3 @@ lower_hull = convex_hull(lower_hull) upper_hull.extend(lower_hull[1:-1]) return upper_hull - -def left_of_line(point, p1, p2): - """ True if the point self is left of the line p1 -> p2 - """ - # check if a and b are on the same vertical line - if p1[0] == p2[0]: - # compute # on which site of the line self should be - should_be_left = p1[1] < p2[1] - if should_be_left: - return point[0] < p1[0] - else: - return point[0] > p1[0] - else: - # get pitch of line - pitch = (p2[1] - p1[1]) / (p2[0] - p1[0]) - - # get y-value at c's x-position - y = pitch * (point[0] - p1[0]) + p1[1] - - # compute if point should be above or below the line - should_be_above = p1[0] < p2[0] - if should_be_above : - return point[1] > y - else: - return point[1] < y