summaryrefslogtreecommitdiffhomepage
path: root/host/simu/model/rectangular_obstacle.py
diff options
context:
space:
mode:
Diffstat (limited to 'host/simu/model/rectangular_obstacle.py')
-rw-r--r--host/simu/model/rectangular_obstacle.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/host/simu/model/rectangular_obstacle.py b/host/simu/model/rectangular_obstacle.py
index 71cfdc8b..8f574f01 100644
--- a/host/simu/model/rectangular_obstacle.py
+++ b/host/simu/model/rectangular_obstacle.py
@@ -61,3 +61,14 @@ class RectangularObstacle (Observable):
found = i
return found
+ def inside (self, a):
+ """If A is inside obstacle, return True."""
+ # Map point in obstacle coordinates.
+ u = vector.polar (self.angle, 1)
+ o = vector (self.pos)
+ a = vector (a)
+ oa = a - o
+ x = oa * u / (.5 * self.dim[0])
+ y = oa * u.normal () / (.5 * self.dim[1])
+ return x > -1 and x < 1 and y > -1 and y < 1
+