Two colliding circles, unable to convert the formula into code

I am at a level where I can detect circle collisions in my physical physics 2D physics program. These circles have a random speed x, y. When any of them hits any of them, I can say that they collide with each other then! this step is a problem. I am trying to take the speed values ​​X and Y and convert them based on the axis of the collision point, I mean the axis of normal force and another axis that is perpendicular to the axis of normal force. The perpendicular axis is called the tangent axis ... right?

I use sin cos tan, but the problem is that since sin cos tan only returns the angle, which is always the right side, my objects never move to the left ... so that the momentum of the X axis of all the colliding objects is fixed on the right side. This leads to a lot of problems, and I cannot figure out how to fix it. I would appreciate even a little advice. Thanks.

+4
source share
1 answer

You should not use trigonometric functions (sin, cos, tan, etc.).

You want to apply momentum to objects in the direction of the collision, i.e. the momentum is a multiple of the collision direction vector. Calculate the momentum of objects and just add momentum.

If you perform simple elastic collisions, momentum and energy are saved. Given these limitations, you can calculate momentum. This wikipedia article has details.

+1
source

Source: https://habr.com/ru/post/1391125/


All Articles