From 9c9f35753489cba5a61816104ac294857be20941 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 29 Apr 2011 20:35:20 +0200 Subject: host/simu: transpose transformation matrix, reverse transformation order This is better because transformations can be built incrementally from the container to the contained. This use the same semantic as OpenGL. --- host/simu/robots/marcel/model/loader.py | 4 ++-- host/simu/robots/marcel/view/loader.py | 2 +- host/simu/robots/marcel/view/robot.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'host/simu/robots/marcel') diff --git a/host/simu/robots/marcel/model/loader.py b/host/simu/robots/marcel/model/loader.py index 0270ce79..ae1caa7d 100644 --- a/host/simu/robots/marcel/model/loader.py +++ b/host/simu/robots/marcel/model/loader.py @@ -159,8 +159,8 @@ class Loader (Observable): # If gate is high, drop elements. if self.load and self.gate_angle > self.GATE_STROKE / 2: m = TransMatrix () - m.rotate (self.robot_position.angle) m.translate (self.robot_position.pos) + m.rotate (self.robot_position.angle) pos = m.apply ((-250, 0)) for e in self.load: e.pos = pos @@ -177,9 +177,9 @@ class Loader (Observable): return elements # Matrix to transform an obstacle position into robot coordinates. m = TransMatrix () + m.rotate (-self.robot_position.angle) m.translate ((-self.robot_position.pos[0], -self.robot_position.pos[1])) - m.rotate (-self.robot_position.angle) # Look up elements. # This could be used if clamp blocking is handled or elements are # pushed: diff --git a/host/simu/robots/marcel/view/loader.py b/host/simu/robots/marcel/view/loader.py index 5bda5d5b..d4ed336e 100644 --- a/host/simu/robots/marcel/view/loader.py +++ b/host/simu/robots/marcel/view/loader.py @@ -67,8 +67,8 @@ class Loader (Drawable): (300, 25 + 25 * i + (150 - 20 * i) * ratio)) if self.model.elevator_height is not None: self.trans_identity () - self.trans_rotate (-self.model.elevator_angle) self.trans_translate ((-100, -100 + self.model.elevator_height)) + self.trans_rotate (-self.model.elevator_angle) # Draw clamp load. if self.model.clamp_load: elements = self.model.clamp_load diff --git a/host/simu/robots/marcel/view/robot.py b/host/simu/robots/marcel/view/robot.py index 4e2135f2..67d505a2 100644 --- a/host/simu/robots/marcel/view/robot.py +++ b/host/simu/robots/marcel/view/robot.py @@ -52,8 +52,8 @@ class Robot (simu.inter.drawable.Drawable): """Draw the robot.""" self.reset () if self.pos is not None: - self.trans_rotate (self.angle) self.trans_translate (self.pos) + self.trans_rotate (self.angle) # Draw robot body. self.draw_polygon ((120, 155), (-95, 155), (-160, 90), (-160, -90), (-95, -155), (120, -155)) -- cgit v1.2.3