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

In summary, the conversation discussed the implementation of collisions with walls in a Java physics engine, including elasticity and friction. The question of how to calculate post-collision rotation was raised and a potential solution was proposed involving an impulse function that would set the velocity of a specific point in the object to a specified value.
  • #1
MTK
13
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
  • #2
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.
 
  • #3


To calculate post-collision rotation, you will need to consider the angular velocity of the object before and after the collision. This can be done by using the moment of inertia of the object, which is a measure of how difficult it is to rotate the object.

In your code, you are already calculating the normal and wall projections of the velocity, which are components of the linear velocity. To calculate the angular velocity, you will need to also consider the perpendicular distance from the center of mass of the object to the point of collision.

Once you have the angular velocity, you can use the angular momentum equation (L = Iω) to calculate the angular momentum before and after the collision. By conserving angular momentum, you can then solve for the post-collision angular velocity.

Depending on the shape and properties of your object, the moment of inertia may need to be calculated differently. For example, a point mass will have a different moment of inertia than a solid sphere. It is important to research and understand the moment of inertia for the specific object you are working with.

Once you have the post-collision angular velocity, you can use this to update the rotation of the object in your physics engine. This will allow you to accurately simulate the rotation of objects after collisions.

I hope this helps and good luck with your physics engine!
 

1. What is wall collision rotation?

Wall collision rotation is a phenomenon that occurs when an object collides with a wall or surface and changes its orientation or rotation as a result of the impact.

2. How does wall collision rotation affect objects?

Wall collision rotation can cause objects to change their direction of movement, spin or rotate around their axis, or bounce off the wall with a different trajectory.

3. What factors can influence wall collision rotation?

The speed, mass, shape, and angle of impact can all affect the rotation of an object after colliding with a wall. The surface material and texture can also play a role.

4. How can wall collision rotation be calculated or predicted?

Wall collision rotation can be calculated using principles of physics, such as conservation of momentum and energy. Computer simulations and models can also be used to predict the rotation of objects after a wall collision.

5. How is wall collision rotation useful in real-world applications?

Wall collision rotation is important in fields such as engineering, sports, and video game design. Understanding how objects rotate after colliding with walls can help with designing more efficient structures, predicting ball trajectories in sports, and creating realistic animations in video games.

Similar threads

Replies
14
Views
1K
Replies
25
Views
2K
  • Mechanics
Replies
5
Views
2K
Replies
22
Views
2K
Replies
13
Views
2K
Replies
3
Views
1K
  • Mechanics
Replies
1
Views
1K
  • Mechanics
Replies
3
Views
5K
Replies
33
Views
2K
Replies
4
Views
2K
Back
Top