Functional Objects           

Function
Mechanism in which an arm C carrying a pen rotates around a pivot which joins two links, one attached to rotating arm A, the other to rotating arm B. Care needed to ensure mechanism is viable 2*AR + AB + 2*BR < Al + Bl and that the linkage remains valid.
Flow1 by Kit :
AR? 
  
Ar? 
  
Al? 
  
Ap? 
  
BR? 
  
Br? 
  
Bl? 
  
Bp? 
  
AB? 
  
CR? 
  
Cr? 
  
Cp? 
  
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 (!positive( (Al+Bl) - (2*AR+AB+2*BR)))
               {alert("mechanism impossible: "+ "links: "+ (Al+Bl)+ " less than base: "+(2*AR+AB+2*BR)); throw("mechanism impossible")}
            d=AB+AR+BR;
            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-(Bx+Ax); dy=By-Ay;
            Cl=Math.sqrt(dx*dx+dy*dy);
            AB=Math.atan2(dy,dx)*180/Math.PI;
           if (!triangle(Cl,Al,Bl)) {alert("not a triangle: " + Cl +" "+Al+" "+Bl); throw("not a triangle");}
            Aa=Math.acos((Al*Al + Cl*Cl -Bl*Bl) /(2*Cl*Al)) *180/Math.PI;
            AC=(Aa+AB);
            Px=Al*cos(AC);Py=Al*sin(AC);
            Cx=CR*cos(t*Cr+Cp); Cy=CR*sin(t*Cr+Cp);
            X= Px+Ax+Cx;Y= Py+Ay+Cy;
//            console.log(d,Cl,Al,Bl,triangle(Cl,Al,Bl),)
            return [scale*X,scale*Y]
            }