Graphics Programs Reference
In-Depth Information
The matlab code to draw the triangular pyramid using these matrices
is
vertices_mx = [ 0 0 0
.510
100
.5 .5 1];
faces_mx = [1 2 3 % base
124
2 3 4 % Face 'A'
1 3 4];
1
clf
patch('Vertices',vertices_mx,...
'faces',faces_mx,'FaceColor','y')
view(162,44)
box;xyz
0.5
0
0
0.5
0
0.5
1
y
1
x
When drawing three dimensional objects, beware of intersecting patches.
Each patch is drawn in its entirety, so intersecting patches often look
strange. For example, here are two triangles that intersect along their
symmetry axes:
vert = [0 0 0
110
1-1 0
10-1
1 0 1];
fac=[123
1 4 5];
1
clf
patch('vertices',vert,...
'faces',fac,'facecolor','y')
view(3),grid,xyz
0
−1
1
0
0.5
y
−1
0
x
Explore this graphic by typing rotate3d and moving the viewpoint with
the mouse. You should see that you never get a realistic image. A better
way to create the required display is to generate four nonintersecting
triangles:
vert2 = [0 0 0
110
1-1 0
10-1
101
1 0 0];

Search WWH ::

Custom Search