# Example: Refraction - Snell’s Law

Published 2012-03-25 | Author: Jimi Oke

When light travels from one medium to another (for instance, from light to water), its speed changes, causes the rays to bend. This phenomenon, called refraction, is governed by Snell’s Law, which states that the ratio of the sine of the angle of incidence to that of the angle of refraction is a constant (known as the index of refraction).

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Refraction
% Author: Jimi Oke
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{decorations.markings}
\tikzstyle arrowstyle=[scale=1]
\tikzstyle directed=[postaction={decorate,decoration={markings,
mark=at position .65 with {\arrow[arrowstyle]{stealth}}}}]
\tikzstyle reverse directed=[postaction={decorate,decoration={markings,
mark=at position .65 with {\arrowreversed[arrowstyle]{stealth};}}}]
\begin{document}
\begin{tikzpicture}

% define coordinates
\coordinate (O) at (0,0) ;
\coordinate (A) at (0,4) ;
\coordinate (B) at (0,-4) ;

% media
\fill[blue!25!,opacity=.3] (-4,0) rectangle (4,4);
\fill[blue!60!,opacity=.3] (-4,0) rectangle (4,-4);
\node[right] at (2,2) {Air};
\node[left] at (-2,-2) {Water};

% axis
\draw[dash pattern=on5pt off3pt] (A) -- (B) ;

% rays
\draw[red,ultra thick,reverse directed] (O) -- (130:5.2);
\draw[blue,directed,ultra thick] (O) -- (-70:4.24);

% angles
\draw (0,1) arc (90:130:1);
\draw (0,-1.4) arc (270:290:1.4) ;
\node[] at (280:1.8)  {$\theta_{2}$};
\node[] at (110:1.4)  {$\theta_{1}$};
\end{tikzpicture}
\end{document}