Car dynamics experiment

This application simulates movements of a car.
There's a special physics system in this application. It's based on particles but you can use several particles to form a rigid body.
Every particle has its mass, and when they were formed into a rigid body, the system calculates the center of gravity and moment of inertia for the rigid body. When a force was applyed to a particle, the physics system calculates acceleration and rotational acceleration for the whole rigid body and make it move.
To simulate the car, I used 4 particles (one for each wheel) to form the car rigid body. Thrusts and frictions were applyed to these wheels.
The friction calculation is special. Since wheels have direction. In the same direction of their rotation, they are free to move. But on the perpendicular direction of their rotation, they tends to stop the movement (Actually it's this friction that makes the car turns).

So here is the result:

First choose peremeters for your car, then click "drive" to drive it.
Use arrow keys to control the car.

You can change the shape of the car by these parameters, and you will see it acts differently for different settings. That's the magic of physics.

But this physics system is not quite complete, there's no collision detection and constraints... Since there's many wonderful physics engine under development now, I think I'm not going to complete this one.

There is also a 3D version here.
Source code download