cyl = UnitCylinder(2);
 
L1 = 3;
L2 = 2;
L3 = 1;
radius = .3;
 
w1 = 5;
w2 = 10;
w3 = 30;
 
arm1 = translate(scale(cyl,radius,radius,L1/2),0,0,L1/2);
arm1.facecolor = 'blue';
arm2 = translate(scale(cyl,radius,radius,L2/2),0,0,L2/2);
arm2.facecolor = 'green';
arm3 = translate(scale(cyl,radius,radius,L3/2),0,0,L3/2);
arm3.facecolor = 'red';
 
angle1 = 0 ; angle2 = 0 ; angle3 = 0;
 
for i = 1:36
    
    distal = combine(translate(rotateY(arm3,angle3),0,0,L2),arm2);
    distal = rotateY(distal, angle2);
    
    arm = combine(translate(distal,0,0,L1), arm1);
    arm = rotateY(arm, angle1);
    
    cla
    renderpatch(arm);
    camlight
    box on
    view(30,30)
    drawnow
    set(gca,'xlim',[-5 5],'ylim',[-5 5],'zlim',[-5 5])
    
    
    angle1 = angle1 + w1 ;
    angle2 = angle2 + w2 ;
    angle3 = angle3 + w3 ;
end