B
B
BonBon Slick2019-12-13 17:26:03
Mathematics
BonBon Slick, 2019-12-13 17:26:03

Calculating direction of objects after collision in 2D?

Example 1: There are 2 circle shaped objects that have width, height, mass and speed with direction.
Example 2: There are 2 square or rectangle shaped objects that have width, height, speed and direction.
All this in 2D.
How to correctly calculate the direction after a collision, general principles?
What are the built in methods of cocos2d?
Mathematical formulas?
UPD: Here's what I found, while everything is blurry.
https://stackoverflow.com/questions/9424459/calcul...
https://www.gamedev.net/forums/topic/57493-calcula...
https://stackoverflow.com/questions/23533395/colli. ..
https://gamedev.stackexchange.com/questions/119606...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2019-12-14
@BonBonSlick

For a circle (by the way, why the width and height, and not the diameter?) everything is quite simple, for the reason that the impact is always central.
1. Find the coordinates of the objects at the moment of collision, as well as the coordinate of the touch point. To do this, you can go to the inertial reference system associated with one of the objects. In this frame of reference, one object will be stationary and everything is simplified. After finding the coordinates, you can transfer them to the original reference system.
2. https://ru.wikipedia.org/wiki/Impact#Absolutely_elastic...
here all the formulas are written and explained.
It's harder for a rectangle... I'm afraid it's much more difficult. In the general case, the impact is not central, it is no longer possible to consider a rectangle as a material point, moments of impulses will appear, some integrals must be fenced ... Perhaps numerical methods will turn out to be simpler. Here I pass, it is necessary to spend a lot of time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question