Graphics Reference
In-Depth Information
Figure 3-1.
3.2 Polygons in Three Dimensions
MATLAB also allows for drawing polygons in three dimensions. To do this, use the following commands:
fill3(X,Y,Z,C)
draws the compact polygon whose vertices are the triples of the components
(Xi, Yi, Zi)
of the column vectors
X
,
Y
and
Z
. C can be a row vector of numbers, with the
same number of columns as X and Y; or C can be a column vector of numbers, with the
same number of rows as X and Y; or C can be a character that uses the colorspec characters
shown like 'k' for black. When C is a numeric vector, it is used as a scaled index into the
current colormap. If
X
,
Y
and
Z
are of the same dimension, several polygons corresponding
to each triple vector column
(X.j, Y.j, Z.j)
may be represented as matrices simultaneously.
In this case,
C
can be a row vector.
Cj
elements determine the unique color of each polygon
corresponding to the triple of vector column
(X.j, Y.j, Z.j)
. C may also be an array of the
same dimension as
X
,
Y
and
Z
, in which case the elements determine the colors of each
point
(Xijk, Yijk, Zijk)
of the set of polygons.
fill3(X1,Y1,Z1,C1,X2,Y2,
Z
2, C2,...)
draws the compact polygon whose vertices are given by
the points
(Xi, Yi, Zi)
and Ci.
Here is an example:
>>
x
= cos(0:0.01:8*pi);
>> y = sin(0:0.01:8*pi);
>> z = 0:0.01:8*pi;
>> fill3(x,y,z,'r')
This generates the graph of Figure
3-2
.
Figure 3-2.