1
$\begingroup$

When reading about rendering topics I commonly run into integrals over a hemisphere similar to this one:

$\int_\Omega n \cdot l \, d\omega$

If I want to put that in Mathematica then I can re-parameterize everything in polar coordinates:

$\int_{0}^{2\pi}{\int_{0}^{\frac{\pi}{2}}{\cos\theta \sin\theta \, d\theta}\, d\phi}$

But it's difficult and error prone to switch back and forth while attempting to follow along with a paper or other source.

Is there a more direct way to solve the original integral?

$\endgroup$
5
  • $\begingroup$ Since version 10 Integrate can operate over regions (see the fourth syntax form in the Integrate documentation). Just define a hemisphere and integrate over it. $\endgroup$ Commented Dec 4, 2015 at 21:51
  • $\begingroup$ Unfortunately as far as I can tell with region integration you don't get access to things like surface normal vectors, so the utility is a bit limited. Chad, can you include n,l that gets you that expression? $\endgroup$
    – george2079
    Commented Dec 4, 2015 at 21:58
  • $\begingroup$ @george2079 Ah, sorry I wasn't clear on that. In my examplen would be constant - the normal at some point on a surface. The hemisphere is over that point. And l the direction of incoming radiance, so a point on the unit hemisphere. Which I guess would also the normal on the hemisphere, actually. $\endgroup$ Commented Dec 4, 2015 at 23:08
  • $\begingroup$ @Sjoerd Thanks! That seems to be what I need. Integrate[Dot[{0, 0, 1}, {x, y, z}], {x, y, z} \[Element] RegionIntersection[Sphere[], ImplicitRegion[z > 0, {x, y, z}]]] and Integrate[ Cos[\[Theta]] Sin[\[Theta]], {\[Theta], 0, Pi / 2}, {\[Phi], 0, 2 Pi}] both give me pi. Can you submit your comment as an answer? $\endgroup$ Commented Dec 4, 2015 at 23:08
  • $\begingroup$ @chad There you go. I didn't use RegionIntersection, BTW. $\endgroup$ Commented Dec 5, 2015 at 20:47

1 Answer 1

1
$\begingroup$

Since version 10 Integrate can operate over regions (see the fourth syntax form in the Integrate documentation). Just define a hemisphere and integrate over it.

Example:

(
 ir = ImplicitRegion[z > 0 && x^2 + y^2 + z^2 == 1, {x, y, z}]
) // DiscretizeRegion // RegionPlot3D

enter image description here

Integrate[{0, 0, 1} . {x, y, z}, {x, y, z} ∈ ir] 
Integrate[Cos[θ] Sin[θ], {θ, 0, Pi/2}, {ϕ, 0, 2 Pi}]
(* π

π *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.