7 ms·
Sure, but I get lost at the notations like big S, `|` and other things. Those notations seem to have many standards or I just can't see to follow. In pseudocod
by keyle 2y ago
Sure, but I get lost at the notations like big S, `|` and other things. Those notations seem to have many standards or I just can't see to follow.
In pseudocode, or any programming language, I'm right there with you.
- magicalhippo 2y agoI used to feel like you before I went to university and had a few math courses. Then it became a lot more clear. And it really isn't that bad in most cases, and isn't unlike how we learnt that "int 10h" is how you change graphics modes[1] in DOS back in the days. The "big S" is an integral, which is in most cases essentially a for-loop but for continuous values rather than discrete values. You integrate over a domain, like how you can for-loop over a range or discrete collection. The domain is written here as just a collection of continuous values S^2, so like a for-in loop, though it can also be from and to specific values in which case the lower bound is written subscript and the upper bound superscript. Similar to how you have a loop variable in a for-loop you need an integration variable. Due to reasons this is written with a small "d" in front, so in this case "dω_i" means we're integration (looping) over ω_i. It's customary to write it either immediately after the integral sign or at the end of the thing you're integrating over (the loop body). However dω_i serves a purpose, as unlike a regular discrete for-loop, integrals can be, lets say, uneven, and the "d" term serves to compensate for that. The only other special thing is the use of the absolute function, written as |cosθ_i|, which returns the absolute value of cosθ_i, the cosine of the angle θ_i. Here θ_i is defined earlier in the book as the vertical angle of ω_i relative to the surface normal at the point in question, which can be calculated using the dot product. So in programmer-like terms, it reads a bit like this in pseudo-code. function L_o(p, ω_o): integral_value = 0 for ω_i in S^2 do θ_i = dot(w_i, n) integral_value += f(p, ω_o, ω_i) * L_i(p, ω_i) * abs(cos(θ_i)) * dω_i return L_e(p, ω_o) + integral_value Note that the surface normal "n" is implicitly used here, typically it would be passed explicitly in code. What's special here is that unlike a normal for-loop, in math the changes in ω_i, represented by dω_i, are infinitesimally small. But in practice you can actually implement a lot of integrals by assuming the changes are small but finite[2]. Anyway, this wasn't meant as a full explanation of integrals and such, but just an attempt to show that it's not all gobbledygook. [1]: https://en.wikipedia.org/wiki/INT_10H https://en.wikipedia.org/wiki/INT_10H [2]: https://en.wikipedia.org/wiki/Riemann_sum https://en.wikipedia.org/wiki/Riemann_sum