A ray can be reflected from a surface as follows. Let N_hat be the unit normal to the surface at the reflection point. Let A be a vector toward the source of the incoming ray, and B be the resulting reflected ray.
First resolve A into components parallel and perpendicular to the
surface normal:
A = A_par + A_perp where
A_par = (A dot N_hat) N_hat, and
A_perp = A - A_par.
Then B = A_par - A_perp
= 2 A_par - A =
2 (A dot N_hat) N_hat - A.
The angle of reflection equals the angle of incidence since
|A_perp| = |-A_perp| and the incident ray,
reflected ray, and surface normal are in the same plane since
A_perp and -A_perp are on the same line.
In IDL:
B = 2*total(A*N)*N - A
where N is the unit surface normal vector.