Remove some hacking.
authorSimon Cross <hodgestar@gmail.com>
Wed, 7 Sep 2016 21:48:57 +0000 (23:48 +0200)
committerSimon Cross <hodgestar@gmail.com>
Wed, 7 Sep 2016 21:48:57 +0000 (23:48 +0200)
data/stations/station-alpha.json
tabakrolletjie/rays.py

index 259a64500c9f44e617e0a7ed7af98d5fa4379348..7eadc6edf497c25342119f46813fc3a30ac81f93 100644 (file)
@@ -33,7 +33,7 @@
       "spread": 45.0,
       "radius_limits": [20, 400],
       "angle_limits": [90, 180],
-      "angular_velocity": 10,
+      "angular_velocity": 5,
       "intensity": 0.8
     },
     {
index f893828112a8084157fe353ea2e2a37b124c19d8..e187f3d3c532633540f41b330f68be6f15b38867 100644 (file)
@@ -98,18 +98,14 @@ class RayPolyManager(object):
 
     def polys(self):
         if self._poly_cache is None:
-            print "===="
             self._poly_cache = [
                 rp.poly(self._body, self._ray_filter) for rp in self._rays
                 if rp.within_limits(*self._angle_limits)
             ]
-            print "===="
-
         return self._poly_cache
 
     def pygame_polys(self, surface):
         if self._pygame_poly_cache is None:
-            print "REGEN ...", self._angle_limits
             self._pygame_poly_cache = [
                 [
                     pymunk.pygame_util.to_pygame(v, surface)
@@ -134,19 +130,14 @@ class RayPoly(object):
     def within_limits(self, start_limit, end_limit):
         if start_limit is None or end_limit is None:
             return True
-        print "----"
-        print "LIM: ", start_limit, end_limit
-        print "ANG: ", self.start.angle, self.end.angle
-        n1 = self.start.normalized()
-        n2 = self.end.normalized()
-        s = pymunk.Vec2d(1, 0).rotated(start_limit)
-        e = pymunk.Vec2d(1, 0).rotated(end_limit)
-        n1bet = s.dot(e) < s.dot(n1) and s.dot(e) < s.dot(n1)
-        n2bet = s.dot(e) < e.dot(n2) and s.dot(e) < e.dot(n2)
-        print "DOTS n1: ", n1.dot(n2), n1.dot(s), n2.dot(s)
-        print "DOTS n2: ", n1.dot(n2), n1.dot(e), n2.dot(e)
-        print "BET: ", n1bet, n2bet
-        if n1bet:
-            print "TRUE\n----"
+
+        def between(n):
+            if start_limit < end_limit:
+                return start_limit <= n <= end_limit
+            return (start_limit <= n) or (n <= end_limit)
+
+        start_within = between(self.start.angle)
+        end_within = between(self.end.angle)
+        if start_within or end_within:
             return True
         return False