From Wiki
Revision as of 08:44, 12 June 2012 by Esteis (talk | contribs) (Closing tag used backslash by accident. Fixed that.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

< Animation

TODO: Warning: Work in progress ! This page should be expanded. The tex code should be commented and needs improvements. (See: To-Do List)

This animation is based on the pdfclock sample.

Some general declarations:




\setupinteraction % closeaction fails here


Next, we need to define the "callback":

\startJSpreamble stepper used now
  var state = 0 ;
  var step = 0 ;
  function step_clock ()
    { try
          Walk_Field("clock") ;
          this.dirty = false }
      catch (e)
        { } }
  function start_clock ()
    { try
        { if (state==0)
            { step = app.setInterval ("step_clock()", 20) ;
              step.count = 0 ;
              state = 1 }
          else if (state==1)
            { app.clearInterval (step) ;
              state = 2 }
          else if (state==2)
            { app.clearInterval (step) ;
              Reset_Fields("clock") ;
              Set_Field("clock", "1") ;
              state = 0 } }
      catch (e)
        { } }
  function stop_clock ()
    { try
        { app.clearInterval (step) }
      catch (e)
        { } }
numeric u; u:=2mm;
pair A, B;
path ancrage, trait, cliphachure;
picture hachureoblique;

drawoptions(withpen pencircle scaled .1u);

trait := (0,-10u)--(0,10u);
for i=-10 upto 10 :
draw trait shifted (i*.5u,0) rotated -45;
cliphachure = (-2u,0u)--(2u,0u)--(2u,-1.5u)--(-2u,-1.5u)--cycle;
clip currentpicture to cliphachure;
hachureoblique := currentpicture;
currentpicture := nullpicture;
draw hachureoblique shifted (0,-2u);
draw hachureoblique shifted (40u,-2u);

label(btex $\varphi = \frac{5\pi}{8}$etex, (20u,0u));

A := (0,0);
B := (40u,0);
ancrage := (-1.5u,-2u)--(0,0)--(1.5u,-2u)--cycle;
draw ancrage shifted A;
draw ancrage shifted B;

label.top(btex $A$ etex, A);
label.top(btex $B$ etex, B);

pair frameloc; frameloc := (-5u,-25u);

drawarrow ((0,0)--(5u,0)) shifted frameloc;
drawarrow ((0,0)--(0,5u)) shifted frameloc;
fill (fullcircle scaled 1u) shifted frameloc withcolor white;
draw (fullcircle scaled 1u) shifted frameloc;
draw ((-.5u,0)--(.5u,0)) rotated 45 shifted frameloc;
draw ((0,-.5u)--(0,.5u)) rotated 45 shifted frameloc;
label.rt(btex $\vec{x}$ etex,(5u,0) shifted frameloc);
label.top(btex $\vec{z}$ etex,(0,5u) shifted frameloc);
label.llft(btex $\vec{y}$ etex,(0,0) shifted frameloc);

setbounds currentpicture to (-10u,10u)--(-10u,-30u)--(55u,-30u)--(55u,10u)--cycle;

numeric stp ; stp := \MPvar{n}-1 ;

numeric u; u:=2mm;
pair A, B, P[], Q[], M[];
path cerclel[], cercler[], cerclelb[], cerclerb[], pivot, trajectoire;

drawoptions(withpen pencircle scaled .1u);

pivot := fullcircle scaled 1u;

A := (0,0);
B := (40u,0);

for i=0 upto 10 :
P[i] := (6u,0) rotated (0+5*i);
Q[i] := (6u,0) rotated (112.5+5*i) shifted B;
cerclel[i] := fullcircle scaled 12u;
cercler[i] := fullcircle scaled 12u shifted B;
cerclelb[i] := fullcircle scaled 59.67u shifted P[i] ;
cerclerb[i] := fullcircle scaled 59.67u shifted Q[i] ;

M[i] := (cerclelb[i] intersectionpoint (subpath ( .5*(length cerclerb[i]),
1*(length cerclerb[i])) of cerclerb[i])) ;

drawoptions(withcolor .625red withpen pencircle scaled .15u);
draw A--P[stp];
draw B--Q[stp];
draw P[stp]--M[stp];
draw Q[stp]--M[stp];

drawoptions(withcolor .625red withpen pencircle scaled .15u);
trajectoire := M[0] for i=1 upto stp : -- M[i] endfor;
draw trajectoire withcolor (1,.0,.0);

path chemin[];
chemin[0] := A--(10u,0);
chemin[1] := A--P[stp];
chemin[2] := B--(50u,0);
chemin[3] := B--Q[stp];

drawoptions(withcolor black withpen pencircle scaled .1u);
draw chemin[0] dashed dashpattern(on 24bp off 12bp on 6bp off 12bp on
24bp) scaled .25;
draw chemin[2] dashed dashpattern(on 24bp off 12bp on 6bp off 12bp on
24bp) scaled .25;

anglelength := 1.0cm ;
drawoptions(withcolor .625red withpen pencircle scaled .25u);
drawarrow anglebetween(chemin[0],chemin[1] ,btex $\omega t $ etex);
drawarrow anglebetween(chemin[2],chemin[3] ,btex $\omega t + \varphi $ etex);

drawoptions(dashed evenly withcolor (.8,.8,.8));
draw P[stp]--Q[stp] dashed evenly withcolor (.8,.8,.8);
draw .5[P[stp],Q[stp]]--M[stp] dashed evenly withcolor (.8,.8,.8);

angle_radius = 10pt ;
def mark_rt_angle (expr a, b, c) =
draw ((1,0)--(1,1)--(0,1))
zscaled (angle_radius*unitvector(a-b))
shifted b
enddef ;

mark_rt_angle( P[stp], (.5[P[stp],Q[stp]]), M[stp]);

drawoptions(withpen pencircle scaled .1u);
fill pivot shifted A withcolor white;
draw pivot shifted A withcolor black;
fill pivot shifted B withcolor white;
draw pivot shifted B withcolor black;
fill pivot shifted P[stp] withcolor white;
draw pivot shifted P[stp] withcolor black;
fill pivot shifted Q[stp] withcolor white;
draw pivot shifted Q[stp] withcolor black;
fill pivot shifted M[stp] withcolor white;
draw pivot shifted M[stp] withcolor black;

freelabel(btex $P$ etex, P[stp], A) ;
freelabel(btex $Q$ etex, Q[stp], B) ;
label.bot(btex $M$ etex, M[stp]);

setbounds currentpicture to (-10u,10u)--(-10u,-30u)--(55u,-30u)--(55u,10u)--cycle;



\dorecurse{72}% from 0 by 5 to 360 gives 72 steps !

  {\definefieldstack [clock] [\mechlist]