Refraction and total internal reflection