%simpleodedriver.m
%This is highly underdocumented since all commands
%were explained in lecture.
options = odeset('RelTol',1e-4,'AbsTol',1e-6);

tstop = .19;
tspan= linspace(0,tstop,100);

th1zero=pi/2; th2zero=pi; th3zero=atan2(-4,3);
zzero=[th1zero th2zero th3zero]';

global om1 L1 L2 L3
om1=4;
L1=2; L2=5; L3=2.5;

[t z] = ode23('fourbarrhs', tspan, zzero, options);



figure(1)
plot(t,z)
axis([0 tstop -inf inf])
xlabel('The x axis'); ylabel('The y axis')
title('simple ode plot')


xB     = L1*cos(z(:,1));  yB     = L1*sin(z(:,1)); 
xCrelB = L2*cos(z(:,2));  yCrelB = L2*sin(z(:,2)); 
xDrelC = L3*cos(z(:,3));  yDrelC = L3*sin(z(:,3)); 

xC = xB + xCrelB;  yC = yB + yCrelB;
xD = xC + xDrelC;  yD = yC + yDrelC;

figure(2)
plot(0,0,'*', xB,yB, xC, yC, xD, yD,'*')
axis('equal')
