Skip to content

Instantly share code, notes, and snippets.

@UponTheSky
Last active July 24, 2023 02:15
Show Gist options
  • Save UponTheSky/d28f50709cc1282151abbde2c7853f89 to your computer and use it in GitHub Desktop.
Save UponTheSky/d28f50709cc1282151abbde2c7853f89 to your computer and use it in GitHub Desktop.
A proof of the vector decomposition in "Raytracing in One Weekend", section 10.2(Snell's Law)

This is a proof of the vector decomposition omitted in Raytracing in One Weekend, section 10.2(Snell's Law)

Let $R_{p}'$ be the decomposed vector perpendicular to the normal $n$, and $R_{n}'$ be the other decomposed vector parallel to $n$. Without loss of generality, we can assume $|R| = |R'| = 1$(this is omitted in the book). Also, let $p$ be a unit vector with the same direction as $R_{p}'$(so it is perpendicular to $n$ as well).

Now we can simply decompose $R' = R_{p}' + R_{n}'$ such that

$$R_{p}' = \sin\theta'p, \text{ } R_{n}' = -\cos\theta'n$$

Since the book shows the result of $R_{p}'$ first, let's investigate this one first.

By Snell's law, we have $R_{p}' = \frac{\eta}{\eta'}\sin\theta p$. Also, if we recall how we get the reflected vector in the above section 9.4 in the book, we can easily see that $\sin\theta p = R + \langle R, n \rangle n = R + \cos\theta n$(remember that $|R| = 1$!). Therefore, we have

$$R_{p}' = \frac{\eta}{\eta'}\sin\theta p = (\frac{\eta}{\eta'}\sin\theta)(\frac{1}{\sin\theta}(R + \cos\theta n)) = \frac{\eta}{\eta'}(R + \cos\theta n)$$ as desired.

On the other hand, $R_{n}' = -\cos\theta'n = -\sqrt{1 - \sin^{2}\theta'}n$(since we assume that $\theta$ and $\theta'$ are both acute angles), and $\sin\theta' = |R_{p}'|$, so we have

$$R_{n}' = -\sqrt{1 - \sin^{2}\theta'}n = -\sqrt{1 - |R_{p}'|^{2}}n$$

which is the same as what the book shows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment