Instant Non-sequencial Calculation of colisions b/w objects

  • Thread starter Thread starter Luke_M
  • Start date Start date
  • Tags Tags
    Calculation
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
Luke_M
Messages
10
Reaction score
0
Balls A,B,C,D are traveling at V=1 to the right next to each other like a train they hit ball E whom is stationary. At the exact instant ball F is traveling down and hits A, F is traveling at V=1 but down

Here is a diagram this is birds eye view:

*=collision
both collisions have happened at the same time
|
|
V
F
*
-------->ABCD*E



A: Vx=1 m=10
B: Vx=1 m=10
C: Vx=1 m=20
D: Vx=1 m=10
E: Vx=0 m=60
F: Vy=1 m=10

will object E receive any Vy ?
why not ?
what are the new V's ?
I need to know how to work this out as I am making a physics model in my game.

If you are a programmer maybe you can also answer this question:
In the real world collisions can happen all at once like in my above example. How can I do this in code ? I can only do them sequentially with for loops. is this normal practice in constructing a physics engine. Because if I do the collision between F and A after the other collisions A's new V will incorrectly not be included in the calculation.
Thanks in advance.
 
Last edited:
Physics news on Phys.org
Luke,

The physics part I cannot easily help you with. As for the programming part, when you want multiple things to happen in parallel you use threads. A thread is a lightweight process. Each thread gets a timeslot much like a process does in a multiprocessing operating system. This is the closest you will get to having them run non-sequentially. I hope this helps.

Ryan
 
I would not use threads for this because their time slices are unpredictable: some threads will sleep longer than others, causing your model to also be unpredictable. Instead, I would maintain two sets of values for each entity in your model: current values and next values. At each iteration of the loop, use the current values as input in the calculation of the next values. At the end of the loop, set the current values to the 'next' values you just calculated for use in the next iteration.