though code seems to be correct there is some problem coupler is getting stretched in half rotation

axis(gca ,'equal');%aspect ratio
axis([-30 30 -30 30]);%axis limits
w=15;
a=[0 0];
d=[12 0];
r1=12;
r2=6;
r3=15;
r4=13;
for t=0:600
theta=(w*t*2*3.14)/60;
b=r2*[cosd(theta) sind(theta)];
crank=line([a(1) b(1)],[a(2) b(2)],'color','r','linewidth',5);
k=sqrt((b(1)-d(1))^2+(b(2)-d(2))^2);
alpha=acosd((k*k+r1*r1-r2*r2)/(2*k*r1));
beta=acosd((k*k+r4*r4-r3*r3)/(2*k*r4));
disp(acosd((k*k+r4*r4-r3*r3)/(2*k*r4)));
phi=180-(alpha+beta);
c=[r1+r4*cosd(phi) r4*sind(phi)];
output=line([d(1) c(1)],[d(2) c(2)],'color','g','linewidth',5);
coupler=line([c(1) b(1)],[c(2) b(2)] ,'color','k','linewidth',5);
pt_a=viscircles(a,0.1);
pt_b=viscircles(b,0.1);
pt_c=viscircles(c,0.1);
pt_d=viscircles(d,0.1);
traj1=viscircles(a,r2);
traj2=viscircles(c,0.1);
pause(0.001);
delete(crank);
delete(output);
delete(coupler);
delete(traj1);
delete(pt_b);
delete(pt_c);
delete(pt_d);
end

This question is closed.

Asked:

on 12 May 2020

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!