function PlotGraphics( t,Q,dQ,ddQ )
%__________________________________________________________________________
% in_args: t, time vector
%            Q, angular joint positions
%           dQ, angular joint velocities
%          ddQ, angular joint accelerations
% out_args: NONE
%
% Plot the graphics of the time evolution
 if nargin == 2,    % Compute numerically the velocities and acclerations
   
    [dQ,ddQ] = NumericalDiff(t,Q);

    figure, plot(t,Q(1,:)*180/pi,'r', t,Q(2,:)*180/pi,'b',...
                 t,Q(3,:)*180/pi,'g', t,Q(4,:)*180/pi,'k')
            xlabel('Time (s)'), ylabel('Joint angle positions (deg)')
            legend('q1','q2','q3','q4')
    figure, plot(t,dQ(1,:),'r', t,dQ(2,:),'b',...
                 t,dQ(3,:),'g', t,dQ(4,:),'k')
            xlabel('Time (s)'), ylabel('Joint angular velocities (deg/s)')
            legend('dq1','dq2','dq3','dq4')
    figure, plot(t,ddQ(1,:),'r', t,ddQ(2,:),'b',...
                 t,ddQ(3,:),'g', t,ddQ(4,:),'g')
            xlabel('Time (s)'), ylabel('Joint angular accelerations (deg/s_2)')
            legend('ddq1','ddq2','ddq3','ddq4')
 else
     [dQ_num,ddQ_num] = NumericalDiff(t,Q);
%       dQ_MSE = sqrt( sum(dQ'-dQ_num').^2 ) 
%      ddQ_MSE = sqrt( sum(ddQ'-ddQ_num').^2 )
%      pause

     figure, plot(t,Q(1,:)*180/pi,'r', t,Q(2,:)*180/pi,'b',...
                  t,Q(3,:)*180/pi,'g', t,Q(4,:)*180/pi,'k')
             xlabel('Time (s)'), ylabel('Joint angle positions (deg)')
             legend('q1','q2','q3','q4')
     figure, plot(t,dQ(1,:),'r', t,dQ(2,:),'b',...
                  t,dQ(3,:),'g', t,dQ(4,:),'k',...
                  t,dQ_num(1,:),'y-.', t,dQ_num(2,:),'y-.',...
                  t,dQ_num(3,:),'y-.', t,dQ_num(4,:),'y-.')
             xlabel('Time (s)'), ylabel('Joint angular velocities (deg/s)')
             legend('dq1','dq2','dq3','dq4')
     figure, plot(t,ddQ(1,:),'r', t,ddQ(2,:),'b',...
                  t,ddQ(3,:),'g', t,ddQ(4,:),'k',...
                  t,ddQ_num(1,:),'y-.', t,ddQ_num(2,:),'y-.',...
                  t,ddQ_num(3,:),'y-.', t,ddQ_num(4,:),'y-.')
             xlabel('Time (s)'), ylabel('Joint angular accelerations (deg/s_2)')
             legend('ddq1','ddq2','ddq3','ddq4')
 end
%__________________________________________________________________________
end

