How can I calculate post-collision rotation in my physics engine?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
MTK
Messages
13
Reaction score
0
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) :

Code:
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);
}
 
Physics news on Phys.org
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.