Exemple #1
0
 def resultant_collision_velocity(self, other, e):
     """ Return the resultant velocity of current coin on collision with the other coin,
      elasticity of the collision is determined the the co-efficient of restitution 'e'."""
     """ If they overlap fully then no collision, handle division by zero exception  """
     if Vector2.length(self.position - other.position) == 0:
         return self.velocity
     return self.velocity - ((1 + e) * other.mass / (self.mass + other.mass)) * \
         Vector2.dot(self.velocity - other.velocity, self.position - other.position) / \
         Vector2.length_squared(self.position - other.position) * (self.position - other.position)
Exemple #2
0
 def resultant_collision_velocity(self, other, e):
     if Vector2.length(self.position - other.position) == 0:
         return self.velocity
     return self.velocity - ((1 + e) * other.mass / (self.mass + other.mass)) * \
         Vector2.dot(self.velocity - other.velocity, self.position - other.position) / \
         Vector2.length_squared(self.position - other.position) * (self.position - other.position)