Archived

This topic is now archived and is closed to further replies.

Some Physics

This topic is 6930 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, I''m talking 2D here for simplicity: When I see a vehicle hitting another vehicle''s side, the hitted vehicle moves in the direction of the hitting vehicle and it also ROTATES. How do I calculate this rotation? I understand that it is casued because not all of the hitted vehcile is equally affected by the hitting vehicle, but how do I calculate this? Thanks, Oren Becker.

Share on other sites
Actually that''s not such an easy thing to solve. It depends on the center of mass of both objects, and the contact point. If the contact point and direction are not directly inline with the center of mass, the collision will cause a moment-force around the center of mass of the object, which manifests itself as a rotation.

#pragma DWIM // Do What I Mean!
**I use Software Mode**

Share on other sites
Well, here''s a simple breakdown of how to do it...

0) Pre calculate the center of mass of the vehicle. This is the point about which it will rotate. For your purposes it''s probably safe to assume this to be the center of the vehicle.

1) Calculate the point of impact on the vehicle. This is exactly where the oncoming vehicle has made contact.

2) Now calculate the vector from the point of contact to the center of mass. (You will also need the vector representing the oncoming vehicles velocity, but presumably you already have this...)

3) Next calculate the portion of the velocity vector *along* the vector from step 2, and the portion of the velocity vector *perpendicular* to the vector from step 2.

4) Now the first vector from step 3 can be used affect the linear velocity of the vehicle (ie that''s the direction in which the vehicle will be pushed). If the masses of both vehicles are the same, you should be able to just add that vector to the velocity of the vehicle, otherwise you will have to scale it based on their relative masses.

5) Finally, the second vector from step 3 can be used to affect the angular velocity of the vehicle. Essentialy, the angular velocity of the vehicle will be directly proportional to the magnitude of the vector from step 2, and the magnitude of the second vector from step 3, and it will be inversely proportional to the rotational inertia (ie mass) of the vehicle.

I know I left out all the equations (I figured this post was long enough already), but that should get you going in the right direction. I''m pretty sure I got all my facts right, if not, I''m certain that they''re close enough to get you realistic *looking* collisions

Share on other sites
alright, i get the global direction of how to do it?

can you show me the equation of how much to add to the angular velocity of the hitted vehicle?

Share on other sites
OK, bear with me here... It''s been several years since I was a physics major! Some of these equations may not be *precisely* correct in the real world, but again, I think they''ll be a close enough approximation for a game. Probably even more accurate then you''d really need.

First some set up->

Vv1 = Velocity vector of oncoming vehicle
Vv2 = Velocity vector of hit vehicle
Av = Angular speed of hit vehicle
Pi = Coordinate of point of impact returned from your collision detection function
Pc = Coordinate of center of mass of vehicle being hit

So...

Vt = Pc - Pi This gets the lever arm from step 2 above
Vut = Vt / /Vt/ Scale Vt to a unit vector
Vl = Vv1 . Vut Get portion of Vv along Vt
Vr = Vv1 . (1 / Vut) I''m too lazy to double check this,
it might be wrong, but essentially get
the portion of Vv perp to Vt
Vv2 += (M1 * Vl) / (M1 + M2) Add the linear velocity
Av += (Vr * /Vt/) / M2 Add the angular speed

I have strayed pretty far from actual physics, but I don''t have time to show you all the math, and this should get you going in the right direction. I''m sure somebody here will be more then happy to write a post detailing all the faults in the above anyway

By the way, I should note that this doesn''t take in to account the fact that the oncoming vehicle is also going to be affected... All the above treats the oncoming vehicle as a point mass.

• 15
• 13
• 35
• 39