summaryrefslogtreecommitdiffhomepage
path: root/host/simu/model
diff options
context:
space:
mode:
Diffstat (limited to 'host/simu/model')
-rw-r--r--host/simu/model/rectangular_obstacle.py11
-rw-r--r--host/simu/model/table_eurobot2013.py7
2 files changed, 14 insertions, 4 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
+
diff --git a/host/simu/model/table_eurobot2013.py b/host/simu/model/table_eurobot2013.py
index 8e5e83fc..d73b0564 100644
--- a/host/simu/model/table_eurobot2013.py
+++ b/host/simu/model/table_eurobot2013.py
@@ -76,11 +76,11 @@ class Table (simu.model.table.Table):
add_glass ((1200, 1050))
# Cherries.
self.plates = [ ]
- self.cherries = [ ]
def add_plate (pos, color):
plate = RectangularObstacle ((170, 170), 0)
plate.pos = pos
plate.angle = 0
+ plate.cherries = [ ]
self.plates.append (plate)
cpos = ((-42, -42), (-42, 0), (-42, +42), (0, -21), (0, 21),
(42, -42), (42, 0), (42, +42))
@@ -88,9 +88,9 @@ class Table (simu.model.table.Table):
random.shuffle (ccol)
for p, c in zip (cpos, ccol):
cherry = RoundObstacle (20, 0)
- cherry.pos = (pos[0] + p[0], pos[1] + p[1])
+ cherry.pos = p
cherry.color = c
- self.cherries.append (cherry)
+ plate.cherries.append (cherry)
for py in (250, 600, 1000, 1400, 1750):
add_plate ((200, py), False)
add_plate ((3000 - 200, py), True)
@@ -114,6 +114,5 @@ class Table (simu.model.table.Table):
self.obstacles += self.candles
self.obstacles += self.glasses
self.obstacles += self.plates
- self.obstacles += self.cherries
self.obstacles += self.gifts