How to compensate ray displacement caused by refraction in glass slab

I need a nudge in the right direction, i guess (this is not a homework question).

I want to calculate the total length of a ray from an emitter to a target which passes through a slab with known properties.

Given:

• Position of Emitter and Target $P_\text{Source}, P_\text{Dest}$
• Refractive indices of the slab and surrounding medium $n_1, n_2$
• position and thickness of the slab $d_1$, $d_2$, $d_3$ Question:

1. What angle of incidence $\theta_i$ is required for a ray cast from $P_{source}$ to intersect $P_\text{dest}$?
2. How long is the path the ray actually takes?

I know the incident ray is displaced parallely depending on angle of incidence and refractive indices. I have also found some equation for the determiantion of the offset, but i am still not sure how to apply it to my problem: $$\begin{equation}\tag{1} \Delta y = d_2 \tan \theta_i \left( 1- \frac{\cos \theta_i}{\sqrt{n^2 - \sin^2 \theta_r}}\right) \end{equation}$$

where $\Delta_y$ is the offset of the ray emerging from the slab.

Could you give me a few directions?

• Looks like an ideal use for Fermat's principle. – John Rennie Feb 19 '14 at 10:39
• Hint: if you know $\Delta_y$ and you know the thickness of the slab, you can figure out the (x,y,z) location of the exiting ray. – Carl Witthoft Feb 19 '14 at 13:06

$$\begin{equation}\tag{2} h_d = d_1 tan(\theta) + \frac{d_2 tan(\theta)}{n} + d_3 tan(\theta) \end{equation}$$
solved for $\theta$ this becomes
$$\begin{equation}\tag{3} \theta = \arctan \left( \frac{h_d}{d_1 + d_3 + \frac{d_2}{n}} \right) \end{equation}$$