12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

xt = [0 1 .5];yt = [0 0 1];zt = [0 0 1];clfpatch(xt,yt,zt,’y’)view(3)boxxyzz10.51 00.5y0 00.5x1Remember that patch is a low-level graphics function, so we must setthe view to three dimensional by h<strong>and</strong>.A plane is defined by three points, but four points need not lie in aplane. In such a case the patch may look a bit strange, depending onthe viewing angle:x = [0 1 1 0];y = [0 0 1 1];z = [0 0 0 1];clfsubplot(221)patch(x,y,z,’y’)11view(-40,10);box;xyz0.50.5subplot(222)patch(x,y,z,’y’)1 00100.500.510.50.50view(33,30);box;xyzyx1 0 yxzThree-dimensional patches should be planar. The above case, for example,is better done as two patches:x1 = [0 1 1];y1 = [0 0 1];z1 = [0 0 0];x2 = [0 1 0];y2 = [0 1 1];z2 = [0 0 1];clfsubplot(221)patch(x1,y1,z1,’y’)patch(x2,y2,z2,’y’)view(-40,10);box;xyz11subplot(222)0.50.5patch(x1,y1,z1,’y’)patch(x2,y2,z2,’y’)1 00100.500.510.50.50view(33,30);box;xyzyx1 0 yxzComplex three-dimensional objects should be built up using nonintersectingthree-dimensional patches. These can be drawn with a singlecall to the patch function, in which x, y, <strong>and</strong> z are matrices. Each column<strong>of</strong> the matrix will define a face. For example, consider the triangularpyramid:zzc○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!