Move calculation of azimuths and sides out of the rendering loop.