# Analog clock

• Sharebar

The TIMESENSOR of X3D is quite a complicated time mechanism to understand. As I have created some commands for easy animation, I thought that it would be interesting to test the TIMESENSOR with an analog clock.

The construction of an analog clock is very mathematical. I used a 2D disk (DISK) as the clock face and a rectangular torus (RECTORUS)  as the clock case. The hour and minute marks are done with scaled boxes (BOX). The second hand is a line drawn by the turtle. The hour and minute hands are faces drawn by the turtle as well using PD (pendown) and PU (penup).

The three hands all have the coordinate (0, 0, 0) as their centre. Therefore, when using the SPIN command with the right amount of seconds as their cycleIntervals, they just spin like a clock. I have also included some objects for you to click on so you can change the thickness of clock case and change colours of the clock. Now, time to play with my newly designed analog clock below.

To my surprise, the TIMESENSOR picked up my computer time (so should be your computer time when you are viewing this), and displays the time correctly. This is quite handy for my first construction of this analog clock. But there are still quite a few mysteries about the X3DOM's implementation of TIMESENSOR I need to try out.

Below are my LOGO program for this analog clock. Because it is quite long so I only included the clock part below.

Can you figure out how I did it in the above LOGO program?

If you are interest in the full program, you can try directly in VRMath2 Editor and open the analog_clock.logo in the Example drive (look in animation folder) in Logo Editor. I have also attached the files here if you wish to download.

PS: To get the Logo Editor window in VRMath2 Editor, you can click on the Window menu to find it, or from the File menu to Open Logo file, or simply click on the small pencil icon in Console window to get to Logo Editor. Then you can open some Logo examples from its Open icon.

Please leave me a comment, suggestions or questions below, or discuss in the forum your ideas.