function J=Jacob3R(theta,a1,a2,a3)

% Programmino per il calcolo della matrice Jacobiana
% del robot planare 3R

phi=theta(1)+theta(2)+theta(3);
c1=cos(theta(1)); c12=cos(theta(1)+theta(2));  c123=cos(phi);
s1=sin(theta(1)); s12=sin(theta(1)+theta(2));  s123=sin(phi);

J=[-(a1*s1+a2*s12+a3*s123), -(a2*s12+a3*s123), -a3*s123;
     a1*c1+a2*c12+a3*c123,    a2*c12+a3*c123,   a3*c123;
     1,   1,   1];
     
