function AnimaMoto(t,q) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %ANIMA EL MOVIMIENTO OBTENIDO% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% persistent h2 h3 h4 h5 global Parametr x3 = Parametr(5); z3 = Parametr(6); x4 = Parametr(7); z4 = Parametr(8); x5 = Parametr(9); z5 = Parametr(10); Rt = Parametr(3); Rd = Parametr(4); a = Parametr(38); b = Parametr(39); c = Parametr(40); d = Parametr(41); e = Parametr(42); h = Parametr(44); i = Parametr(45); k = Parametr(47); Rx3=q(1); Ry3=q(2); Rz3=q(3); %EVALUA EN CADA t% %%%%%%%%%%%%%%%%% rg2=RG2(q); rg5=RG5(q); a2=A2(q); a3=A3(q); a4=A4(q); a5=A5(q); %%DESCRIBE CADA SOLIDO CON LINEAS%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RA3= [q(1) q(2) q(3)]' + a3*[a 0 -b]'; %baja a inicio sillin RB3= [q(1) q(2) q(3)]' + a3*[-h 0 -(c+b)]'; %hacia rueda trasera RC3= rg2 + a3*[(h+i) 0 0]'; %ahora de rueda trasera hacia plato RE3= RA3 + a3*[k-a 0 0]'; RA4=[q(1) q(2) q(3)]' + a3*[k 0 -e]'; %manillar RB4=RA4 + a4*[0 0.3 0]'; RC4=RA4 + a4*[0 -0.3 0]'; rp3=[[q(1) q(2) q(3)]' RA3 RB3 RC3 RA3 RE3 RC3]; %cuadro rp4=[RA4 RB4 RC4 RA4 RE3 rg5]; %ruedas, solidos 2 y 5 se describen con parámetro angular alfa = 0:0.3:(2*pi+0.3); rP2=zeros(3,length(alfa));%trasera rP5=zeros(3,length(alfa));%delantera for j=1:length(alfa) %para dibujar 2 y 5 en glob rP2(1:3,j)=rg2+a2*[Rt*cos(alfa(j)) 0 Rt*sin(alfa(j))]'; rP22(1:3,j)=rg2+a2*[(Rt-0.06)*cos(alfa(j)) 0 (Rt-0.06)*sin(alfa(j))]'; rP5(1:3,j)=rg5+a5*[Rd*cos(alfa(j)) 0 Rd*sin(alfa(j))]'; rP55(1:3,j)=rg5+a5*[(Rd-0.06)*cos(alfa(j)) 0 (Rd-0.06)*sin(alfa(j))]'; end rP2=[rP2 rP22 rg2]; %contorno y cdg de 2 rP5=[rP5 rP55 rg5]; %contorno y cdg de 5 %%% LAS REPRESENTA %%% %%%%%%%%%%%%%%%%%%%%%% if t==0 scrsz = get(0,'ScreenSize'); figure('Position',[0.1*scrsz(4) 0.1*scrsz(4) 0.8*scrsz(3) 0.8*scrsz(4)]) h2 = plot3(rP2(1,:),rP2(2,:),rP2(3,:),'XDataSource','rP2(1,:)','YDataSource','rP2(2,:)','ZDataSource','rP2(3,:)'); %rueda trasera OK hold on; h5 = plot3(rP5(1,:),rP5(2,:),rP5(3,:),'XDataSource','rP5(1,:)','YDataSource','rP5(2,:)','ZDataSource','rP5(3,:)'); %rueda delantera OK h3 = plot3(rp3(1,:), rp3(2,:),rp3(3,:),'XDataSource','rp3(1,:)','YDataSource','rp3(2,:)','ZDataSource','rp3(3,:)'); %cuadro OK h4 = plot3(rp4(1,:),rp4(2,:),rp4(3,:),'XDataSource','rp4(1,:)','YDataSource','rp4(2,:)','ZDataSource','rp4(3,:)'); %manillar OK axis equal; axis([Rx3-1.3 Rx3+1.3 Ry3-1.3 Ry3+1.3 Rz3-0.3 Rz3+1.3]); %intervalo en x y z visible %superficie para hacer "suelo" plano % % [x,y]=meshgrid(-3:.3:3,-2.5:.3:2.5); % [m,n]=size(x); % z=zeros(m,n); % surf(x,y,z,'FaceColor','k') % else axis equal; axis([Rx3-1.3 Rx3+1.3 Ry3-1.3 Ry3+1.3 Rz3-0.3 Rz3+1.3]); refreshdata(h2,'caller') refreshdata(h5,'caller') refreshdata(h3,'caller') refreshdata(h4,'caller') drawnow; end end