Line to point response
I'm doing a simple 2d physics engine and I'm trying to get a point to bounce off a line. I already know which line it is hitting, all the angles, ect... Any help appreicated (btw, my angles go ccw).
Generally this sort of thing is done with vector math rather than angles and trig. A simple way to 'bounce' an object is to reflect the velocity vector about the line (or plane in 3d) normal. The equation for vector reflection is:
v' = v - 2(v.n)n
Where n is the unit-length normal.
ToyBox 2D physics engine code/exe
Check out PhysicsEngine/PhysicalObject.cpp and look at the collisionResponse function for falling object. Do your bounces like that.
Check out PhysicsEngine/PhysicalObject.cpp and look at the collisionResponse function for falling object. Do your bounces like that.
Yes, and I'm still hacking away on it. :-D It's been in serious development for about 6 months off and on.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement