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

Click For Summary
SUMMARY

The forum discussion focuses on calculating post-collision rotation in a Java physics engine after implementing wall collisions with elasticity and friction. The provided method, processWallCollision(Vector normal), utilizes vector projections to adjust the object's velocity based on collision dynamics. The user suggests introducing an impulse function to directly set the velocity of a specific point on the object, which could simplify the calculation of both velocity and rotation post-collision.

PREREQUISITES
  • Understanding of vector mathematics and operations
  • Familiarity with Java programming language
  • Knowledge of physics concepts such as elasticity and friction
  • Experience with collision detection and response in game development
NEXT STEPS
  • Research impulse-based physics calculations in game engines
  • Learn about vector projection techniques in physics simulations
  • Explore Java libraries for advanced physics simulations, such as JBox2D
  • Study rotational dynamics and how they apply to rigid body physics
USEFUL FOR

Game developers, physics engine programmers, and anyone interested in enhancing collision response and rotation calculations in simulation environments.

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.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 24 ·
Replies
24
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 60 ·
3
Replies
60
Views
7K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K