Jump to content
  • Advertisement
Sign in to follow this  

Physics Collision Response for boxes

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

As a final project for school, a friend and I are making a basic 3D physics engine. We've made a lot of progress since we started, but there's a topic we've had a lot of trouble with: calculating the effects(velocity, direction, etc.) how a collision affects the two objects that have collided. We've already found a way to do this for point-masses (spheres in this case) thanks to the great help at physforum.com. But we're having problems with the box-solid, specifically, with the rotational velocity.

We have an (axis-aligned,) rotating box colliding with a sphere. The box has a width of Bw, a length of Bl and a depth of Bd. The box' mass is mb, the sphere's mass is ms. We have the point of collision, which is (cx,cy,cz). The box has a speed of (vbx, vby, vbz) and a rotational speed of (vbrx, vbry, vbrz). The sphere has a speed of (vsx, vsy, vsz). After the collision, the box has a speed of (vbx', vby', vbz'), rotates with (vbrx', vbry', vbrz') and the sphere has a speed of (vsx', vsy', vsz'). Conservation of energy and momentum both apply.

Our first thought was that we would replace the box with a point mass positioned at the point of collision but after some further thinking we realized that this is not correct on the level of physics, since the mass is not divided uniformly from that point mass on. If that is indeed so, how *do* we solve this problem? (solving must be done analytically, not numerically! However, it may be done numerically if the computer solves it.)

We appreciate any help any of you can give us.

Share this post

Link to post
Share on other sites
To summarize a little bit.

Each shape will be referred to as a body, with state variables ( P - position of center of mass, A - Orientation, V - linear velocity, W - angular velocity )

The center of mass of each body will be offset from the contact pt by some extension. This extension is what will result in torque changing the angular velocity.

Your force function will look something like this:

Body::AddForce( worldForce, worldPt, dt )
V += force / Mass * dt;

vec3 offset = worldPt - P;
W += CrossProduct( offset, force ) / Inertia * dt

//And each step you're probably doing something like this:
Body::Step( dt )
P += V * dt;
A += W * dt;

Here's a good tutorial on computing the force or impulse to apply. But if you're doing it in 3d then i recommend using baraff's paper because the 2d -> 3d conversion is not intuitive, lots of stuff has been reduced.

Baraff derives the same equation in figure (8-18 Here

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!