original_docstring: 
      Resolves the collision between two discs
      
docstring: Resolves the collision between two discs
docstring_tokens: Resolves the collision between two discs
code: def resolve_disc_disc_collision(disc_a: Disc, disc_b: Disc) -> None:
      """
      Resolves the collision between two discs
      """
      dist = np.linalg.norm(disc_a.position - disc_b.position)
      radius_sum = disc_a.radius + disc_b.radius
      if 0 < dist <= radius_sum:
          normal = (disc_a.position - disc_b.position) / dist
          mass_factor = disc_a.inverse_mass / (disc_a.inverse_mass + disc_b.inverse_mass)
          disc_a.position += normal * (radius_sum - dist) * mass_factor
          disc_b.position -= normal * (radius_sum - dist) * (1 - mass_factor)
          relative_velocity = disc_a.velocity - disc_b.velocity
          normal_velocity = np.dot(relative_velocity, normal)
          if normal_velocity < 0:
              bouncing_factor = -(
                  1 + disc_a.bouncing_coefficient * disc_b.bouncing_coefficient
              )
              disc_a.velocity += normal * normal_velocity * bouncing_factor * mass_factor
              disc_b.velocity -= (
                  normal * normal_velocity * bouncing_factor * (1 - mass_factor)
              )
  
      return
code_tokens: def resolve_disc_disc_collision ( disc_a : Disc , disc_b : Disc ) -> None : dist = np . linalg . norm ( disc_a . position - disc_b . position ) radius_sum = disc_a . radius + disc_b . radius if 0 < dist <= radius_sum : normal = ( disc_a . position - disc_b . position ) / dist mass_factor = disc_a . inverse_mass / ( disc_a . inverse_mass + disc_b . inverse_mass ) disc_a . position += normal * ( radius_sum - dist ) * mass_factor disc_b . position -= normal * ( radius_sum - dist ) * ( 1 - mass_factor ) relative_velocity = disc_a . velocity - disc_b . velocity normal_velocity = np . dot ( relative_velocity , normal ) if normal_velocity < 0 : bouncing_factor = - ( 1 + disc_a . bouncing_coefficient * disc_b . bouncing_coefficient ) disc_a . velocity += normal * normal_velocity * bouncing_factor * mass_factor disc_b . velocity -= ( normal * normal_velocity * bouncing_factor * ( 1 - mass_factor ) ) return
short_docstring: Resolves the collision between two discs
short_docstring_tokens: Resolves the collision between two discs
comment: """
      Resolves the collision between two discs
      """