# Simulation of a two-masses connected by a rod 2D system

I'm working on a multitouch-based interface and I want to add some physical behavior to gestures (pan, zoom and rotation). I thought model the system like that:

• When a touch starts, a point mass is created.
• As the finger moves, I calculate it's velocity vector.
• When the touch ends, I suppose the mass is released and starts to move freely.

My problem comes when I have two masses (I don't need more than two masses to model this system):

The masses should act as if they were connected by a massless rod and, optional, they can slide along the rod with some coefficient of friction.

I attach a picture to explain the thing better. I forgot almost all the physics I knew at college and now I'm a developer.

I know that at time t the masses have a position (x, y), a velocity and one or more forces or accelerations acting on it. And I want to know those values at time t+dt.

I would like to have some advice or approach to this problem. It's not about integrators or numerical analysis. My main doubt is about the rod constraint (keep the distance between masses) and the rotation movement.

## 1 Answer

You have only four independent co-ordinates to track:

• The location of the center-of-mass, as the vector (x, y);
• the separation of the two point masses as the scalar d; and
• the orientation of the masses about the center-of-mass, as the scalar theta.

plus their rate of change over time: (Vx, Vy), v, and w

Don't attempt to analyze any forces - just use the kinematics and apply linear impulses as you have described in your posting.

Apply all impulses applied to either mass directly to the center-of-mass as a change in its velocity; then recalculate the resultant changes in v and w by applying the each impulse to the appropriate point mass relative to the center-of-mass.

In this model the constraint of the rod is implicitly enforced by having every impulse to each mass also result in an overall rotation of the system.