Refraction is what happens to light when it passes from one medium to another. For example, things appear differently from the bottom of a swimming pool than on the top. Simplistically, refraction is the bending of light. The explanation for this phenomenon, however, can be described with light as rays and light as waves. No matter the case, it is important to remember that the speed of light is constant in every homogeneous medium, regardless of shape, size or form.
The index of refraction
Light travels ( in certain substances ) at a fraction of the velocity if it travelled in a vacuum. The index of refraction is the inverse of this fraction. Thus, this number is greater than or equal to 1. This index is also specific to light, so different light in different mediums have different indices. For example, here is a table of indices:
Air at STP 1.00029
Water at 20 C 1.33
Ethyl alcohol 1.36
Sugar solution(30%) 1.38
So let's observe the effect of refraction in terms of rays. A ray strikes the surface between substance I and substance R. The angle i between the incoming ray and the normal vector at the boundary is called the angle of incidence, and the angle r between the refracted ray and the normal vector on the opposite side is called the angle of refraction.
This is related in the following law, called Snell's Law: ni sin i = nr sin r. For red light in air hitting water this gives sin r = sin i/1.33
Solving for Snell's Law for r gives the relation r = arcsin (sin i/n)
In simple ray tracing, a ray originates at a point P at a directional vector v, which is of unit length. This is the set of all points P+tv where t is a non-negative scalar. When the ray hits the boundary between two different substances, it will refract, and begin a new ray.