flash - Find radians reflection angle -



i'm coding simple flash game, learn flash , improve maths, i'm getting confused radians there new me.

what i've done far using mouse (click & release) shoot ball off in direction using radians. i'd happen when ball hits wall bounces off in it's reflection angle. eg. if ball hits right-hand-side wall travelling @ in radians of -0.65 should bounce in radians of -2.5

could please explain me how go doing this? thanks

if work radians, should (always) express them in pi, divide pi. make easier work , understand.

-0.65 rad = -0.207*pi rad -2.5 rad = -0.796*pi rad 

a full circle 2*pi. normal horizontal surface 0.5*pi (or -0.5*pi).

normal = 0.5*pi angle of incidence = + pi - 0.5*pi //edit: +pi, need invert direction angle of reflection = 0.5*pi - angle of incidence 

see reflection on wikipedia image , explanation. gives formula horizontal wall:

r = 0.5*pi - (i + pi - 0.5*pi) r = 2*pi -  r = -i //subtract 2*pi 

for example

i = -0.207*pi //gives r = 0.207*pi //for horizontal wall 

similar vertical wall:

r = 0 - (i + pi - 0) r = -pi - 

edit realized not correct. formula work, i has point in opposite direction. fixed it, correct now. if got time later, i'll include image explaining mistake , solution.


Comments