I see many programs around allowing "simulating" a compass on a cellphone, just by specifying latitude and time. How do they work?
Which formula should I use to obtain sun azimut?

Sun_Az = f(latitude,longitude?,time)