# Формула вычисления преломляющего луча

## 2.2 Computing Caustics

Snell’s Law is not easy to code with this formulation, because it only imposes one restriction, making the computation of the refracted ray nontrivial. Assuming that the incident, transmitted, and surface normal rays are co-planar, a variety of coder-friendly formulas can be used, such as the one in Foley et al. 1996:

$\vec T = \vec N \left ( \frac{\eta_1}{\eta_2}\left( \vec E \cdot \vec N\right) \pm \sqrt {1+\left(\frac{\eta_1}{\eta_2}\right)^2\left(\left( \vec E \cdot \vec N \right )^2 -1 \right)}\right) + \frac{\eta_1}{\eta_2} \vec E$

Here T is the transmitted ray, N is the surface normal, E is the incident ray, and $\eta_1$, $\eta_2$ are the indices of refraction.