Im working on my first game ever and I have made a prototype for a 2D Pinball-simulation and after lotsa effort most off the collision detection is working just as I wanted it to do, but theres one equation Im not able to solve (or even find for that matter) and its when Im trying to calculate when and where the ball will hit the flipper (or the other way around).
I describe the ball as the four tuple (Pos, Velocity, Acceleration, radius) and the Flipper (Pivot, Angel, Angulary speed), well theres a few more parameters but they isnt nessesary for this problem.
Whats making it hard (for me ) is the fact that the flipper is moving with an angulary speed and the ball is moving in a stright line (every timestep that is).
At the moment Ill move the flipper and then check if hit did hit the ball, if it did I just move the ball and gives it it''s new speed. This works but sometimes the result gets a bit peculiar cos'' I pretend the ball stands still when I update the flipper and vice versa.
Sooo, Im hoping that someone could help me find the equation to solve the Collision time t and Collision Pos(x,y).
/Thanks

# Advanced (?) collision detection

Started by Monk73, Aug 09 2001 02:46 AM

6 replies to this topic

Sponsor:

###
#2
Members - Reputation: **351**

Posted 09 August 2001 - 04:13 AM

Your approach seems good but it sounds af if you''re suffering from the main problem with using fixed time steps: they work fine for things moving uniformly over the time step but if there''s a sudden acceleration part way through the calculations done at the beginning/end can become very inaccurate.

One solution is divide your timestep to avoid this. In this case divide it into before and after the collision. You will need to know the precise time of the collision, which you can get from e.g. interpolating the penetration distance of the ball and flpper (it should be negative then positive, indicating a collision at penetration = 0 at an itermediate time).

Knowing this time you can work out the motion up to this time, resolve the collision then work out the motion with the new velocity/velocities from this time to the end of the time step. As long as the collision is instantaneous, i.e. the ball and flipper are solid and so the collision takes no time to complete, this can work well.

One solution is divide your timestep to avoid this. In this case divide it into before and after the collision. You will need to know the precise time of the collision, which you can get from e.g. interpolating the penetration distance of the ball and flpper (it should be negative then positive, indicating a collision at penetration = 0 at an itermediate time).

Knowing this time you can work out the motion up to this time, resolve the collision then work out the motion with the new velocity/velocities from this time to the end of the time step. As long as the collision is instantaneous, i.e. the ball and flipper are solid and so the collision takes no time to complete, this can work well.

###
#3
Members - Reputation: **122**

Posted 09 August 2001 - 05:20 AM

Thx for the reply, maybe I should have been clearer.

I do exactly what u suggest: when I find a collision I''ll devide the timestep and continue to look for more possible collisions within that timestep, and it works great with all obstacles that doesnt move (walls eg. lines, arcs and cirkles, bumbers etc) and it should work just fine with obstacles that moves using the same equations as the ball (eg. a multiball situation).

My problem now is to find the right equation for the ball/flipper collision... and my limited knowledge in math . I need to solve the time and pos for the collision wich would be a peice of cake if the flipper had a similar movement as the ball but my head just hurts because of the angular speed of the flipper... I have read all my old mathbooks without any result..

Thx

I do exactly what u suggest: when I find a collision I''ll devide the timestep and continue to look for more possible collisions within that timestep, and it works great with all obstacles that doesnt move (walls eg. lines, arcs and cirkles, bumbers etc) and it should work just fine with obstacles that moves using the same equations as the ball (eg. a multiball situation).

My problem now is to find the right equation for the ball/flipper collision... and my limited knowledge in math . I need to solve the time and pos for the collision wich would be a peice of cake if the flipper had a similar movement as the ball but my head just hurts because of the angular speed of the flipper... I have read all my old mathbooks without any result..

Thx

###
#4
Members - Reputation: **351**

Posted 09 August 2001 - 05:32 AM

My problem now is to find the right equation for the ball/flipper collision... and my limited knowledge in math . I need to solve the time and pos for the collision wich would be a peice of cake if the flipper had a similar movement as the ball but my head just hurts because of the angular speed of the flipper... I have read all my old mathbooks without any result..

That''s why interpolation''s nice. Work out the positions at the start and end of the period in question, and work out the penetration at both times. For collision one should be positive and one should be negative. The time is then got from these. E.g. if the distance goes from 1 to -2 the collision is at time = 1/3 of the time interval.

If this is not accurate enough you can use quadratic interpolation. Work out the positions at the start end and middle of the period, then work out the penetrations at each time. Plotting these on a graph you can draw a curve joining them and the point of intersection is where the line crosses the dist = 0 axis.

That''s why interpolation''s nice. Work out the positions at the start and end of the period in question, and work out the penetration at both times. For collision one should be positive and one should be negative. The time is then got from these. E.g. if the distance goes from 1 to -2 the collision is at time = 1/3 of the time interval.

If this is not accurate enough you can use quadratic interpolation. Work out the positions at the start end and middle of the period, then work out the penetrations at each time. Plotting these on a graph you can draw a curve joining them and the point of intersection is where the line crosses the dist = 0 axis.

###
#5
Anonymous Poster_Anonymous Poster_*
Guests - Reputation:

Posted 10 August 2001 - 08:32 AM

I don''t understand the real point of your problem: Is it that you can''t calculate the exact point of time / impact position of the ball and flipper (collision detection) or is it the formula to apply to the ball in order to change it''s state (acceleration, velocity) as a response to a collision ?