Advertisement

verlet integration for rotational movement in rigid bodies

Started by March 21, 2003 07:13 AM
1 comment, last by oliii 21 years, 11 months ago
I'm trying to implement the verlet integration for rigid bodies. So far, I've implemented the Euler integration as follow

	LinVelocity     += LinAcceleration * dt;
	RotVelocity     += RotAcceleration * dt;

	Position		+= LinVelocity * dt + LinAcceleration * (dt*dt*0.5f);
	
	//----------------------------------------------------------------------
	// Poisot equation to integrate for orientation
	//----------------------------------------------------------------------
	Quaternion Qvel = Quaternion(RotVelocity, 0) * Q * 0.5f;
	
	Quaternion Qaccel = Quaternion(RotAcceleration, 0) * Q * 0.5f;
	
	Q += Qvel * dt + Qaccel * (dt*dt*0.5f); // standard euler equation, like for position
  
and I've got this for verlet integration

	//-------------------------------------------------------
	// Verlet Integration
	// x' = 2x - x° + a * §t² => x += (x - x°) + a * §t²
	//-------------------------------------------------------
	Vector Temp  = Position;
	Position	 = Position*2.0f - PrevPosition + LinAcceleration * (dt*dt);
	PrevPosition = Temp;
	LinVelocity = (Position - PrevPosition) / dt;

	Quaternion Qaccel = Quaternion(RotAcceleration, 0) * Q * 0.5f;
	Quaternion TempQ  = Q;
	Q				  = Q*2.0f - PrevQ + Qaccel * (dt*dt);
	PrevQ			  = TempQ;
	//RotVelocity = ?????????????
  
Now, I need to extract the rotational velocity out of it. I'm not sure of the math. For the moment, I integrate with verlet for the linear movement, and with euler for the roational movement. I'm hoping a full verlet integration would make the system more stable. Thanks for your help non! [edited by - oliii on March 21, 2003 8:17:09 AM]

Everything is better with Metal.

Well, just one thing I noticed. You should do
LinVelocity += LinAcceleration * dt;RotVelocity += RotAcceleration * dt; 

after you update the rotation and position, not before. If you really need to have it first for some reason, LinAcceleration*(dt*dt*0.5f) should be subtracted instead of added.
Advertisement
thanks. I guess If I''m doing constraints, it would be better that way.


non!

Everything is better with Metal.

This topic is closed to new replies.

Advertisement