Yuvan Sharma
23 Apr 2020: A 3D Printed Digital Sundial
23.04.20203 Min Read — In Coding

Introduction

I recently came across a project involving a 3D printed digital sundial on a YouTube channel Mojoptix. I was fascinated by this since it involved taking such an ancient invention, the sundial, and digitizing it to a level of amazing accuracy.

Approach

Since I have no access to a 3D printer, I was forced to rethink this project at an early stage. What I really had to do was simulate sunlight realistically. The Eureka moment came when I realized I could use the animating software Blender in order to run a simulation with sunlight and the sundial. I imported the digital design of the sundial into OpenSCAD. The sundial had the basic structure of a conventional one, but it also had slits to display hours, minutes and seconds. It had a pivot joint to adjust for latitude and came as one version for the northern hemisphere and a different version for the southern hemisphere.

The Mojoptix Sundial in OpenSCAD

The Mojoptix Sundial in OpenSCAD

I made some necessary adjustments and then imported the Sundial into Blender. In Blender, I placed the sundial on a plane, added a source of light and animated it according to the positions of the Sun at various times of the day. Then, I entered these coordinates into Blender and ran the animation. It worked perfectly on my very first try! The sundial displayed the time of the day in 20-minute intervals as the light source went from east to west, simulating the Sun.

Mathematical Details

What was important in this approach was to get the coordinate system of the Sundial correct in 3D space. The alignment was done with respect to 28.5deg North latitude for Delhi. It took some time for me to grasp the trigonometry details of how to calculate the Sun\rquote s path at each minute of the day. The Sun is positioned at a certain altitude from the horizontal and at a certain azimuth from geographical North. For any sundial arm of length R, the shadow can be calculated using the equations described at many websites. Initially, I tried to understand and program this from the site {{\field{*\fldinst{HYPERLINK https://www-spof.gsfc.nasa.gov/stargaze/Secliptc.htm }}{\fldrslt{https://www-spof.gsfc.nasa.gov/stargaze/Secliptc.htm\ul0\cf0}}}}\f0\fs22 . Eventually, I realized that the python pysolar library (from {{\field{*\fldinst{HYPERLINK http://www.pysolar.org }}{\fldrslt{http://www.pysolar.org\ul0\cf0}}}}\f0\fs22 ) does the same thing more easily. I then used pysolar by writing a python program as below:

Python program

Python program

The output of my python script gives for each time the exact x,y,z coordinates of the Sun. I positioned a light source in Blender at this position and then animated this over the course of the whole day. A screen shot is given below:

Sundial showing time as 14:20

Sundial showing time as 14:20

Conclusion

This project taught me a lot about how sundials work, the concepts related to the rotation of the earth around the Sun, as well as animation and simulation. I managed to use trigonometry for this program. Most importantly, I was able to prove my sundial worked even though I didn\rquote t have any 3D printer. I am now generalizing the program for positioning the sundial for any place on Earth for any given time and day. I really enjoyed this project because of the new skills that I learnt.