close all
clear all

size=14;

theta0=-45;
thetaF=+45;
omega0=0;
period=4;

syms t
time=0:0.001:period;
delta=thetaF-theta0;


% a0=theta0;
% a1=delta/period;
% 
% theta1=a0+a1*t;
% omega1=diff(theta1,t);
% gama1 =diff(omega1,t);
% 
% theta1n=subs(theta1,time);
% omega1n=subs(omega1,time);
% gama1n =subs(gama1 ,time);
% 
% figure(1);
% axes('fontsize',size);
% plot(time,theta1n,'b',time,omega1n,'g','linewidth',2)
% xlabel('time (s)','fontsize',size);
% legend('Position (degrees)','Velocity (degrees/s)','Location','SouthEast');



a0=theta0;
a1=omega0;
a2=3*delta/period^2;
a3=-2*delta/period^3;

theta2=a0+a1*t+a2*t^2+a3*t^3;
omega2=diff(theta2,t);
gama2 =diff(omega2,t);

theta2n=subs(theta2,time);
omega2n=subs(omega2,time);
gama2n =subs(gama2 ,time);

figure(1);
axes('fontsize',size);
plot(time,theta2n,'b','linewidth',2)
grid on
xlabel('time (s)','fontsize',size);
ylabel('Posição (graus)','fontsize',size);

figure(2);
axes('fontsize',size);
plot(time,theta2n,'b',time,omega2n,'r','linewidth',2)
grid on
xlabel('time (s)','fontsize',size);
legend('Position (degrees)','Velocity (degrees/s)','Location','SouthEast');

figure(3);
axes('fontsize',size);
plot(time,omega2n,'b',time,gama2n,'r','linewidth',2)
grid on
xlabel('tempo (s)','fontsize',size);
legend('Velocity (º/s)','Acceleration (º/s^2)','Location','SouthEast');
