diary-2008-03-04
lect11_1
x = -1:3;
y = 1:4;
[X Y] = meshgrid(x,y)
X =
-1 0 1 2 3
-1 0 1 2 3
-1 0 1 2 3
-1 0 1 2 3
Y =
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
Z = X.*Y.^2./(X.^2+Y.^2)
Z =
Columns 1 through 4
-0.5000 0 0.5000 0.4000
-0.8000 0 0.8000 1.0000
-0.9000 0 0.9000 1.3846
-0.9412 0 0.9412 1.6000
Column 5
0.3000
0.9231
1.5000
1.9200
mesh(X, Y, Z)
lect11_2
lect11_2
lect11_2
grid off
box
clf
lect11_3
lect11_4
Y =
Column 1
1.0000
2.0000
3.0000
4.0000
3.0000
2.0000
1.0000
Column 2
6.5000
6.0000
5.5000
5.0000
4.0000
3.0000
2.0000
Column 3
7.0000
7.0000
7.0000
7.0000
7.0000
7.0000
7.0000
lect11_5
az =
-37.5000
az =
-27.5000
az =
-17.5000
az =
-7.5000
az =
2.5000
az =
12.5000
az =
22.5000
az =
32.5000
az =
42.5000
az =
52.5000
az =
62.5000
az =
72.5000
az =
82.5000
az =
92.5000
az =
102.5000
az =
112.5000
az =
122.5000
az =
132.5000
az =
142.5000
az =
152.5000
az =
162.5000
az =
172.5000
az =
182.5000
az =
192.5000
az =
202.5000
az =
212.5000
az =
222.5000
az =
232.5000
az =
242.5000
az =
252.5000
az =
262.5000
az =
272.5000
az =
282.5000
az =
292.5000
az =
302.5000
az =
312.5000
az =
322.5000
az =
332.5000
az =
342.5000
az =
352.5000
az =
362.5000
az =
372.5000
az =
382.5000
az =
392.5000
az =
402.5000
az =
412.5000
az =
422.5000
az =
432.5000
az =
442.5000
az =
452.5000
az =
462.5000
az =
472.5000
az =
482.5000
az =
492.5000
az =
502.5000
az =
512.5000
az =
522.5000
az =
532.5000
az =
542.5000
az =
552.5000
az =
562.5000
az =
572.5000
az =
582.5000
az =
592.5000
???
Operation
terminated
by user
during
==>
lect11_5
at 40
---------------------------------------------------------------------------
KLEIN BOTTLE
A Klein bottle is a nonorientable surface in four-dimensional space. It
is formed by attaching two Mobius strips along their common boundary.
Klein bottles cannot be constructed without intersection in three-space.
The figure shown is an example of such a self-intersecting Klein bottle.
Thanks to Davide Cervone, University of Minnesota.
---------------------------------------------------------------------------
echodemo('xpklein',2)
Click Next to continue or Stop to end xpklein.m (2/4)
---------------------------------------------------------------------------
GENERATE THE KLEIN BOTTLE
Define Klein bottle parameters
---------------------------------------------------------------------------
n = 12;
a = .2; % the diameter of the small tube
c = .6; % the diameter of the bulb
t1 = pi/4 : pi/n : 5*pi/4; % parameter along the tube
t2 = 5*pi/4 : pi/n : 9*pi/4; % angle around the tube
u = pi/2 : pi/n : 5*pi/2;
[X,Z1] = meshgrid(t1,u);
[Y,Z2] = meshgrid(t2,u);
% The handle
len = sqrt(sin(X).^2 + cos(2*X).^2);
x1 = c*ones(size(X)).*(cos(X).*sin(X) ...
- 0.5*ones(size(X))+a*sin(Z1).*sin(X)./len);
y1 = a*c*cos(Z1).*ones(size(X));
z1 = ones(size(X)).*cos(X) + a*c*sin(Z1).*cos(2*X)./len;
handleHndl=surf(x1,y1,z1,X);
set(handleHndl,'EdgeColor',[.5 .5 .5]);
hold on;
% The bulb
r = sin(Y) .* cos(Y) - (a + 1/2) * ones(size(Y));
x2 = c * sin(Z2) .* r;
y2 = - c * cos(Z2) .* r;
z2 = ones(size(Y)) .* cos(Y);
bulbHndl=surf(x2,y2,z2,Y);
set(bulbHndl,'EdgeColor',[.5 .5 .5])
colormap(hsv);
axis vis3d
view(-37,30);
axis off
light('Position',[2 -4 5])
light
hold off
echodemo('xpklein',3)
Click Next to continue or Stop to end xpklein.m (3/4)
---------------------------------------------------------------------------
HALF OF THE BOTTLE
---------------------------------------------------------------------------
shading interp
c = X;
[row col] = size(c);
c(1:floor(row/2),:) = NaN*ones(floor(row/2),col);
set(handleHndl,'CData',c);
c = Y;
[row col] = size(c);
c(1:floor(row/2),:) = NaN*ones(floor(row/2),col);
set(bulbHndl,'CData',c);
set([handleHndl bulbHndl],'FaceAlpha',1);
echodemo('xpklein',4)
End of demo. Click Replay to see it again xpklein.m (4/4)
---------------------------------------------------------------------------
TRANSPARENT BOTTLE
---------------------------------------------------------------------------
shading faceted;
set(handleHndl,'CData',X);
set(bulbHndl,'CData',Y);
set([handleHndl bulbHndl], ...
'EdgeColor',[.5 .5 .5], ...
'FaceAlpha',.5);
% Modify expression to add input arguments.
% Example:
% a = [1 2 3; 4 5 6];
% foo(a);
Ex11_1
Ex11_2
Ex11_2
Ex11_2
Ex11_3
[r fr conv]=newtfun(@f, @df, 1)
Column 1
1.250000000000000e+00
Column 2
2.031250000000000e-01
Column 1
1.214285714285714e+00
Column 2
4.737609329445558e-03
Column 1
1.213412175782825e+00
Column 2
2.779086666571118e-06
Column 1
1.213411662762407e+00
Column 2
9.583445148564351e-13
Column 1
1.213411662762230e+00
Column 2
-4.440892098500626e-16
r =
1.213411662762230e+00
fr =
-4.440892098500626e-16
conv =
1
[r fr conv]=newtfun(@f, @df, 1)
19 x = x - fh(x)/dfh(x);
dbstep
20 steps = steps + 1;
dbstep
21 disp([x fh(x)])
dbstep
Column 1
1.250000000000000e+00
Column 2
2.031250000000000e-01
22 myrel = abs((x-xold)/x);
dbstep
23 end
dbstep
17 while (myrel > re) & (steps < 20)
dbstep
18 xold = x;
dbstep
19 x = x - fh(x)/dfh(x);
dbstep
20 steps = steps + 1;
dbstep
21 disp([x fh(x)])
dbstep
Column 1
1.214285714285714e+00
Column 2
4.737609329445558e-03
22 myrel = abs((x-xold)/x);
dbstep
23 end
dbstep
17 while (myrel > re) & (steps < 20)
dbclear ('/Users/ausas/Documents/CS4/MATLAB/work/newtfun.m', '19')
dbcont
Column 1
1.213412175782825e+00
Column 2
2.779086666571118e-06
Column 1
1.213411662762407e+00
Column 2
9.583445148564351e-13
Column 1
1.213411662762230e+00
Column 2
-4.440892098500626e-16
r =
1.213411662762230e+00
fr =
-4.440892098500626e-16
conv =
1