From 246b074bd07ea54bf5f35f94b1783fec807e4afc Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Wed, 12 Aug 2015 17:20:20 +0200 Subject: fixed check_point_in_interval --- interval_utils.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/interval_utils.py b/interval_utils.py index 8557760..ba7715a 100644 --- a/interval_utils.py +++ b/interval_utils.py @@ -49,16 +49,17 @@ def find_largest_angle_interval(intervals): def get_point_angle(origin, p): dx = p[0] - origin[0] dy = p[1] - origin[1] - return math.atan2(dy,dx) + return math.atan2(dy,dx) % (2*pi) def check_point_in_interval(origin, p, interval): ang = get_point_angle(origin, p) - print(interval) - print(canonicalize_angle_interval(interval)) - if ang >= interval[0] and ang <= interval[1]: - return True + a,b = interval[0]%(2*pi), interval[1]%(2*pi) + print ((ang,a,b)) + if a <= b: + return (a <= ang and ang <= b) else: - return False - + return (a <= ang or ang <= b) + def get_cells_in_interval(origin, interval, cells): - return list(filter(lambda x: check_point_in_interval(origin, x.pos, interval), cells)) \ No newline at end of file + return list(filter(lambda x: check_point_in_interval(origin, x.pos, interval), cells)) + -- cgit v1.2.3