function P = DirKin3dof( q,L )

 %-- Definition of constants & variables ----------------------------------
 DIM = size(q,2);
 q1 = q(1,:); q2 = q(2,:); q3 = q(3,:);
 l0 = L(1); l1 = L(2); l2 = L(3);
 %-- Hip ------------------------------------------------------------------
  x3=   l1*sin(q2)+l2*sin(q2+q3);
  y3=  -l1*sin(q1).*cos(q2)-l2*sin(q1).*cos(q2+q3);
  z3=l0+l1*cos(q1).*cos(q2)+l2*cos(q1).*cos(q2+q3);
 %-------------------------------------------------------------------------
  P = [x3;y3;z3];
 %----------------------------------------------------------------------end
