An interesting pheomenon occurs when light travels from one transparent
material to another; light beams actually change directions. This bending
at the surface of transparent objects is called refraction. Refraction can
be looked at much the same way as reflection. Once again, we have a normal,
but this time, it's extended into the materal, and the angle of refraction
is measured with respect to the extended normal. The larger the angle of
incidence, the larger the amount of bending.
The amount of bending not only depends on the angle of incidence, but also an optical property of the material itself called the index of refraction. Snell's law is a mathematical relationship that predicts the refracted angle given the incident angle and the type of material. If no refraction takes place, the index of refraction is 1. Very little bending occurs when light goes from vacuum to regular air, and so its index of refraction is only very slightly greater than 1. The higher the index of refraction of a material, the more light bends when entering it at a certain angle of incidence.
Light coming into the material from the air bends toward the normal. If
the light originates from a material with a higher index of refraction to a
lower one, the light bends away from the normal.
Rainbows are caused by another aspect of refraction called dispersion. Light waves of different frequencies (colors) bend different amounts. In most cases, this is not noticable, but prisms make use of this to spread out the spectrum so we can see all of the colors. Violet light bends the most, with each color bending a little less up to red, which bends the least.