# 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 :
Randomly set the parameter values

Path Step size Scale Max Cycles Line Width Line Color Padding

## Function code

```            function fn(t,p,scale) {
if (check==1 ) {
{alert("invalid - max : "+AD + "," + BD + ","+( AB+AR+BR)); throw("mechanism impossible")}
{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)
{alert("not a triangle: " + Cl +" "+AD+" "+BD); throw("not a triangle");}