Separating Axis Theorem's collision responce
BlitzMax Forums/BlitzMax Beginners Area/Separating Axis Theorem's collision responce
| ||
Hi, been messing with the SAT. Got checking overlapping shapes figured out, now trying to move shapes to contact. I have an octagon that can be moved about with the arrow keys, and some rectangles that remain stationary. From the collision I have the following info: 1: how far you need to push the octagon away to get out of the collision. 2: the direction vector away from collision (a normal) 3: some edge/vertex stuff Only problem is that I don't want to move directly out of collision (I check if polys overlap before moving) - I want to know how far I can go along the velocity vector before colliding. So I got the velocity vector and the normal vector pointing to two different places. I have the length of the normal. ![]() I recall something called the sinus relation A/sin(a) = B/sin(b) = C/sin(c) I know (read: have no idea) that C = ?, sin(c) = 1, A = velocity.length-info.length, sin(a) = velocity direction Basically I wrote this and everything went crazy: Local contactDist# = (velocity.length()-info.depth)/Sin(ATan2( velocity.y, velocity.x )) move(velocity.x/velocity.length()*contactDist, velocity.y/velocity.length()*contactDist) Please help a poor coder :S Full source code here: img http://www.recursive.dk/files/sat_experiment.bmx |