clear
close all

disp('                Compound motions     ')
disp(' ')

disp(' We combine motion along a helix with periodic up and down motion.')
disp(' For example, a person walking up a circular staircase, and ')
disp(' playing with a yoyo  ')
disp(' ')
disp(' The motion along the helix is given by   ')
disp('       t -> r_0(t) = (cos(t), sin(t), t)   .')
disp(' The motion of the yoyo is given by ')
disp('       t -> r_1(t) = (0,0, .2*cos(10*t) ) .')
disp(' The combined motion is given by   ')
disp('            t -> r(t) = r_0(t) + r_1(t) ')
disp('                      = (cos(t), sin(t), t + .2*cos(10*t)) .')

    x = inline('cos(t)');
    y = inline('sin(t)');
    z = inline('t + .4*cos(20*t)');
    t = linspace(0, 2*pi, 201);
    plot3(x(t), y(t),t)
    hold on
    pause 
    ss = linspace(0, 2*pi, 81);
    M = moviein(81);
    for j = 1:81
        s = ss(j);
        tau = linspace(0,s, 101);
        h1 = plot3(x(tau), y(tau), z(tau), 'k');
          h2 = plot3(x(s),y(s),z(s), '*r');
        M(j) = getframe;
        delete(h1); delete(h2);
    end
    pause
    
    movie(M,1,8)
    
    pause
    close
   
   

