Version 9 of counterclock

Updated 2005-05-20 13:19:47 by AM

if 0 {Richard Suchenwirth 2005-05-19 - Mathematicians are well aware of the importance of counterclockwise orientation. For the rest of us, who wonder how it looks like, here's a counterclock that goes the other way round, strongly based on a little A-D clock :) The direction is in the global variable sense - click on the window to reverse it.

http://mini.net/files/counterclock.gif }

 proc main {} {
    set ::sense -1
    pack [canvas .c -width 100 -height 100]
    for {set i 1} {$i<13} {incr i} {
        set a [expr {$i/6.*$::sense*acos(-1)}]
        set x [expr {50 + 43 * sin($a)}]
        set y [expr {50 - 43 * cos($a)}]
        .c create text $x $y -text $i -tag t
    }
    every 100 {drawhands .c 50 50}
    bind .c <1> {set sense [expr -$sense]; .c scale t 50 50 -1 1} 
 }
 proc drawhands {w xm ym} {
     $w delete hands
     set secSinceMidnight [expr {[clock seconds] - [clock scan 00:00:00]}]
     foreach divisor {30 1800 21600} length {40 35 30} width {1 2 3} {
         set angle [expr {$secSinceMidnight*$::sense*acos(-1) / $divisor}]
         set x [expr {$xm + $length * sin($angle)}]
         set y [expr {$ym - $length * cos($angle)}]
         $w create line $xm $ym $x $y -width $width -tags hands
     }
 }
 proc every {ms body} {eval $body; after $ms [info level 0]}

 main

AM (20 may 2005) I could not resist commenting on the introductory remarks :)

Quite apart from clockwise and counterclockwise directions, there is also the matter of using the positive x-axis as the reference, instead of the positive y-axis. This is all about conventions, of course, but you would be surprised by the confusion they may cause - see Angles and directions for an earlier "lamentation" on the subject.

In short: a mathematician (and, by proxy, a physicist) would devise a clock running from 0 to 11, where the 0 mark is at the right and the hands move in a leftward direction - counterclockwise you might say, but if such a clock were standard, it would not be a counter direction ...

CLN Ah, handism rears its ugly head again! Speaking as a lefty, I have to ask, Why is a right-handed coordiate system better than a left-handed one? ;-)

AM (In a conspiratory voice, as a fellow-lefty) In a right-handed system you actually rotate things leftwise! There have been rumours that the universe is right-handed - but I take that to be a vile plot ...


Category Toys - Arts and crafts of Tcl-Tk programming