[Arjen Markus] (19 december 2003) I intend this page for collecting a few examples to show with my "mathematical notebook". ---- '''Example: Constructing a cycloid''' ---- # Explain the construction of a cycloid # # Note: # We use a simple animation technique here # # Initialisation: define the procedure that takes care of drawing # @init { # Notes: # - Time must start at zero! # - The first time we do not want the animation # set stop 1 proc drawCycloid {time deltt} { variable CNV variable width variable height variable radius variable stop $CNV delete all # # Draw the circle at the right position # set xcentre [expr {$time+$radius}] set ycentre [expr {$height-1-$radius}] set xleft [expr {$xcentre-$radius}] set xright [expr {$xcentre+$radius}] set ytop [expr {$ycentre-$radius}] ;# Signs are correct! set ybottom [expr {$ycentre+$radius}] $CNV create oval $xleft $ytop $xright $ybottom -outline gray -width 2 # # Draw the spoke # set angle [expr {$time/$radius}] set xend [expr {$xcentre-$radius*sin($angle)}] set yend [expr {$ycentre+$radius*cos($angle)}] $CNV create line $xcentre $ycentre $xend $yend -fill black # # Draw the cycloid # set t 0.0 set xend $radius set yend [expr {$height-1}] while { $t <= $time } { set angle [expr {$t/$radius}] set xbegin $xend set ybegin $yend set xend [expr {$t+$radius-$radius*sin($angle)}] set yend [expr {$ycentre+$radius*cos($angle)}] $CNV create line $xbegin $ybegin $xend $yend -fill black set t [expr {$t+$deltt}] } # # Careful: we need to call this procedure from the global namespace # set time [expr {$time+$deltt}] if { $time < $width && $stop == 0 } { after 100 [list [namespace current]::drawCycloid $time $deltt] } else { set stop 0 } } }

Constructing a cycloid

(Press the Refresh button to see the construction at work)

@canvas 500 100 { set width [$CNV cget -width] set height [$CNV cget -height] set radius [expr {$height*0.4}] set deltt [expr {$width/50}] set time 0 drawCycloid $time $deltt }

If you take a circle and roll it along a straight line, just as with a bicycle, then a fixed point on the circle (or wheel, if you like), follows a curve called the cycloid (see the picture)

The points on the cycloid can be described via these formulae:

    x  =  r * (t - sin(t))
    y  =  r * (1 - cos(t))

    r = radius of the circle
    t = time parameter
 

Exercise

Proof these equations ---- '''Example: Pythagorean triples''' ---- TODO ---- [[ [Category Mathematics] | [Category Education] ]]