Closed mikhail-vlasenko closed 1 year ago
Also, why only balls? The collision resolution algorithm that you have should work almost perfectly with anything else. Though computing surface normal seems hard, in practice it should not be hard: we should just use jax.grad
on the support function. This is actually such a smart move, that I think we could make it a really small paper, or blogpost, just about using autodifferention in this particular fashion. Like, usually computing normals to arbitrary shapes is a complete pain
Though it might be harder than I expect, since the surface tangent is not precisely a subgradient: like, we have two bodies, and only one of the subgradients is going to be an appropriate surface tangent... Cuz, if you imaging like a polygon colliding with a circle, the surface normal will be the normal of the circle, not the normal of the polygon. So we will probably have to think about it harder.
Maybe randomized smoothing? But I am not sure...
When I think about computing normal correctly, another obvious thing that comes to mind is just using the penetration vector direction as the normal: since the shapes are convex, the "shortest path to the surface" is going to be normal to the surface, and EPA effectively computes the shortest path to the surface in minkowski difference space. But, I am not precisely sure that being normal in minkowski difference space means being normal in normal space: it is going to be something in the lines of being normal 'simultaneously to both bodies' which is weird. Idk..
im going to extend the ball resolution to any shape, treating the EPA vector as the normal
perhaps will do time of impact. but only after the basic version is working
so this doesnt consider angular momentum yet, but I would prefer to merge it, and then have another PR for angular momentum, as there are still some things missing for it: like center of mass, or the function for produce mass matrix of the body, which I would like to put into the body class.
will do TOI after angular momentum I think
attempts #16
full (partially) elastic collisions for arbitrary shapes seem pretty difficult. so I started small for now