Game Collision Physics

  • #1
I am currently programming a 2-dimensional game and am creating a class that will allow for collision detection with any polygon defined by a set of points. The actual collision detection was easy, however i am having trouble coming up with an equation to describe the resulting velocity vector of an object after the collision.

http://www.cheeseparade.com/diagram.png [Broken]

Based on the diagram above, can anyone give me an equation that will return the blue vector as a function of the green vector, regardless of the angle of the green vector? All the red points are known information at any given time.

Thanks,
Madison
 
Last edited by a moderator:

Answers and Replies

  • #2
diazona
Homework Helper
2,175
6
I'm not quite sure what I'm looking at here... what should the relationship be between the blue vector and green vector? Or in other words, what kind of physical situation are you trying to simulate? What happens to the object that collides with the polygon?
 
  • #3
when the object collides, the component of its velocity that is perpendicular to the edge that it collides with should be eliminated so that the object continues on a path parallel to the edge. i dont need to worry about bouncing at this point.
 
  • #4
diazona
Homework Helper
2,175
6
OK, I see... you're talking about a totally inelastic collision. I'm assuming you have (or can calculate) the velocity vector [itex]\vec{v}[/itex] as well as the vector pointing along the edge of the polygon in the direction of the blue arrow, which I'll call [itex]\vec{p}[/itex], and also that you either have or can write a function to take dot products. Then you can just project [itex]\vec{v}[/itex] on to [itex]\vec{p}[/itex] to get your final velocity:
[tex]\vec{v}\,' = \frac{\vec{v}\cdot\vec{p}}{\vec{p}\cdot\vec{p}}\ \vec{p}[/tex]

Incidentally, a general formula for inelastic collisions can be found on Wikipedia, http://en.wikipedia.org/wiki/Coefficient_of_restitution.
 
  • #5
Thank you! that equation worked perfectly.
 

Related Threads on Game Collision Physics

  • Last Post
4
Replies
93
Views
12K
  • Last Post
Replies
1
Views
2K
  • Last Post
7
Replies
154
Views
16K
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
1
Views
638
  • Last Post
Replies
20
Views
8K
Replies
1
Views
3K
  • Last Post
Replies
4
Views
1K
Replies
13
Views
2K
Top