def move_right(self): if not self.collision: #cannot change dir in the air return None (P, Q) = self.collision (x, y) = p.vsub(Q, P) if self.collision and x <= 0: if abs(x) >= abs(y): #surface angle leq 45, can move normally self.v = p.proj((self.maxImpulse, 0), p.vsub(self.collision[1], self.collision[0])) else: #surface angle > 45, cannot move easily self.v = (self.minImpulse, 0)
def particleEdgeCollision(self, wp, P, Q): wp.v = (0, 0) if p.vsub(Q, P)[0] <= 0: #then collided from the top wp.g = p.proj(wp.gravity, p.vsub(Q, P))
def particleVertexCollision(self, wp, P): R = (wp.x, wp.y) if p.vsub(R, P)[1] <= 0: wp.g = p.proj(wp.gravity, p.vsub(R, P))