Elastic Collisions

Problem #76

Tags: physics

Who solved this?

Previous:Universal Gravitation Next:Billiard Ball Collisions


In the game of Billiards, a player must make certain balls fall into pockets around the table. However he cannot strike these balls directly, instead the rules required him to hit a small "cue ball" which can move the other balls by striking them. If we knew the masses m1, m2 and initial velocities v1, v2 of two balls, how could we predict how these values would change after a collision between those two balls?

Let's start by stating some assumptions in order to achieve an "ideal model" and avoid overcomplications. First, things like ball rotation, friction, etc will play no impact in the outcome of the collision (we can picture this collision happening in space, for example). Additionally, one of the fundamental laws of physics is the Conservation of Energy which states that the total energy of a closed system must remain constant (energy cannot be created nor destroyed). And so therefore we will assume that the total kinetic energy contained in both balls will remain constant before and after a collision, called an elastic colliision. The Kinetic Energy of an object is defined as half its mass multiplied by the square of its velocity, and so the Conservation of Kinetic Energy implies the following equation:

$$ \Large \frac{1}{2} m_{1} v_{1}^{2} + \frac{1}{2} m_{2} v_{2}^{2} = \frac{1}{2} m_{1} v^{\prime 2}_{1} + \frac{1}{2} m_{2} v^{\prime 2}_{2} $$

Where v1 and v2 are the pre-collision velocities, and v'1 and v'2 are the post-collision velocities.

In addition to the total energy of the system being conserved, the total momentum of the system is also conserved. An object's momentum is simply its mass multiplied by its velocity, and so the conservation of momentum can be described with the following equation:

$$ \Large m_{1} v_{1} + m_{2} v_{2} = m_{1} v^{\prime}_{1} + m_{2} v^{\prime}_{2} $$

Problem Statement

There exist two spheres in space having masses m1, m2 in units of kilograms, and initial velocities v1, v2 in unites of meters per second. For simplicity, these spheres exist on a single axis, and their velocities are colinear with that axis. Assume that the spheres are positioned such that a collision is guaranteed to occur.

Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each in the format m1 m2 v1 v2.

Answer
Should consist of 2 * Q space-separated values, corresponding to the post-collision velocities v'1 and v'2.
Error should be less than 1e-6

Example

input data:
2
1.2 3.4 5.6 -7.8
9.8 7.6 5.4 3.2
100.1 100.2 100.3 -100.4


answer:
-14.208696 -0.808696 3.478161 5.678161 -100.500200 100.199800
You need to login to get test data and submit solution.