# Simple reflection question

1. Jul 29, 2008

Hello there,

Let me start by saying this question is going to make me look somewhat ridiculous considering the complexity of most other questions floating around here, but I'm not a maths or physics student and never have been; rather I'm a graphic designer with a basic query in relation to a game I'm making in flash. That said, forgive me if I don't use the right terminology, so far I'm more or less entirely self taught in what basic physics I know.

So here's the problem:

I have a ball moving in 2D with independent x and y velocities. That ball collides with a curved shape - when this happens, I'm able to find the tangent at which it collides - the effect I want to achieve is simply of the ball bouncing from that tangent in the correct reflected direction (with no concern for fricition, gravity or anything like that).

So, for example, say the ball's x velocity is 4 pixels per second and the y velocity is 2 pixels per second (flash is upside down, a positive y value actually implies downward movement), and it hits the curve at a 35 degree tangent - how do I find what the new x and y velocities should be?

I've been working on this all night and I've come quite close - using various sine functions I was able to at least make the ball retain the same overall velocity when it bounced, but I can't for the life of me get it to bounce in the right direction and I'm not sure why, so I figured it'd be pointless showing you guys my code which doesn't work if someone can simply offer a method that does.

In short:

I have the x and y velocities (and therefore the overall speed and direction) of a ball and the angle of the tangent at which it hits a curve. I need to set new x and y velocities to make it appear to have bounced off naturally - how?

Thanks heaps for any help,

2. Jul 29, 2008

### Staff: Mentor

Since you have the angle that the velocity makes with the tangent, try this. Find the components of the velocity parallel and perpendicular to the tangent. During the collision, the parallel component will remain unchanged but the perpendicular component will be reversed.

You'll have to work out the details of converting back and forth between x&y and parallel & perpendicular. Should be straightforward.

3. Jul 29, 2008

Whilst I'm slightly confused by some of those terms, that at least sounds pretty much like what I've been trying, but I still don't know the exact methodology. It's not really a case of being able to work it out, it's a case of simply not knowing how to use the tools available (sine functions, etc).

Assume I know very little about math. It's been years since highschool and beyond the most basic use of Pythagoras I've more or less forgotten everything I'd learned. Before reading up on it yesterday, I had no idea how any of those angle functions worked, and because it's such a new concept and I've already got my brain full of other new concepts in terms of hit detection and other code I've been writing, I just... can't figure it out. I'm willing to admit I've gone completely brain dead. Not only that, but I've probably tried too many different things to get it working now that what I have is way too complex and confusing and relies on too many variables, any of which could potentially be wrong.

At the very least I've been able to make my application draw three lines: the trajectory when it hits, the tangent, and the desirable reflected trajectory... so I'm assuming that means my angles are okay - I just can't seem to get the proper new x and y velocities so that it actually takes up this new trajectory.

I'm more or less asking for an exact methodology, if you can. I'd love to be able to work this out for myself, but without knowing how it's done at all I feel lost.

Thanks heaps,