 Light rays travel through space in a straight line at approximately 300,000 km per second. As light passes through a transparent medium such as water or glass, its speed is decreased. For glass it's reduced to 200,000 km per second and for water the speed is 225,000 km per second. If the light enters into a medium perpendicular to the surface it passes straight through but at a slower speed. However if the light beam arrives at the medium surface at an angle not only will its speed be reduced but it will bend due to a process called refraction. To better visualize this phenomenon let's look at this diagram. As a beam of light reaches the surface of a medium the lower portion enters first and is slowed down. However the upper portion is still traveling at the speed of light until it arrives at the surface and enters. This speed difference at the top and bottom aspects of the light path causes it to pivot bending toward what is referred to as the normal. This is an imaginary line drawn perpendicularly to the surface of the material. Transparent materials have what is called a refractive index. This is the speed at which light travels in a medium compared to light traveling in a vacuum. For example typical glass has a refractive index of 1.33. This is calculated by dividing the speed of light in a vacuum 300,000 km per second by the speed of light in glass 225,000 km per second. The refractive index of air is 1.0003. Anytime a light beam travels from a medium with a low index of refraction like air to a medium with a higher index of refraction like glass the beam of light will bend toward the normal. Likewise when the beam of light exits a highly refractive medium into a medium with a low index of refraction the process is reversed. The bottom portion of the beam of light exits first and resumes at the speed of light with the top portion still at the speed determined by the medium. This causes the beam to pivot away from the normal line.