1+ clear all, close all, clc
2+
3+ xlim([-2 2 ])
4+ ylim([-2 2 ])
5+ zlim([-2 2 ])
6+ % view([-72 18])
7+ view([45 26 ])
8+ % axis off
9+
10+ set(gca ,' FontSize' ,13 );
11+ set(gcf ,' Position' ,[100 100 300 300 ])
12+ set(gcf ,' PaperPositionMode' ,' auto' )
13+ print(' -depsc2' , ' -loose' , ' CH01_EX09_1_axis.eps' )
14+
15+ %% Define rotation matrix
16+ t1 = pi / 15 ;
17+ t2 = - pi / 9 ;
18+ t3 = - pi / 20 ;
19+
20+ Rx = [1 0 0 ;
21+ 0 cos(t1 ) - sin(t1 );
22+ 0 sin(t1 ) cos(t1 )];
23+
24+ Ry = [cos(t2 ) 0 sin(t2 );
25+ 0 1 0 ;
26+ - sin(t2 ) 0 cos(t2 )];
27+
28+ Rz = [cos(t3 ) - sin(t3 ) 0 ;
29+ sin(t3 ) cos(t3 ) 0 ;
30+ 0 0 1 ];
31+
32+ Sigma = diag([3 ; 1 ; 0.5 ]);
33+
34+ R = Rz * Ry * Rx * Sigma ;
35+
36+ %% Plot sphere and great circles
37+ [x ,y ,z ] = sphere(250 );
38+ % subplot(1,2,1)
39+ plot3([-2 2 ],[0 0 ],[0 0 ],' k' ,' LineWidth' ,6 );
40+ hold on
41+ plot3([0 0 ],[-2 2 ],[0 0 ],' k' ,' LineWidth' ,6 );
42+ plot3([0 0 ],[0 0 ],[-2 2 ],' k' ,' LineWidth' ,6 );
43+
44+ h1= surf(x ,y ,z );
45+ hold on
46+ set(h1 ,' EdgeColor' ,' none' ,' FaceColor' ,[.5 .5 .5 ],' FaceAlpha' ,.75 )
47+ % set(h1,'FaceColor','none')
48+ lighting phong
49+ shading interp
50+ axis equal
51+
52+ theta = (0 : .001 : 1 )*2 * pi ;
53+ x1 = cos(theta );
54+ y1 = sin(theta );
55+ z1 = 0 * theta ;
56+ x2 = 0 * theta ;
57+ y2 = cos(theta );
58+ z2 = sin(theta );
59+ x3 = cos(theta );
60+ y3 = 0 * theta ;
61+ z3 = sin(theta );
62+
63+ plot3(x1 ,y1 ,z1 ,' k' ,' LineWidth' ,6 );
64+ plot3(x2 ,y2 ,z2 ,' k' ,' LineWidth' ,6 );
65+ plot3(x3 ,y3 ,z3 ,' k' ,' LineWidth' ,6 );
66+
67+ xlim([-2 2 ])
68+ ylim([-2 2 ])
69+ zlim([-2 2 ])
70+ % view([-72 18])
71+ view([45 26 ])
72+ % axis off
73+
74+ set(gca ,' FontSize' ,13 );
75+ set(gcf ,' Position' ,[100 100 100 100 ])
76+ set(gcf ,' PaperPositionMode' ,' auto' )
77+ set(gcf ,' renderer' ,' opengl' )
78+
79+ axis off
80+ % save2pdf('CH01_EX09_1b.pdf',gcf,600)
81+ % print('-depsc2', '-loose', 'CH01_EX09_1b.eps')
82+ print(' -dpng' ,' -r1800' ,' -loose' , ' CH01_EX09_1a.png' )
83+
84+ %%
85+ xR = 0 * x ;
86+ yR = 0 * y ;
87+ zR = 0 * z ;
88+
89+ for i= 1 : size(x ,1 )
90+ for j= 1 : size(x ,2 )
91+ vec = [x(i ,j ); y(i ,j ); z(i ,j )];
92+ vecR = R * vec ;
93+ xR(i ,j ) = vecR(1 );
94+ yR(i ,j ) = vecR(2 );
95+ zR(i ,j ) = vecR(3 );
96+ end
97+ end
98+
99+ vec1 = [x1 ; y1 ; z1 ];
100+ vec2 = [x2 ; y2 ; z2 ];
101+ vec3 = [x3 ; y3 ; z3 ];
102+
103+ vec1R = R * vec1 ;
104+ vec2R = R * vec2 ;
105+ vec3R = R * vec3 ;
106+
107+ eX = [2 ; 0 ; 0 ];
108+ eY = [0 ; 2 ; 0 ];
109+ eZ = [0 ; 0 ; 2 ];
110+ eXR = R * eX ;
111+ eYR = R * eY ;
112+ eZR = R * eZ ;
113+
114+ x1R = vec1R(1 ,: );
115+ y1R = vec1R(2 ,: );
116+ z1R = vec1R(3 ,: );
117+ x2R = vec2R(1 ,: );
118+ y2R = vec2R(2 ,: );
119+ z2R = vec2R(3 ,: );
120+ x3R = vec3R(1 ,: );
121+ y3R = vec3R(2 ,: );
122+ z3R = vec3R(3 ,: );
123+
124+ figure
125+ % plot3([0 -2],[0 0],[0 0],'Color',[.3 .3 .3],'LineWidth',6);
126+ % hold on
127+ % plot3([0 0],[0 -2],[0 0],'Color',[.3 .3 .3],'LineWidth',6);
128+ % plot3([0 0],[0 0],[0 2],'Color',[.3 .3 .3],'LineWidth',6);
129+ h1= surf(xR ,yR ,zR ,z );
130+ hold on
131+ set(h1 ,' EdgeColor' ,' none' ,' FaceColor' ,[.5 .5 .5 ],' FaceAlpha' ,.75 )
132+ % set(h1,'FaceColor','none')
133+ axis equal
134+ shading interp
135+ lighting phong
136+
137+ plot3(x1R ,y1R ,z1R ,' k' ,' LineWidth' ,6 );
138+ plot3(x2R ,y2R ,z2R ,' k' ,' LineWidth' ,6 );
139+ plot3(x3R ,y3R ,z3R ,' k' ,' LineWidth' ,6 );
140+
141+ plot3([-eXR(1 ) eXR(1 )],[-eXR(2 ) eXR(2 )],[-eXR(3 ) eXR(3 )],' k' ,' LineWidth' ,6 );
142+ plot3([-eYR(1 ) eYR(1 )],[-eYR(2 ) eYR(2 )],[-eYR(3 ) eYR(3 )],' k' ,' LineWidth' ,6 );
143+ plot3([-eZR(1 ) eZR(1 )],[-eZR(2 ) eZR(2 )],[-eZR(3 ) eZR(3 )],' k' ,' LineWidth' ,6 );
144+
145+ xlim([-2 2 ])
146+ ylim([-2 2 ])
147+ zlim([-2 2 ])
148+ grid off
149+
150+ % view([-72 18])
151+ view([45 26 ])
152+ % axis off
153+
154+ set(gca ,' FontSize' ,13 );
155+ set(gcf ,' Position' ,[100 100 100 100 ])
156+ set(gcf ,' PaperPositionMode' ,' auto' )
157+ set(gcf ,' renderer' ,' opengl' )
158+
159+ axis off
160+ % save2pdf('CH01_EX09_1b.pdf',gcf,600)
161+ % print('-depsc2', '-loose', 'CH01_EX09_1b.eps')
162+ print(' -dpng' ,' -r1800' ,' -loose' , ' CH01_EX09_1b.png' )
0 commit comments