Skip to content

Instantly share code, notes, and snippets.

View UponTheSky's full-sized avatar
🎯
Focusing

UponTheSky UponTheSky

🎯
Focusing
  • Seoul
View GitHub Profile
@UponTheSky
UponTheSky / gist:d28f50709cc1282151abbde2c7853f89
Last active July 24, 2023 02:15
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.

Based On MIT 6.096 lecture node 5

  1. const int* var: var is a pointer to a const int
  2. int* const var: var is a const, which is a pointer to int
  3. const int* const var: var is a const, which is a pointer to a const int