Archive site for Autodesk Ecotect Analysis educational resources, notes and tutorials

Solar Position: Calculator

Below is an interactive tool for calculating the azimuth and altitude of the Sun at any date and time. Your first step in the use of this tool is to set the Latitude and Longitude of the desired location - making sure to first set the TimeZone value as this will make entering the longitude easier. In addition to the current Sun position, it also calculates Sunrise / Sunset times, the Declination and Equation of Time as well as the relative shadow length. To enter a value manually, remember to hit the Enter key.

It seems you are missing out on our interactive content. Please visit and update your browser with the latest flash plugin... or if you think your version of Flash should be okay, then click here to bypass this Flash detection.

Figure 1 - An interactive solar position calculator with additional information such as the Declination and Equation of Time as well as the relative shadow length for a vertical element of height h.
You can actually download this as a stand-alone Windows application as part of the Teaching_Tools package.

Manual Calculation Method

The algorith used in the interactive tool above to determine the position of the Sun from any location on Earth is outlined below. The azimuth and altitude of the Sun are calculated using formulae first proposed by Spencer (Spencer, 1965), then refined by Szokolay (Szokolay, 1996). Values for solar declination and the equation of time are determined using formulae proposed by Carruthers, et al [1990], as shown in the following pseudo-code.

Please Note: All angles are in radians, a common requirement of most implementations of trigonometric functions in programming languages and spreadsheets. Hence the (PI/180) conversion factors seen within the code.


Solar declination as per Carruthers et al:

Equation of Time

Equation of time as per Carruthers et al:

Then convert seconds to hours:

Solar Altitude

Calculate hour angle (in radians):

Then calculate current altitude (in radians):

Solar Azimuth

The calculation of azimuth (in radians):

Now, it would be great if all math libraries worked the same, because then the calculation of azimuth would be quite simple, as shown below.


Unfortunately life is a bit more complex so we have to do some quadrant checking. For this we will need the sin and cos values from which to work out which quadrant we are in.

NOTE: To avoid division by zero errors, first check:

if (Altitude < (p/2.0)) {
    sin1 = ts / cos(Altitude)
    cos2 = (t - u) / cos(Altitude)
else { 
    sin1 = cos2 = 0.0

Then do some more range checking, just for safety sake:

if (sin1 > 1.0) sin1 = 1.0;
if (sin1 < -1.0) sin1 = -1.0;
if (cos2 < -1.0) cos2 = -1.0;
if (cos2 > 1.0) cos2 = 1.0;

The next big issue is to check the quadrants:

if (sin1 < -0.99999) {
    Azimuth = asin(sin1);

else if (sin1 > 0.0) and (cos2 < 0.0) {

    if (sin1 >= 1.0) {
        Azimuth = -(PI/2.0);

    else {
        Azimuth = (PI/2.0) + ((PI/2.0) - asin(sin1));


else if (sin1 < 0.0) and (cos2 < 0.0) {
    if (sin1 <= -1.0) {
        Azimuth = (PI/2.0);

    else {
        Azimuth = -(PI/2.0) - ((PI/2.0) + asin(sin1));

else {
    Azimuth = asin(sin1);

Then a final last-ditch range check:

if (Azimuth < 0.0) and (LocalTime < 10.0) {
    Azimuth = -Azimuth

Simple, huh...

Javascript Solar Position Calculator

If you are unsure of the exact meaning of any of these formula, simply check the source of this page for a fully functional JavaScript implementation of it. The following HTML form uses the mathematical method described above to calculate a range of solar data at a particular date and time. Simply enter the latitude, longitude and time-zone of the desired location, set the required date and time, and then select the Calculate button.

NOTE: You must be careful to select the correct time zone to match the longitude of the site.

Latitude:  °
Longitude: °
Time Zone:
Required Date:
Local Time (24hr):
Declination: °
Equation of Time: minutes
Solar Altitude: °
Solar Azimuth: °
Solar Time: Hrs
Sunrise: Hrs
Sunset: Hrs

1/2 Hourly Solar Positions

This same method can be used to generate a list of solar positions over a particular day. The 1/2 Hourly Solar Position Calculator can be used for this purpose.


  1. Carruthers D, Uloth C and Roy G. G., 1990, An Evaluation of Formulae for Solar Declination and the Equation of Time, Research Report No RR17, School of Architecture, the University of Western Australia, Jan.

Useful Links

Approximate Solar Coordinates - U.S. Naval Observatory
Other Solar Position Calculators
NASA Information on Sundials
Solar Position
Solar Position: 1/2 Hourly


Average: 4 (22 votes)


User login

Translate Site To: