There are several ways to determine a collision response.

One such method is to simulate the physics of the situation, calculating the forces on the two objects. Those forces can be applied to the center-of-mass (or center-of-gravity CG) of each object as linear forces and torques.

Another, perhaps the simplest, method is to merely assume both spheres respond elastically, forget about forces and torques, and set their velocities in the opposite direction V_{new} = -V_{old}, like billiard balls. A sphere strikes another sphere in the direction up-to-the-left and flies off up-to-the-right.

If a more formal collision is needed or desired, the forces on the objects can be done by simulating the compression of the surface of each object (like a rubber ball hitting a wall) taking in account the resiliency or the restitution factor for the object. As an example, consider the situation where your two spheres have collided and they overlap by a distance D. Part of D is the compression of sphere 1 and part is the compression of sphere 2. For simplicity, assume both spheres are the same radius, have collided directly in line with their centers-of-mass, and have the same restitution factor W in units of kg-meters-per-second-squared/meter. Since both spheres have the same factor, the compression of each is D/2. That means that the force on each sphere is W * D/2, in the direction of the center-of-mass. If the collision is NOT in line with the centers-of-gravity, the compression force is resolved into a force through the center-of-mass, and a tangential force which results in a torque.

The force through the center-of-mass is applied using, for instance, Newton's laws - primarily F = m * a (force = mass * acceleration).

In the following the bold letters indicate vectors, as the force and the acceleration are directional.

For **F** = m * **a**, the force (W * D/2) and mass are known, so put the unknown (acceleration) on one side of the equation, and the knowns on the other side: **a** = **F**/m. The acceleration (in meters/sec^{2}) in this example is W * D/2 / mass (in kg), and is in the direction from the point of collision through the center-of-mass.

The sphere's new velocity **V** = **V**_{0} + **a** * dT, where **V**_{0} is the sphere's (vector) velocity at the time the collision, **a** is the calculated acceleration, and dT is the time since the last collision check was performed, normally the frame rate of your app. The new position **P** of the sphere = **P**_{0} + **V***dt, where **P**_{0} is the position of the sphere at the time of the collision, **V** is the new velocity calcuated above, and dT is the same delta-time used in the velocity calc.

The spheres are then drawn at their new positions **P** in the next rendering frame. This type of simulation *may* result in the spheres appearing to overlap (being compressed) for one of more frames if, for instance, the forces are not great enough to separate the spheres in time dT.

Note: this is just one of several methods for handling collision response. Another approach is to calculate an impulse (force) large enough to separate the spheres in time dT. Even that can be done in several ways. For instance, use very large values for the restitution factors and using very small dT values. Alternatively, that can also be simulated using the V = -V example above.

The "restitution factor" mentioned is likely what you mean by "bounciness." Friction is a bit more complicated and would be applied if the velocities of the spheres are not anti-parallel at the time of the collision - i.e., collision at an angle.

In that case, the force on the spheres is calculated in two pieces - one force (a "normal"** force) through the center-of-gravity, and another tangential (perpendicular to the first force) to the surface. The tangential force is proportional to the normal force, the relative velocity of the spheres at the point of collision, and friction factors of the two spheres.

** "normal" is the sense of perpendicular to the surface, not meaning "ordinary."

The tangential force is applied as a torque and an additional normal force on the center-of-mass. The additional normal force is added to the first force (used in F = ma) and the torque (the vector cross-product of the tangential force with the vector from the point of collision to the center-of-mass) results in a change in angular velocity (spin) where **torque** = MOI * d**L**/dT. MOI is the motion of inertial (google for it) and d**L**/dT is the *change* in angular velocity (d**AV**/dTfor the sphere. So, d**L**/dT = **torque**/MOI. For a very simple response, you can simulate that by calculating angular velocity **AV**_{new} = **AV**_{old} + **torque**/MOI * dT. The new orientation of the sphere (rotation) **ROT**_{new} = **ROT**_{old} * **AV**_{new} * dT. N.B., dT is the same small delta-time used throughout the calculations.

**Edited by Buckeye, 27 August 2014 - 12:12 PM.**