Calculating the Reflexion from a slope

i working on some collision detection, currently on bumping a ball from a slope/diagonal line.
i use the projection of the ball’s direction on the slope to get the impact point and test, if the
normal from this point to the ball’s center is <= the radius of the ball.

now im searching for a good way of getting the reflection vector. the incoming angle is the
same as the outgoing one … but my try looks a little too elaborately…

any good hints ?

I quickly punched some numbers into a calculator. Try the following formula:


xNew = 2*cos(u)^2*vx - 2*cos(u)*sin(u)*vy - vx
yNew = -2*sin(u)*cos(u)*vx - 2*cos(u)^2*vy + vy

u is the angle of the ball velocity with the edge, vx and vy are coordinates of the velocity.

I could have made a typo somewhere, but I can explain or correct at some other time.