Tazaa

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

% simulacion de rueda de alfarero

clear; clg; hold off


axis([0, 1.25, 0, 1.2])
text(1.02,1.14,'Haga clic aqui','Color', 'r')
text(1.02,1.09,'para terminar', 'Color', 'r')
hold on
axis('off')
plot([1,1.25,1.25,1,1],[1,1,1.2,1.2,1])
plot([0,1,1,0,0],[0,0,1,1,0])
text(0,1.2,'Haga clic en varios puntos del cuadro de abajo.','Color', 'g')
text(0,1.15,'Luego haga clic una vez en el cuadrito de la derecha','Color', 'g')
text(0,1.10,'Siga las instrucciones de la pantalla de comandos.','Color', 'g')
for n=1:100
[xg,yg] = ginput(1);
if xg>0.99 & yg>0.99, break; end
x(n)=xg; y(n)=yg;
text(x(n),y(n), 'x')
end
m = length(y);
xlabel('xx'); ylabel('y'); plot(x,y,'o')
for k=1:m
z=int2str(k); xk = x(k); yk=y(k); text(xk+0.1,yk,z)
end
t = 0:0.25:1; t2=t.^2; t3=t.^3;
lt = length(t); ltm=lt -1;
rs=[]; zs=[];
for i=2:m-2
yb = 1/6*((1-t).^3*y(i-1) + (3*t3-6*t2+4)*y(i) + (-3*t3 + 3*t2 + 3*t +1)*y(i+1) +
t3*y(i+2));
xb = 1/6*((1-t).^3*x(i-1) + (3*t3-6*t2+4)*x(i) + (-3*t3 + 3*t2 + 3*t + 1)*x(i+1)
+ t3*x(i+2));
plot(xb,yb)
rs = [rs,xb(1:ltm)];
zs = [zs,yb(1:ltm)];
end
rs=[rs,xb(lt)];
zs=[zs,yb(lt)];
title(' Curva b-spline cubica en el plano x-y ')
fprintf('Pulse RETURN para continuar')
pause
clg
dth=pi/10;
th=0:dth:2*pi;
for i=1:length(th)
zz(i,:)=zs;
xx(i,:)=rs.*(cos(th(i)) + 0*0.2*cos(5*th(i)));
yy(i,:)=rs.*(sin(th(i)) + 0*0.2*sin(5*th(i)));
end
mesh(xx,yy,zz,zz)
colormap default
caxis([-0.5, 1.5])
shading interp
fprintf ('Pulse RETURN para continuar')
pause
surfl(xx,yy,zz,[30,30])
fprintf('Pulse RETURN para continuar')
pause
caxis([-1,3])
fprintf('Pulse RETURN para continuar')
pause
clg
colormap default
[nx,ny,nz] =surfnorm(xx,yy,zz);
r=specular(nx,ny,nz,[30,30], [50,10]);
r=diffuse(nx,ny,nz, [-50,10]);
surface(xx,yy,zz,r*0.3+0.1*zz)
view([-30,30])
shading interp
colormap jet
caxis([-0,1])
pause
clg

You might also like