- #1
hadyn
- 3
- 0
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,
Hadyn
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,
Hadyn