|
1372 | 1372 | function `atan2()`, which takes any pair of numbers proportional to sine and cosine and returns the
|
1373 | 1373 | angle, we can pass in $x$ and $z$ (the $\sin(\theta)$ cancel) to solve for $\phi$:
|
1374 | 1374 |
|
1375 |
| - $$ \phi = \text{atan2}(z, -x) $$ |
| 1375 | + $$ \phi = \operatorname{atan2}(z, -x) $$ |
1376 | 1376 |
|
1377 | 1377 | `atan2()` returns values in the range $-\pi$ to $\pi$, but they go from 0 to $\pi$, then flip to
|
1378 | 1378 | $-\pi$ and proceed back to zero. While this is mathematically correct, we want $u$ to range from $0$
|
1379 | 1379 | to $1$, not from $0$ to $1/2$ and then from $-1/2$ to $0$. Fortunately,
|
1380 | 1380 |
|
1381 |
| - $$ \text{atan2}(a,b) = \text{atan2}(-a,-b) + \pi, $$ |
| 1381 | + $$ \operatorname{atan2}(a,b) = \operatorname{atan2}(-a,-b) + \pi, $$ |
1382 | 1382 |
|
1383 | 1383 | and the second formulation yields values from $0$ continuously to $2\pi$. Thus, we can compute
|
1384 | 1384 | $\phi$ as
|
1385 | 1385 |
|
1386 |
| - $$ \phi = \text{atan2}(-z, x) + \pi $$ |
| 1386 | + $$ \phi = \operatorname{atan2}(-z, x) + \pi $$ |
1387 | 1387 |
|
1388 | 1388 | The derivation for $\theta$ is more straightforward:
|
1389 | 1389 |
|
1390 |
| - $$ \theta = \text{acos}(-y) $$ |
| 1390 | + $$ \theta = \arccos(-y) $$ |
1391 | 1391 |
|
1392 | 1392 | <div class='together'>
|
1393 | 1393 | So for a sphere, the $(u,v)$ coord computation is accomplished by a utility function that takes
|
|
2491 | 2491 | represents the normal vector. To get this, we just use the cross product of the two side vectors
|
2492 | 2492 | $\mathbf{u}$ and $\mathbf{v}$:
|
2493 | 2493 |
|
2494 |
| - $$ \mathbf{n} = \text{unit_vector}(\mathbf{u} \times \mathbf{v}) $$ |
| 2494 | + $$ \mathbf{n} = \operatorname{unit\_vector}(\mathbf{u} \times \mathbf{v}) $$ |
2495 | 2495 |
|
2496 | 2496 | The plane is defined as all points $(x,y,z)$ that satisfy the equation $Ax + By + Cz = D$. Well, we
|
2497 | 2497 | know that $\mathbf{Q}$ lies on the plane, so that's enough to solve for $D$:
|
|
3658 | 3658 | As the ray passes through the volume, it may scatter at any point. The denser the volume, the more
|
3659 | 3659 | likely that is. The probability that the ray scatters in any small distance $\Delta L$ is:
|
3660 | 3660 |
|
3661 |
| - $$ \text{probability} = C \cdot \Delta L $$ |
| 3661 | + $$ \mathit{probability} = C \cdot \Delta L $$ |
3662 | 3662 |
|
3663 | 3663 | where $C$ is proportional to the optical density of the volume. If you go through all the
|
3664 | 3664 | differential equations, for a random number you get a distance where the scattering occurs. If that
|
|
0 commit comments