I recently came across Desmos. This an online calculator is to provide interactive plots and calculations. It uses JavaScript to do this on a web page. There are many other such graphing calculators online. But Desmos is one of the best because of the well done user interface. On the left bar you enter things to compute or to plot, and on the right side you see the plot. Variables can also be changed with sliders. The interface is very intuitive and works fast. It often helps the user by predicting his actions.

Since interactivity is one of the main features of Euler Math Toolbox (EMT) I took the challenge to mimic a few plots from this page. One example is a clock where the user can drag the time with sliders. I tried the clock on this page (the link contains a garbage string, so I do not know if it is permanent).

Here is the code to draw a clock in EMT.

>function drawclock ([h,m]) ...
$  plot2d("x^2+y^2",r=1.05,
$    level=[0;1],color=rgb(0.8,0.8,0.9),<grid);
$  t=(0:30:360)°; plot2d(cos(t),sin(t),>points,>add,style="ow");
$  th=90°-(h+m/60)/12*360°; xh=cos(th); yh=sin(th);
$  plot2d([0.7*xh,-0.1*xh],[0.7*yh,-0.1*yh],>add);
$  tm=90°-m/60*360°; xm=cos(tm); ym=sin(tm);
$  plot2d([0.9*xm,-0.1*xm],[0.9*ym,-0.1*ym],>add);
>drawclock(12,5); // Test


There is not much to say about the code. The filled clock is drawn with an implicit plot, just like it is done on the Desmos page. An alternative in EMT would be a filled curve. Note that EMT works in radian  mode and thus the angles have to be converted to degrees.

To make the plot we can use the function dragvalues(). The following lets the user drag the hours and the minutes.

>dragvalues("drawclock",["Hour","Minute"], ...
>  [12,5],[0,24;0,60],[24,60],digits=0);

If you want a clock with the current time, use the following code.

>function now() ...
$  {y,m,d,h,min}=date(daynow);
$  drawclock(h,min);
$  textbox(printdate(y,m,d,<time),
$    x=0.75,w=0.25,>left,>center,style="O");

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.