# Understand geometry calculation about light interference

My question is about interference of light through a thin layer of some material. This image shows how one can easily calculate using basic geometry whether you will have positive/constructive or negative/destructive interference: http://imgur.com/a/xfsiE The goal of those calculations is to obtain the path difference between the rays r1 and S1.

An additional image that shows the path followed by the incoming light under an angle theta1: http://imgur.com/a/G7Tr6

However the very last step is unclear to me. How do you get "2anCos(theta)"? (This formula shows the requirements for positive interference). Using very easy geometry one know that cos(theta) = adjacent/hypothenusa

So I don't even see how you can get the form "adjacent.cos(theta)". Could somebody please explain this to me?

$${2an\over\cos\theta_2}-2a\tan\theta_2\sin\theta_1={2an\over\cos\theta_2}-2a{\sin\theta_2\over\cos\theta_2}\sin\theta_1={2a\over\cos\theta_2}\left(n-\sin\theta_2\sin\theta_1\right)$$
Now we can use the Snell's law: $n_1\sin\theta_1=n_2\sin\theta_2$ with $n_1=1$ and $n_2=n$, so:
$${2a\over\cos\theta_2}\left(n-\sin\theta_2\sin\theta_1\right)={2a\over\cos\theta_2}\left(n-n\sin^2\theta_2\right)=2an\cos\theta_2$$