diff options
author | Florian Jung <flo@windfisch.org> | 2015-08-12 17:20:20 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2015-08-12 17:20:20 +0200 |
commit | 246b074bd07ea54bf5f35f94b1783fec807e4afc (patch) | |
tree | 1b1ad1f67d249c75258e360e8fe84af5549f41c3 | |
parent | c61c5b52ba496ee4cc684d43117111ec7d351c0b (diff) |
fixed check_point_in_interval
-rw-r--r-- | interval_utils.py | 17 |
1 files 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)) + |