12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The colour <strong>of</strong> each vertex is indexed by the matrix T’ to the colours inthe hot colour map. (The hot spot is coloured dark in this gray scaleversion.) Each face <strong>of</strong> the patch is coloured in a way that interpolatesbetween the colours <strong>of</strong> its vertices.Exercise 22 Can you see what we have done wrong in the aboveexample? Hint: the patch colouring does not truly represent thedistance away from the heat source. How would you go aboutgetting a better representation? (Answer on page 193.)37.2 Light ObjectsTo create pictures representing real objects, you can colour them as ifthey are lit by one or more lights. The lights can be any colour youlike, <strong>and</strong> the lit objects can have their reflectance properties adjustedto simulate different surfaces: mirror-like, or self-coloured <strong>and</strong> shiny, ordull. Lighting can be applied to surface or patch objects. Light objectsthemselves cannot be seen. For the following examples the pltlightfunction plots a dot at the position <strong>of</strong> each light on the graphic. Let uscreate a sphere <strong>and</strong> see what it looks like when lit:clfsphereaxis equalgrid,box,xyzh = light(’position’,[1 -1 1]);pltlightYou should see a sphere with rather dull z-coded colouring <strong>and</strong> a glint<strong>of</strong> white light reflecting from about 45 ◦ N latitude. The dot at the topright h<strong>and</strong> corner <strong>of</strong> the plot is the result <strong>of</strong> the pltlight function, <strong>and</strong>represents the light. Let us see the result <strong>of</strong> using different colouredlights:set(h,’color’,[1 0 0])light(’position’,[-1 1 1],...’color’,[0 1 0])light(’position’,[-1 -1 1],...’color’,[0 0 1])pltlightThe light from the different coloured sources mix together to give amulticoloured shading. This graphic is still influenced by the z-codedc○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!