# 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.

## 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 on other sites
I'd start off by reading and understanding Hecker's old physics articles: http://chrishecker.com/Rigid_Body_Dynamics

Especially the 3rd and 4th.

##### Share on other sites
This is the bible: http://graphics.cs.cmu.edu/courses/15-869-F08/lec/14/notesg.pdf
Section 2.7.

While the bodies are in contact you'll apply a force at the point of contact to affect their velocities. You might apply a strong force for only one timestep and this would be considered an impulse.

##### 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 ) { //linear V += force / Mass * dt; //angular 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.
http://myphysicslab.com/collision.html

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

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11