Collision with more than two objects at once in code

  • Context: Undergrad 
  • Thread starter Thread starter Luke_M
  • Start date Start date
  • Tags Tags
    Code Collision
Click For Summary
SUMMARY

The discussion focuses on simulating simultaneous collisions in a physics model for a game involving multiple balls (A, B, C, D, E, and F) with defined velocities and masses. The key question is whether object E will receive any vertical velocity (Vy) after being hit by balls traveling horizontally and vertically. The consensus is that E will not receive Vy due to the nature of the collisions. Additionally, the conversation highlights the limitations of using sequential loops for collision detection and suggests exploring threading in programming languages like Java and C++ to handle simultaneous collisions more effectively.

PREREQUISITES
  • Understanding of basic physics principles, particularly momentum and collision dynamics.
  • Familiarity with programming concepts, specifically collision detection algorithms.
  • Knowledge of threading in programming, particularly in Java and C++.
  • Experience with game development frameworks that support physics simulations.
NEXT STEPS
  • Research "Java concurrency" to understand how to implement threading for collision detection.
  • Explore "collision resolution algorithms" to improve the accuracy of physics simulations.
  • Study "finite time collision response" to model real-world collision dynamics more effectively.
  • Investigate "physics engines" like Box2D or Bullet Physics for advanced collision handling techniques.
USEFUL FOR

Game developers, physics simulation programmers, and anyone interested in implementing realistic collision mechanics in interactive applications.

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.
 
Physics news on Phys.org
For programming I think that you need to take a look at a concept called "threading" not all languages support it, but Java does and I believe C++ does as well.

Here is a great place to start:
http://java.sun.com/docs/books/tutorial/essential/concurrency/

Plus why are you using loops, can't you just use a couple of equations to model this and just put those into your code?
 
IN the real world collisions don't happen "all at once". They take a finite amount of time, and the effects propagate through the bodies at the speed of sound, so if one side of a ball collides with something the other side of the ball doesn't "know" anything about that till a finite amount of time later. The typical speed of sound in a solid is a few km/sec, or a few mm per microsecond.

The easy way to program this is to pretend the balls are all a small distance apart. So in your example first, F collides with A and D collides with E (and those two collisions don't interact with each other).

Next, because D has slowed down, C collides with D, and so on.
 

Similar threads

  • · Replies 35 ·
2
Replies
35
Views
4K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 49 ·
2
Replies
49
Views
5K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 24 ·
Replies
24
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K