Also, the wiki doesn't show how they got their formulas for the paths of the reflected (AD) and refracted (AB and BC) rays, which could help understand where the formula comes from.
Segment AB forms the hypotenuse of a right triangle with two legs: d, and half the distance of AC. Let's call that halfway point between A and C the letter "E" to help the math.
For segments AB and BC, we know the angle of ACE is θ₂ and we know the length of θ₂'s adjacent leg, d. Channeling SOHCAHTOA, we know that cos(θ₂)=adjacent/hypotenuse=d/AB.
Multiply both sides by AB:
ABcos(θ₂) = d
Divide both sides by cos(θ₂) to solve for AB:
AB=d/cos(θ₂)
AB is equal to BC, and as we'll see later, AB+BC is necessary to solve the OPD equation
AB+BC=2d/cos(θ₂)
For AD, we first need to find the length of AC, which is the hypotenuse of a right triangle of which one leg is AD (the other is DC).
To find AC, we just need to find 2AE, which we can do by going back to our previous triangle for finding AB. AE is the other leg of that triangle, so we can say that tan(θ₂)=opposite/adjacent=AE/d.
Multiply both sides by d to solve for AE:
AE=dtan(θ₂)
AC=2AE=2dtan(θ₂)
Since we know that the angle of ACD is θ₁ and we now know that the hypotenuse AC is 2dtan(θ₂), we can use sin(θ₁) to determine AD:
sin(θ₁)=opposite/hypotenuse=AD/AC=AD/2dtan(θ₂)
Multiply both sides by 2dtan(θ₂) to solve for AD:
AD=2dtan(θ₂)sin(θ₁)
So that's how they got the path lengths you see right before the part that says "Using Snell's law..."
Now that we know the refracted path length AB+BC and the reflected path length AD, we can get to work on solving the OPD equation:
OPD=n₂(AB+BC)-n₁(AD)
OPD=n₂(2d/cos(θ₂))-2dtan(θ₂)n₁sin(θ₁)
Now we use Snell's law, which states that the product of the index of refraction of air (n₁) and the sine of the reflected angle, sin(θ₁), is equal to the product of the index of refraction of the film (n₂) and the sine of the refracted angle: sin(θ₂): n₁sin(θ₁)=n₂sin(θ₂).
We want to substitute n₂sin(θ₂) for n₁sin(θ₁), eliminating the need for the index of refraction of air:
OPD=n₂(2d/cos(θ₂))-2dtan(θ₂)n₂sin(θ₂)
Using the trigonometric function tan=sin/cos, we can create a common denominator:
OPD=n₂(2d/cos(θ₂))-2d(sin(θ₂)/cos(θ₂))n₂sin(θ₂)
Combine sines and combine common products:
OPD=(2n₂d/cos(θ₂))-2n₂d(sin²(θ₂)/cos(θ₂))
OPD=2n₂d((1-sin²(θ₂))/cos(θ₂))
Since we know that sin²(θ)+cos²(θ)=1, then 1-sin²(θ)=cos²(θ)
Substituting cos²(θ) for 1-sin²(θ):
OPD=2n₂d(cos²(θ)/cos(θ₂))
Remove extra cosine term and you get the final equation:
OPD=2n₂dcos(θ₂)