equal
deleted
inserted
replaced
339 * Bounces from straight wall in any direction. |
339 * Bounces from straight wall in any direction. |
340 * Direction given as normal of that wall |
340 * Direction given as normal of that wall |
341 */ |
341 */ |
342 void PhysicsObject::bounce (Vector normal) { |
342 void PhysicsObject::bounce (Vector normal) { |
343 Vector tangent(normal.y, -normal.x); |
343 Vector tangent(normal.y, -normal.x); |
344 Vector tprojection = (velocity * tangent) / tangent.length(); |
344 Vector tprojection = (velocity * tangent)*tangent / (tangent.length()*tangent.length()); |
345 Vector nprojection = (velocity * normal) / normal.length(); |
345 Vector nprojection = (velocity * normal)*normal / (normal.length()*normal.length()); |
346 velocity = tprojection - nprojection; |
346 velocity = tprojection - nprojection; |
347 } |
347 } |
348 |
348 |
349 /*bool PhysicsWorld::collided (Vector oldPos, Vector newPos) { |
349 /*bool PhysicsWorld::collided (Vector oldPos, Vector newPos) { |
350 return false; |
350 return false; |