PDA

View Full Version : Wall collision rotation


MTK
Oct29-09, 05:23 PM
I implemented collisions with walls in my Java physics engine, complete with elasticity and friction, but I am not sure how to calculate the post-collision rotation. Maybe you can help?

Here is the wall collision method (if you can understand it) :


public void processWallCollision(Vector normal) {
Vector wall = normal.rotate(Math.PI/2);
Vector normalProjection = velocity.projectOnto(normal);
Vector wallProjection = velocity.projectOnto(wall);
normalProjection = normalProjection.reverse();
normalProjection = normalProjection.scale(elasticity);
wallProjection = wallProjection.scale(1-friction);
velocity = normalProjection.add(wallProjection);
}

MTK
Oct30-09, 09:00 AM
I am thinking that it might actually be best to have am impulse function (similar to the apply force function), that would set the velocity of a certrain point (instead of increasing or decreasing it) in the object to a specified value, and calculating the velocity ant rotation from that.