summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-08-12 17:20:20 +0200
committerFlorian Jung <flo@windfisch.org>2015-08-12 17:20:20 +0200
commit246b074bd07ea54bf5f35f94b1783fec807e4afc (patch)
tree1b1ad1f67d249c75258e360e8fe84af5549f41c3
parentc61c5b52ba496ee4cc684d43117111ec7d351c0b (diff)
fixed check_point_in_interval
-rw-r--r--interval_utils.py17
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))
+