Crossposting this from Reddit.
Basically, I have a custom 2d physics engine, written in AS3, for entirely academic purposes.
Previously, it consisted solely of jacobson advanced character physics style verlet integrated particles and constraints, but recently I added rigid body rotating disks.
I use verlet both for the integration of particles and the integration of the rotation of disks, so it looks like this:
For the particles' positions:
var temp:Vector2 = new Vector2(x, y); //Store old position
var tempv:Vector2 = new Vector2(v.x, v.y); //and old velocity
x = x * 2 - old.x + f.x; //integrate the velocity + accumulated force
y = y * 2 - old.y + f.y;
old.x = temp.x;
old.y = temp.y;
v.x = ((x - old.x) + tempv.x)/2; //averaging the velocity like this
v.y = ((y - old.y) + tempv.y)/2; //seems to help with stability
f.x = 0; //zero the force accumulators
f.y = 0;
For the rotation of uniform objects:
acc_force += -velocity * friction
velocity = velocity * 2 - old_velocity + (acc_force*radius)/inertia;
rotation += velocity
old_velocity = velocity;
acc_force = 0;
As you can see, I integrate the velocity of rotating bodies and use that to derive the position. This is because if I do things the other way, it was incredibly unstable. Averaging the position a la the velocity of fixed points also had a negative effect.
So basically, my issue is that rotation is a lot less stable than position. It tends to 'shudder' at low speed and it can explode quite easily.
Has anyone had similar experiences? Is there a better way to integrate rotation? Or is this more likely a numerical instability issue?