# Integrating differential solid angle over the unit hemisphere

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?

• 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. Commented Dec 4, 2015 at 21:51
• 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? Commented Dec 4, 2015 at 21:58
• @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. Commented Dec 4, 2015 at 23:08
• @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? Commented Dec 4, 2015 at 23:08
• @chad There you go. I didn't use RegionIntersection, BTW. Commented Dec 5, 2015 at 20:47

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


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

π *)