% Program 2.8 % R-RTR-RTR % Position analysis % Creating a movie clear; clc; close all AB = 0.14; AC = 0.06; AE = 0.25; CD = 0.15; xA = 0; yA = 0; xC = 0 ; yC = AC; xE = 0; yE = -AE; axis([-0.3 0.3 -0.3 0.3]); % create axis M = moviein(6); % allocate/initialize the matrix to have 6 frames set(gca,'NextPlot','replacechildren') % prevents the plot function from resetting the axis shaping to axis % normal each time it is called incr = 0; for phi=pi/3:pi/3:2*pi, xB = AB*cos(phi); yB = AB*sin(phi); eqnD1 = '( xDsol - xC )^2 + ( yDsol - yC )^2 = CD^2 '; eqnD2 = '( yB - yC ) / ( xB - xC ) = ( yDsol - yC ) / ( xDsol - xC )'; solD = solve(eqnD1, eqnD2, 'xDsol, yDsol'); xDpositions = eval(solD.xDsol); yDpositions = eval(solD.yDsol); xD1 = xDpositions(1); xD2 = xDpositions(2); yD1 = yDpositions(1); yD2 = yDpositions(2); if (phi>=0 && phi<=pi/2)||(phi >= 3*pi/2 && phi<=2*pi) if xD1 <= xC xD = xD1; yD=yD1; else xD = xD2; yD=yD2; end else if xD1 >= xC xD = xD1; yD=yD1; else xD = xD2; yD=yD2; end end plot([xA,xB],[yA,yB],'r-o',[xB,xD],[yB,yD],'b-o',[xD,xE],[yD,yE],'g-o'),... text(xA,yA,' A'), text(xB,yB,' B'), text(xC,yC,' C'),... text(xD,yD,' D'), text(xE,yE,' E') incr = incr + 1; M(:,incr) = getframe; % record the movie end % end for % movie(M,5) % run the movie 5 times