Graphics Reference
In-Depth Information
eXerCISe 3-7
represent the cylinder {t, sine [t], u}, with {t, 0, 2pi} and {u, 0, 4} by revolving {Cos [t](3+Cos[u]), sine [t]
(3+Cos[u]), sine [u]}, with {t, 0, 2 pi} and {u, 0, 2pi}.
>> t = [0:0.1:2*pi]';
>> r = [0:0.1:4];
>>
X
= sin(t) * ones(size(r));
>>
Y
= cos(t) * ones(size(r));
>>
Z
= ones(size(t)) * r;
>> surf(X,Y,Z)
>> shading interp
You get the graph in figure
3-19
.
Figure 3-19.
to represent the torus of revolution, we use the following syntax:
>> r = [0:0.1:2*pi]';
>> t = [0:0.1:2*pi];
>>
X
= [3 + cos(r)] * cos(t);
>>
Y
= [3 + cos(r)] * sin(t);
>>
Z
= sin(t)' * ones(size(t));
>> surf(X,Y,Z)
>> shading interp
We get the graph in figure
3-20
.