It has come to the point in my computing program now where I have 5 swinging pendulums that are all modified at once by slider values. These values are drawn onto the from and passed through the class pendulum. To change the values the update button is run, and their is a default option to use a setup that works. The values are also shown on screen through some simple labels. The zero button sets all values (except length) to zero.
The values for each pendulum drawn is:

  • String length
  • angle
  • Acceleration (angular)
  • Angluar velocity
  • Damping or friction
  • Gravity

My calcuations for these values: (Bob = the weight at the end of the string, and there are X and Y Co-ordiantes for it.

bobX = originX + (Math.Sin(angle) * length);
        bobY = originY +(Math.Cos(angle) * length);

Caclulate Acceleration:

Angular Acceleration = (-1 * gravity / length) * Math.Sin(angle); 

Increment Velocity:

        Angular Velocity += Angluar Acceleration;

Increment Angle

        angle += AngularVelocity;

Friction action, pendulum eventually 0's

        AngularVelocity*= damping;

Now my next task is to make the pendulums collide "realistically" and recreate a newtons cradle type effect. I've looked into elastic collision solutions on particle e.g. here is an excellent example: https://stackoverflow.com/questions/345838/ball-to-ball-collision-detection-and-handling

I've also looked at the raw physics behind it here but my brain couldn't get to grips with the raw physics side of things.

So I'm wondering if anybody could help me figuring out the theory for the collisions.
My current idea is when the co-ordinates meet the velocity will simply change polarity e.g. +10 to -10 in the opposing pendulum. Am I correct here? If you are into code I've posted the code on stack overflow here!

  • $\begingroup$ For your case you need to know a) when a collision occurs, b) which objects are in contact and c) how to handle multiple contacts at the same time. Not an easy task, so read here for an introduction to physically based modeling. $\endgroup$ Commented Oct 16, 2013 at 0:33

1 Answer 1


There is something called impulse $J$ which represents a very high force over a short period of time resulting in a step change in velocity.

For a particle object $\Delta v = \frac{J}{m}$. When two objects collide and equal and opposite impulse acts on both of them resulting in

$$\begin{aligned} \Delta v_1 &= \frac{J}{m_1} & \Delta v_2 & = \frac{-J}{m_2} \end{aligned} $$

So how do you find what the impulse $J$ is and hence the changes in speed?

Typically a rule is placed for collision saying that the final relative velocity is proportional in magnitude to the initial relative velocity, but in an opposite direction. Namely:

$$ \left( \left( v_1 + \Delta v_1 \right) - \left( v_2 + \Delta v_2 \right) \right) = -\epsilon \left( v_1 - v_2 \right) $$

This only applies for the components of velocity along the contact normal direction (along the impulse direction). The constant $\epsilon$ is called the coefficient of restitution and it is $\epsilon=0$ for a plastic contact (sticking) and $\epsilon=1$ for an elastic contact (bouncing) and everything in-between.

Combine the above to get

$$ \boxed{ J = (\epsilon+1) \left(v_2-v_1\right) \left( \frac{1}{m_1}+\frac{1}{m_2}\right)^{-1}}$$

  • $\begingroup$ $v2$ and $v1$ are the velocities before collision, right ? $\endgroup$
    – niceman
    Commented May 25, 2015 at 7:43
  • $\begingroup$ Yes. I should condense them to $v_{impact} = v_2-v_1$ $\endgroup$ Commented May 25, 2015 at 14:30
  • $\begingroup$ hmmm I think your law of calculating $J$ is wrong, $J$ should be a very big force acting on a short time(that's an impulse force) $\endgroup$
    – niceman
    Commented Jun 7, 2015 at 20:00
  • $\begingroup$ Yes, $J$ is an impulse. It has units of $\mbox{Newton Second}$. A very big force acting over a small amount of time multiples together make a not so big impulse $J$. $\endgroup$ Commented Jun 7, 2015 at 20:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.