Graphics Programs Reference
In-Depth Information
x=[0 0.5 0
.5 .5 1 1
1 .5 .5 .5];
y=[0 0 1 0
1100
0 .5 .5 .5];
z=[0 0 0 0
0000
0111];
1
0.5
clf
h = patch(x,y,z,'y')
view(3);box;xyz
0
1
0.5
0.5
0
0
y
x
Exercise 21 Define x, y, and z matrices to draw a truncated
square pyramid (answer on page 192):
1
patch(x,y,z,'y')
view(3);box;xyz
0.5
0
1
0.5
0.5
0
y
0
x
Using x , y , and z matrices to draw objects results in the same vertex
being listed as many times as the number of faces that share the vertex.
A more compact way of drawing such multifaceted patches is to define
a matrix of vertices and a matrix of faces.
Consider again the above triangular pyramid
and which is shown here with labelled corners.
The vertices are numbered from 1 to 4 and the
faces can be defined by specifying the order of
joining the vertices. For example, the base is
formed by joining the vertices 1 , 2 , and 3 , and
the white front face “ A ” is formed by joining the vertices 2 , 3 , and 4 .
The vertices and faces can be defined by the following matrices:
1
4
1
0.5
3
0
A
0
2
0.5
0
0.5
1
y
1
x
xyz
000
0 . 51 0
100
0 . 50 . 51
vertex 1
vertex 2
Vertices =
vertex 3
vertex 4
123
124
234
134
base
Faces =
face A
 
Search WWH ::




Custom Search