summaryrefslogtreecommitdiff
path: root/host/simu/model/rectangular_obstacle.py
diff options
context:
space:
mode:
authorNicolas Schodet2013-04-15 22:24:42 +0200
committerNicolas Schodet2013-04-15 22:25:39 +0200
commita32cf498ca953e0ebc0558958977ecd37fc741a5 (patch)
tree66db0ff683cf19dd375e63b2923c46b995763549 /host/simu/model/rectangular_obstacle.py
parent8d625a7761959fc53b6e8d99c8c30c8456211555 (diff)
host/simu, host/simu/robots/apbirthday: add plate loading simulation
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
+