Why Does My Box Collision Fail When Not a Cube?

  • Thread starter gc36
  • Start date
  • Tags
    Box
In summary, a programmer is discussing their process for colliding a box with the 'floor' in a physics engine for a game. They use a formula to calculate the impulse needed for the box to bounce and take into account factors such as contact normal, inverse inertia tensor, relative position, and restitution. However, they are having issues with non-cube boxes or when the box is tilted, potentially due to not accounting for torque. They confirm that they are considering torque in their process.
  • #1
gc36
2
0
Hello
I am programming a simple physics engine for a game.

I am colliding a box with the 'floor' (inverseMass = 0). I detect the vertices of the box that collide with the floor, calculate the impulse required to get the box to bounce for each contact, and apply it to that contact. The calculation for the impulse uses the standard forumula :

n is the contactNormal;
iitw is the inverseInertiaTensor in world coordinates of the box
r = relative position of contact point w.r.t centre of mass i.e (contactPoint - position of centre of mass)
e = restitution

numerator = -(1+e)relativeVelocity.Dot(n)
denominator = (n.Dot(n) * inverseMass) + ((iitw*r.Cross(n)).Cross(r)).Dot(n)
impulse = numerator/denominator;

I find that this works when the box is a cube (length = breadth = height ) and bouncing with its base parallel to the floor. If all dimensions are not equal - or the box is tilted a bit it is wrong.
Could somebody point out what I am doing wrong?
 
Physics news on Phys.org
  • #2
It the box is tilted then one corner or edge will hit the floor first- the force will not be through the center of mass of the box. Are you taking into account the torque on the box?
 
  • #3
yes - that's what the relative contact position etc.. does
 

FAQ: Why Does My Box Collision Fail When Not a Cube?

What happens when a box collides with the floor?

When a box collides with the floor, the box exerts a force on the floor and the floor exerts an equal and opposite force on the box. This force causes the box to bounce off the floor or to come to a complete stop, depending on the elasticity and surface properties of both the box and the floor.

How does the speed of the box change during the collision?

The speed of the box changes during the collision due to the transfer of kinetic energy between the box and the floor. If the collision is elastic, the speed of the box will remain the same after the collision, but if the collision is inelastic, the speed of the box will decrease due to the loss of kinetic energy.

Can the box and floor deform during the collision?

Yes, both the box and the floor can deform during the collision, depending on the materials and forces involved. If the forces are strong enough, the box and/or the floor may permanently deform or break.

How does the mass of the box affect the collision?

The mass of the box affects the collision by determining the amount of force that is exerted on the floor and the amount of kinetic energy that is transferred. A heavier box will exert more force and transfer more kinetic energy compared to a lighter box during a collision with the same surface.

Is there a difference between a box colliding with a hard floor versus a soft floor?

Yes, there is a difference in the collision between a box and a hard floor versus a soft floor. A hard floor will exert a greater force and transfer more kinetic energy compared to a soft floor due to its rigidity and lack of deformation. This can result in a higher bounce or a more significant change in the box's speed.

Similar threads

Back
Top