2
\$\begingroup\$

I need to calculate the new velocity vector when the ball collides with one of the paddle's corners.

Let d be the velocity vector of the ball, r the target velocity vector and n the surface normal used for reflecting the velocity vector.

I found that the formula to calculate the reflection vector is: r=d−2(d⋅n)n

My first thought was to create a vector using the coordinates of the paddle's corner and the ball's center, normalize it and use it as my surface normal n.

That way I have both d and n that I need to calculate the reflection vector.

enter image description here

But, after some more research I've come across the following article: Pool Hall Lessons: Fast, Accurate Collision Detection Between Circles or Spheres

which may be better since ball - ball collision is the same as the ball - point collision that I need.

The collisions are all elastic and forces like gravity and friction don't exist.

Is my approach wrong? If I end up doing this in any of the aforementioned ways, what are the advantages and disadvantages of each one of them?

EDIT: I forgot to mention that the post i linked doesn't contain any collision resolutions, but only collision detections, but it is what made me to think that searching for ball - ball collision resolutions is a better approach.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Your approach is equivalent to the approach linked in the article (they go on to collision resolution in later pages)except you assume that the paddle has infinite mass (i.e. the collision does not change the velocity of the paddle) and that the paddle is stationary (i.e. the balls speed does not increase after the collision).

Looking at the equations provided in the article the final velocities for the two objects are dependent on the masses of the two objects. If the second object is given an infinite mass then they become,

v1' = v1 - 2(a1 - a2) * n

and

v2' = v2.

Due to their definitions of the velocities v1 and v2, a1 = v1 . n and a2 = v2 . n. Due to the assumption that the paddle is stationary a2 = 0 and so final results are,

v1' = v1 - 2(v1n) * n

which is the same as you calculated.

Note here I have used bold to distinguish vectors from scalars (also assumed some knowledge of vector maths as you demonstrated it in your question but happy to explain if not clear).

\$\endgroup\$
7
  • \$\begingroup\$ Oh man, makes perfect sence if you assume infinite mass on the paddle, when i thought about how to implement the vector transformation on my own, i completely disregarded the objects' mass, silly me!! Your explanation is great, cleared some fog off of my mind. \$\endgroup\$
    – Mitsosp
    Dec 2, 2015 at 12:22
  • \$\begingroup\$ Cheers, the only potential problem I can see is if the paddle can move and the ball bounces off nearly horizontally then there may be another collision when the ball is moving away from the paddle (as in the paddle hits the ball from behind) which could cause some weird behaviour but should normally not be a problem \$\endgroup\$
    – Malrig
    Dec 2, 2015 at 12:30
  • \$\begingroup\$ Yes I thought the exact same thing, especially when the ball's speed is very small, a second collision is bound to happen almost immediately. I can think of two differenct ways to deal with this. The first is to add a very small timespan in which collisions are ignored, based on the speed and direction of the ball. The second one is, upon collision, to speed up the ball enough so it can break free before the second collision happens and the gradually reduse the speed to it's original value. \$\endgroup\$
    – Mitsosp
    Dec 2, 2015 at 12:36
  • \$\begingroup\$ My approach would depend on what the game is, if it is a brick breaker game then I would 'extend' the paddle hit box a small amount (<~ball radius/sqrt(2)) and treat it as an infinitely thin line. Then only consider the bottom of the ball when checking for calculations. This means that you ignore collisions where the ball won't then travel upwards and that if the ball is going to collide that its bottom never goes below the paddle so can't collide again. This has problems i.e. clipping on misses and bouncing early \$\endgroup\$
    – Malrig
    Dec 2, 2015 at 12:55
  • \$\begingroup\$ Your approach is actually very nice, but i don't get the "clipping on misses" part. What do you exactly mean? I don't mind bouncing early cause the difference will not be noticeable by the end user :P \$\endgroup\$
    – Mitsosp
    Dec 2, 2015 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .