By: Ian Greenwood (ijaygee) - 2008-03-15 10:31 |
Hi Martin, I'm having problems getting rotating spheres to bounce off walls properly - with 'side' or 'english'. I've read this page https://www.euclideanspace.com/physics/dynamics/collision/threed/index.htm (note: shouldn't vaf = vai + J/ma, and vbf = vbi - J/mb ?) I've done the math with 3D boxes before and it all works fine. I think the problem with spheres is that the collision normal (n) and hit point radius (r) are in line - i.e. the cross product is always 0 0 0, and the relative velocity of the hit point dot normal only gives the velocity into the wall for the rebound. There's no torque for the rotational velocity to be transfered to or from the linear velocity. Are spheres a special case? What I think I need is the cross product of the normal and the instantaneous relative velocity of the point, but I'm not sure how to incorporate this in the collision response (assuming this is the quantity I need...?). As ever any help much appreciated Ian G. |
Hi Ian, Its a long time since I worked on that page, looking back at it I think it could do with some improvement, I think some more diagrams would be helpful and perhaps I don't need all those gifs in the formulas. > (note: shouldn't vaf = vai + J/ma, and vbf = vbi - J/mb ?) I think thats where a diagram would help to show which directions of these quantities are positive, at first sight what you suggest makes sense because that would indicate that the momentum is being taken from vb and transferred to va. From what I remember the code does not determine the collision normal 'n' so that has to be supplied by the programmer but as you say that can be easily determined in the case of spheres. I think the assumption is that there is no friction and therefore the direction of the impulse is normal to the surfaces. However if there is some friction then 'n' needs to be rotated slightly to transfer angular momentum between the spheres. It would be nice to expand the equation which calculates J to include the friction coefficient but that would make the equation very complicated, it might be simpler to rotate 'n' by some factor of the angular velocities? Martin |
By: Ian Greenwood (ijaygee) - 2008-03-16 03:12 |
Hi
Martin, I think we discussed the "moving the normal" solution some time
ago - I did get something working along those lines but in that
instance I wasn't using a full 3D physics model (no mass or
inertia). I've been pondering the actual problem a bit more. What it boils down to is that the tangential velocity of the impact point is completely ignored in the impusle response - that's a design of the method. I've found this article which I think contains the solution we're looking for http://citeseer.ist.psu.edu/cache/papers/cs/892/http:zSzzSzwww.cs.berkeley.eduzSz~mirtichzSzpaperszSzibds.pdf/mirtich95impulsebased.pdf My maths isn't great but I can see from this paper that we need that tangential velocity and the coefficient of friction (plus a few other bits to cope with sticking and sliding) and we should have a complete solution for any eventuality. I'll try my best to interpret what the guys at Berkeley came up with, but if you could run it through a 'math translator' and turn it into English that would help no end. I've no doubt it will be of great use to mjbworld too. regards Ian G. |
Ian, I agree with all you say, the paper looks very interesting and it would be good to include the effects of friction on the website. My first thoughts after glancing through the paper very quickly are that we need to: first calculate approach velocity of the points on each object that collide: uia = via + wia x ria uib = vib + wib x rib approach velocity = u = uia - uib normal velocity component = u.n*n tangential velocity component = u-(u.n*n) Then in addition to calculating the impulse Jnorm to stop or reverse the normal approach velocity we also need to calculate the impulse Jtang to stop the tangential approach velocity Then calculate the total impulse J which is made up from all of Jnorm + some of Jtang depending on the friction coefficient or collision parameter in the paper. If we want to include sliding or continuous contact then we replace Jtang the tangential impulse with a continuous tangential force. I think this makes things a lot more complicated as we need to know the contours of both objects along the sliding faces so there is not a formula that we can use if we have complex shapes. Although this part is not an issue if you are working with spheres. Martin |
By: Ian Greenwood (ijaygee) - 2008-03-17 07:32 |
Martin, that's great! Thank you. I'd almost got there but I hadn't quite got the Utan calculation right... In searching for more info I've found some very recent work which covers non-convex objects and stacking e.g. 1000 boxes in a wall which then collapses, or hundreds of hoops falling onto poles. The integration technique looks very intriguing too. In the classic ('naive') approach we'd update x with vt, and then v with at, check for collisions (perhaps back step in time as per Chris Hecker's method) and resolve the collisions. This usually fails to produce realistic effects with stationary objects e.g. a box on a slope with sufficient friction to hold it in place - what happens is the box gets pushed away from the slope and falls back under gravity and gradually bounces down the slope. In the new approach we calculate the future position with the velocity as before (x' = x + vt) then check and resolve collisions with the proper coefficient of restitution, then we update the (now possibly collided) velocity with acceleration (v' += at) and then do another collision (or contact) check with coff. restitution of 0 (zero), which will then only push the objects out of penetration. From what I can gather, they perform these steps several times each frame from the bottom of the stack upward (propagation ordered tree) and on the final pass they give everything an infinite mass (working from the lowest level upward) to 'shock' everything into a non-penetrating state. The box on the slope never moves with this technique - it has no velocity in the 1st collision check and simply gets its velocity zeroed after the acceleration step. This eliminates the ad hoc microcollision velocity threshold as per the Mirtich paper above. They don't claim that this technique is particularly accurate but their test results are almost identical to theoretical position and velocities and "allow for plausible microstruture variances" (i.e. appears more realistic than the purely theoretical). Of course this method is very collision-detection intensive and the paper discusses the techniques being used. It seems to be using a grid, voxel or octree with 'signed distances' indicating the inside and outside of the objects (not sure exactly how that works) - apparently this technique works equally well for convex and non-convex polyhedra and from what I can gather it returns the normal for the closest contour whether that's a face, edge or vertex. They also incorporate static, kinetic, rolling and spinning frictional effects in the collision resolution. Could be worth a look...? http://www.cs.ubc.ca/~rbridson/docs/rigid_bodies.pdf Many, many thinks for your help Ian G. |
By: Ian Greenwood (ijaygee) - 2008-03-17 23:25 |
Martin, ok, took a while to figure it out but I've got it working in 2D as follows First compute Jnorm as usual and update velocities then using Utang check the friction speed = Utang.mag() if(speed>0){ // can we compute friction? T = Utang.div(-speed) // negate and normalize tangent vector perpDot = perp(R).dot(T) // perp dot product of collision point radius and tangent vector Jtang = speed/((1/M)+(perpDot*perpDot/I)) // tangent impulse // now compare Jtang to friction from Jnorm and select appropriate friction mode if(Jtang<staticFrictionCoeff*Jnorm) Fimp = Jtang else Fimp = dynamicFrictionCoeff*Jnorm vaf += T * Fimp/M waf += perpDot * Fimp/I } Ian |