Skip to content

Commit

Permalink
Decoupled shape position updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed Jul 7, 2018
1 parent 34ea540 commit f945fb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 1 addition & 4 deletions fluids/assets/car.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,8 @@ def raw_step(self, steer, f_acc):
x, y, vel, angle = delta_ode_state[-1]


self.angle = angle
self.x = x
self.y = y
self.vel = vel
self.update_points()
self.update_points(x, y, angle)



Expand Down
8 changes: 4 additions & 4 deletions fluids/assets/pedestrian.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def step(self, action):
x0, y0 = self.x, self.y
x1, y1 = self.waypoints[0].x, self.waypoints[0].y
angle = np.arctan2([y0-y1], [x1-x0])[0]
self.x = self.x + 1 * np.cos(angle)
self.y = self.y - 1 * np.sin(angle)
self.angle = angle
self.update_points()
x = self.x + 1 * np.cos(angle)
y = self.y - 1 * np.sin(angle)
angle = angle
self.update_points(x, y, angle)
while len(self.waypoints) < self.planning_depth and len(self.waypoints) and len(self.waypoints[-1].nxt):
next_waypoint = random.choice(self.waypoints[-1].nxt)
line = shapely.geometry.LineString([(self.waypoints[-1].x, self.waypoints[-1].y),
Expand Down
5 changes: 4 additions & 1 deletion fluids/assets/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def render_debug(self, surface, color=(255, 0, 0), width=10):
def step(self, actions):
pass

def update_points(self):
def update_points(self, x, y, angle):
self.x = x
self.y = y
self.angle = angle
origin = np.array([self.x, self.y])
self.points = self.origin_points.dot(rotation_array(self.angle)) + origin
xs, ys = self.points[:,0], self.points[:,1]
Expand Down

0 comments on commit f945fb5

Please sign in to comment.