Snell's Law
If you look more carefully at the figure on Transmission of Light, you will see that when the light slows down, it becomes more vertical: that is, it bends towards the normal. This is a general rule:
When rays speed up, they bend away from the normal.
The relationship between the angles is given by Snell's Law:
where $n_i$ and $n_t$ are the indices of refraction for the incident and transmitted materials, and $\theta_i$ and $\theta_t$ are the angles in both materials, always measured from the normal.
Notice that this equation is symmetric: if you swap the direction of the ray so that incident becomes transmitted and vice versa, then the angles remain the same.
You can play with Snell's Law using the script below: you can drag on the incident ray to change its angle, and you can choose indices of refraction from the spinners on the left. In particular, see what happens when you make the incident index larger than the transmitting index, and then slowly increase the angle of the incident ray.