Graphics Reference
In-Depth Information
Figure 3-20.
3.10 Special Geometric Forms
MATLAB enables commands to generate cylinders and spheres. We have:
[X, Y, Z] = cylinder(r, n)
draws the cylinder generated by the curve
r
, which has
n
points (
n = 20
per default) on the horizontal section of the circumference that is aligned
with the
Z
axis.
[X, Y, Z] = sphere (n)
draws a sphere (by default
n = 20
).
As an example, let's represent the cylinder generated by the curve
4Cos (t)
when
t
varies between
0
and
2p.
The syntax will be as follows:
>> t = 0:pi/10:2 * pi;
>> [X, Y, Z] = cylinder(4 * cos(t));
>> surf(X, Y, Z)
This generates the graph of Figure
3-21
.
Figure 3-21.