3D object physics

Started by
11 comments, last by stefu 22 years, 9 months ago
Yeah, just wanted to reiterate what I said in plainer language. The point on a body where a force is applied is irrelevant to linear dynamics (well, I think this is true only if the body is rigid, but I''m assuming that''s the case here). Force (F=ma) is in no way dependent on position, but torue (T = r x F) obviously is, because the cross product depends on the length of the vectors r and F and the angle between them (r is a vector from the centre of mass to the point where the force is applied).

The only reason we break forces up into components is because it''s generally easiest for us humans to represent vectors in X, Y and Z components. There is no such thing as a linear or angular component of force.
Advertisement
Thanks for all, I have now quite working rigid base class.

The interesting point is getting force that affects to a point.

Here''s my old GetForce funtion:
  vector_3 GetForce(Position,Direction){	vector_3 R = Position - CMPosition;	vector_3 M = AngularMomentum/seconds;	vector_3 F = CrossProduct(M,R) + LinearMomentum/seconds;	// Project Force	return Direction * DotProduct(Direction,F) / DotProduct(Direction,Direction);}  


I looked at Chris Heckers rigid physics example. There was an interersting function to get the Impulse.
So I modified my GetForce function:

  vector_3 GetForce(Position,Direction){	real CoefficientOfRestitution = r(1);	vector_3 R = Position - CMPosition;	vector_3 Normal = Normalize(Direction);	vector_3 Velocity = LinearVelocity + CrossProduct(AngularVelocity,R);    	real ImpulseNumerator = (r(1) + CoefficientOfRestitution) * DotProduct(Velocity,Normal);	real ImpulseDenominator = 1.0f/m_fMass + DotProduct( CrossProduct(InverseWorldInertiaTensor * CrossProduct(R,Normal),R), Normal );    	vector_3 Impulse = (ImpulseNumerator/ImpulseDenominator) * Normal;	// Project Force	return = Direction * DotProduct(Direction,Impulse/DeltaTime) / DotProduct(Direction,Direction);}  


I don''t quite understand that great chunck of Dot/cross Products yet. I didn''t realize differences in my car''s running so what does this do that the first method doesn''t?
> I don''t quite understand that great chunck of Dot/cross
> Products yet. I didn''t realize differences in my car''s running
> so what does this do that the first method doesn''t?

What it is supposed to do is work out the impulse experienced by a moving object colliding instantaneously with a fixed object/plane. The inputs include a plane/collision point normal, the object''s initial angular and linear velocity, as well as the position of the impact point relative to the object centre and the moment of inertia tensor.

I don''t know whether that code will work: it looks like it includes everything but the code relies on a number of factors, such all the variables being measured the same way, which aren''t
obvious from the code.

As for its use, it''s the way to (e.g.) work out the impuluse on a car colliding with a wall, or with the floor when rolling over. It''s not as much use for collisions between two moving objects, which requires a similar but more complex calculation.
John BlackburneProgrammer, The Pitbull Syndicate

This topic is closed to new replies.

Advertisement