From a32cf498ca953e0ebc0558958977ecd37fc741a5 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 15 Apr 2013 22:24:42 +0200 Subject: host/simu, host/simu/robots/apbirthday: add plate loading simulation --- host/simu/model/rectangular_obstacle.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'host/simu/model/rectangular_obstacle.py') 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 + -- cgit v1.2.3