Instant Non-sequencial Calculation of colisions b/w objects

  • Thread starter Thread starter Luke_M
  • Start date Start date
  • Tags Tags
    Calculation
AI Thread Summary
In the discussion, a scenario is presented where multiple balls (A, B, C, D) are moving to the right at a velocity of 1, colliding with a stationary ball (E), while another ball (F) moves downward at the same velocity and collides with ball A simultaneously. The main questions revolve around whether ball E will gain a vertical velocity (Vy) from the collisions and how to calculate the new velocities of the balls post-collision for a physics model in a game. The conversation shifts to programming challenges in simulating simultaneous collisions. One participant suggests using threads for parallel processing, while another advises against this due to the unpredictability of thread execution. Instead, they recommend maintaining separate current and next values for each entity, allowing for accurate calculations of new velocities in a controlled loop iteration. This method ensures that all collisions are accounted for without the inaccuracies that can arise from sequential processing.
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:
Technology 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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top