I am implementing ambient occlusion using a cosine weighted hemisphere. So far I assume that the hemisphere is centered about normal (0,0,1), which is pointing in the positive z direction. I cast rays about this hemisphere using zenith and azimuth angles $$0 < \theta < \pi/2, 0 < \phi < 2\pi$$, where the direction of the ray is computed as (sin theta cos phi, sin theta sin phi, cos theta).
How could I generalize this to work for an arbitrary normal?