i`m working in a project to design to link arm that writes letters or draws some simple figure(sqaure,traingle).i obtained the inverse kinematic and simulated the mechanasim in mathlab.I could draw cicrle my question is how i can modify my program to draw a suqaure or trianlge or even letters? this is the mathlab code:
clear all close all clc clear t=0:0.1:2*pi; r=1; //raduis of the cicle n=length(t); l1=1; l2=1;
for i=1:n; x(i)=r*cos(t(i)); y(i)=r*sin(t(i));
c2=(x(i)^2+y(i)^2-l1^2-l2^2)/(2*l1*l2); s2=sqrt(1-c2^2); th2(i)=atan2(s2,c2) k1=l1+l2*c2; k2=l2*s2; th1(i)=atan2(y(i),x(i))-atan2(k1,k2) x1=l1*cos(th1(i)); y1=l1*sin(th1(i)); x2=x1+l2*cos(th1(i)+th2(i)); y2=y1+l2*sin(th1(i)+th2(i)); line([0,x1,x2],[0,y1,y2]);hold on;pause(0.5); end;