Why Does My Box Collision Fail When Not a Cube?

  • Thread starter Thread starter gc36
  • Start date Start date
  • Tags Tags
    Box
AI Thread Summary
The issue arises when the box is not a cube or is tilted, as the collision calculations assume uniform dimensions and a flat base. When the box is tilted, the contact point shifts, leading to an incorrect impulse calculation since the force does not act through the center of mass. The torque generated by the tilted position must be accurately accounted for in the impulse calculation. The current formula may not adequately handle the varying contact points and their effects on the box's dynamics. Adjusting the calculations to consider these factors will improve collision detection and response for non-cubic boxes.
gc36
Messages
2
Reaction score
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
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?
 
yes - that's what the relative contact position etc.. does
 
So I know that electrons are fundamental, there's no 'material' that makes them up, it's like talking about a colour itself rather than a car or a flower. Now protons and neutrons and quarks and whatever other stuff is there fundamentally, I want someone to kind of teach me these, I have a lot of questions that books might not give the answer in the way I understand. Thanks
Back
Top