lunes, 11 de enero de 2010

Un robot creado en Matlab

%% Creado por Pérez del Razo Marco

for i=0:3
clf
matriz_0=[0,0,0,0,0,3,3,0,0,3,3,0,3,3,3,3;0,0,1,1,0,0,1,1,1,1,0,0,0,0,1,1;0,1,1,0,0,0,0,0,1,1,1,1,1,0,0,1]
matriz_1=[0,0,-1,-1,0,0,0,-1,-1,0,-1,-1,-1,-1,0,0;0,1,1,0,0,0,1,1,0,0,0,0,1,1,1,1;0,0,0,0,0,-3,-3,-3,-3,-3,-3,0,0,-3,-3,0]
x=matriz_0(1,:)
y=matriz_0(2,:)
z=matriz_0(3,:)
plot3(x,y,z)
axis([-5,5,-5,5,-5,5])
hold on
x=matriz_1(1,:)
y=matriz_1(2,:)
z=matriz_1(3,:)
plot3(x,y,z)
for i=0:45
clf
theta = -(i * pi)/180
matriz_y=[cos(theta),0,sin(theta);0,1,0;-sin(theta),0,cos(theta)]
a=matriz_y*matriz_0
x=a(1,:)
y=a(2,:)
z=a(3,:)
plot3(x,y,z)
hold on
x=matriz_1(1,:)
y=matriz_1(2,:)
z=matriz_1(3,:)
plot3(x,y,z)
axis([-5,5,-5,5,-5,5])
hold on
pause(0.030)
end
pause(0.5)
for i=0:90
clf
theta = (i * pi)/180
matriz_z=[cos(theta),-sin(theta),0;sin(theta),cos(theta),0;0,0,1]
b=matriz_z*a
x=b(1,:)
y=b(2,:)
z=b(3,:)
plot3(x,y,z)
axis([-5,5,-5,5,-5,5])
hold on
poste=matriz_z*matriz_1
x=poste(1,:)
y=poste(2,:)
z=poste(3,:)
plot3(x,y,z)
hold on
pause(0.030)
end
pause(0.5)
for i=0:45
clf
theta = -(i * pi)/180
matriz_x=[1,0,0;0,cos(theta),-sin(theta);0,sin(theta),cos(theta)]
c=matriz_x*b
x=c(1,:)
y=c(2,:)
z=c(3,:)
plot3(x,y,z)
axis([-5,5,-5,5,-5,5])
hold on
x=poste(1,:)
y=poste(2,:)
z=poste(3,:)
plot3(x,y,z)
hold on
pause(0.030)
end
pause(0.5)
for i=0:45
clf
theta = (i * pi)/180
matriz_x=[1,0,0;0,cos(theta),-sin(theta);0,sin(theta),cos(theta)]
d=matriz_x*c
x=d(1,:)
y=d(2,:)
z=d(3,:)
plot3(x,y,z)
axis([-5,5,-5,5,-5,5])
hold on
x=poste(1,:)
y=poste(2,:)
z=poste(3,:)
plot3(x,y,z)
hold on
pause(0.030)
end
pause(0.5)
for i=0:90
clf
theta = -(i * pi)/180
matriz_z=[cos(theta),-sin(theta),0;sin(theta),cos(theta),0;0,0,1]
e=matriz_z*d
x=e(1,:)
y=e(2,:)
z=e(3,:)
plot3(x,y,z)
axis([-5,5,-5,5,-5,5])
hold on
poste1=matriz_z*poste
x=poste1(1,:)
y=poste1(2,:)
z=poste1(3,:)
plot3(x,y,z)
hold on
pause(0.030)
end
pause(0.5)
for i=0:45
clf
theta = (i * pi)/180
matriz_y=[cos(theta),0,sin(theta);0,1,0;-sin(theta),0,cos(theta)]
f=matriz_y*e
x=f(1,:)
y=f(2,:)
z=f(3,:)
plot3(x,y,z)
axis([-5,5,-5,5,-5,5])
hold on
x=matriz_1(1,:)
y=matriz_1(2,:)
z=matriz_1(3,:)
plot3(x,y,z)
plot3(x,y,z)
hold on
pause(0.030)
end
pause(0.5)
end

No hay comentarios:

Publicar un comentario