The formula for calculating the hourlines on a horizontal sundial is:

**tan(angle) = tan(HA) x sin(lat)**

Where:

**angle = the resulting dial angle**

**HA = the hour angle of the sun, expressed in degrees **

lat = sundial site latitude, in degrees

To determine the dial angle, we need to determine HA, the hour angle of the sun. When the sun is on the meridian, it is close to 12 o'clock. We measure HA using the meridian as the reference. At 10 AM, the sun is two hours before the meridian. At 3:15 PM the sun is 3 hours 15 min after the meridian.

Since the earth rotates 360 degrees in 24 hours, that's 15 degrees in 1 hour. So 10 AM can be expressed as -30 degrees, 10:30 as -22.5 degrees, while 3 PM would be +45 degrees and 3:15 would be +48.75 degrees.

Using a spreadsheet the sundial angles can be computed for any time during the day (remember in some spreadsheet programs the angles are expressed in radians, so you must multiply degrees by pi divided by 180 to get radians:

**radians = (pi/180) x (degrees)**

You can use this mathematical framework for a BASIC program to compute the sundial hour angles for the hours from 6 AM to 6 PM on a horizontal dial located...in the example situated at 35º North latitude

**1 CLS**

2 ToRad = 3.14159/180

3 ToDeg = 180/3.14159

4 lat = 35

5 slat= sin(ToRad*lat)

6 FOR HA = -90 to 90 STEP 15

7 hrad = ToRad*HA

8 tangle = tan(hrad)*slat

9 dial = ToDeg*atan(tangle)

10 print dial

11 NEXT

12 END

The above code is normally all you need to lay out a very nice sundial. In this modern age, we use time zones. And these equations apply to the longitude of the time zone. If you live at a different longitude, you can apply a "longitude correction" (time zone offset) by changing line 6. For instance, if your longitude is 4.56 degrees east of your timezone central meridian, you would **add** 4.56 to the value for HA. Then line 6 would be:

**6 FOR HA = -90 + 4.56 to 90 + 4.56 STEP 15**

And to list the dial angle lines for every half hour, we would change the STEP value to 7.5 degrees, the value that represents one half hour steps in time:

**6 FOR HA = -85.44 to 94.56 STEP 7.5**

Have fun writing your own spreadsheet or BASIC code.