Sundial simulation

  • Email
  • Sharebar
  • Email
Andy's picture

Some weeks ago, I have implemented the lighting components in VRMath2 Editor. There are three different lights: point light, directional light, and spotlight. In this blog, I am using the directional light to simulate the sunlight for casting a shadow on a sundial.

The idea is that directional light does not concern about its location. Therefore, we can place a directional light anywhere in the 3D space. Of course, the direction of the directional light will be the direction of the turtle. So we can rotate the turtle to the direction or orientation we like, then insert a directional light. Once a directional light is inserted into the 3D virtual world, it simulates the sunlight as shinning from a far away place and all the light rays are parallel.

In the virtual world created by VRMath2 Editor, the lighting and/or shadow effects will be calculated and displayed instantly (Virtual Reality). I then came up with an idea to animate the directional light, so it will simulate the sun rising from the east and set to the west.

Below are the simulation and programming codes.

As can be seen in the virtual world, we are facing north so east is on the right. I did this because Australia is in southern hemisphere, and the sun will pass through the northern part of the sky. In the program below, I also tilt the light to 23.5 degrees so the shadow will cast on the southern part of the ground.

I set the rotation cycle to 24 seconds for a day, so during the 12 seconds of day time, you should be able to see the shadow moving from the west to the east. And I bet you know why the shadow is moving from west to east.

There are some questions you may have for this simulation.

  • If you can trace and plot the shadow, what will be the path of the shadow? Is it a straight line or a curve? 
  • Can you describe the movement of the shadow with regards to speed, length and time?
  • For the purpose of observing the shadow, I set a 23.5 degree tilt to the directional light. What do you think when this will happen? and where it will happen?
  • If it is on an equinox day, and this sundial is located at equator, what will be the shadow during the day? How short can the shadow be during the day time?

Please leave me a comment about what you think. enlightened

Files: sundial.logo sundial.x3d


aleciarose's picture

That's was incredibly

That's was incredibly awesome. It was performed brilliantly.  Can we plan a rotation cycle and direction path similar to this sundial?
Visit our website -

Facebook Comments Box