Functional Objects           

Function
Mechanism in which an arm C carrying a pen rotates around a pivot D which joins two links, one attached to rotating arm A, the other to rotating arm B. Care needed to ensure mechanism is viable AR + AB + BR < AD + BD and that the linkage remains valid. In this version, AR rotates counter-clockwise, BR clockwise
another go at Lorenzos by Kit :
AR? 
  
Ar? 
  
AD? 
  
Ap? 
  
BR? 
  
Br? 
  
BD? 
  
Bp? 
  
AB? 
  
CR? 
  
Cr? 
  
Cp? 
  
check? 
  
log? 
  
Randomly set the parameter values

Path Step size Scale Max Cycles
Line Line Width Line Color Padding

Function code

            function fn(t,p,scale) {  
            if (check==1 ) {   
               if(!triangle (AD,BD,AB+AR+BR))
               {alert("invalid - max : "+AD + "," + BD + ","+( AB+AR+BR)); throw("mechanism impossible")}
               if(!triangle (AD,BD,AB-AR-BR))
               {alert("invalid- min : "+AD + "," + BD + "," + (AB-AR-BR)); throw("mechanism impossible")}
            }
            d=AB; 
            Ax=AR*cos(t*Ar+Ap);
            Ay=AR*sin(t*Ar+Ap);
            Bx=BR*cos(t*Br+Bp);
            By=BR*sin(t*Br+Bp);
            dx=d-Ax+Bx;
            dy=By-Ay;
            AB=Math.atan2(dy,dx)*180/Math.PI;
            
            Cl=Math.sqrt(dx*dx+dy*dy);
            // three sides of a triangle :  AD AD,BD BD and Cl
            if (check==1) 
               if(!triangle(Cl,AD,BD)) 
               {alert("not a triangle: " + Cl +" "+AD+" "+BD); throw("not a triangle");}
        
            Aa=Math.acos((Cl*Cl +AD*AD -BD*BD) / (2*Cl*BD)) *180/Math.PI;
            
            AC=(Aa+AB);
            Px=AD*cos(AC);
            Py=AD*sin(AC);
            Cx=CR*cos(t*Cr+Cp);
            Cy=CR*sin(t*Cr+Cp);
            X= Px+Ax+Cx;
            Y= Py+Ay+Cy;
            if (log==1) console.log(t,Ax,Ay,Bx,By,dx,dy,Cl,AD,BD,AB,Aa)
            return [scale*X,scale*Y]
            }