% pendtemplate.m

% (c) 2014-11-15 Philip D Loewen; history at end of file

hlist = newpendulum('Hello, My Name Is ...');

L   = hlist{11};
g   = hlist{13};
periodT = 2*pi*sqrt(L/g);
dt      = periodT/8;

C   = 1;    % Phase plane circle radius
fps = 5;    % Frames per second

newstate(hlist,0,0);  % Reset state to (0,0) before each new trajectory.

% Using a trivial condition creates an infinite loop.
% Hit Control-C on the keyboard, or kill the figure window
% to break out of it.
while true
  theta = 0; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 2*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 3*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 4*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 5*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 6*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 7*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 8*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 9*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 10*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
  theta = 11*pi/6; 
  newstate(hlist,C*cos(theta),-C*sin(theta));
  drawnow
  pause(1/fps);
end

% Revision history (newest first):
%  2014-11-24 - corrected a sign error
%  2014-11-15 - original
