Answers to Exercises, Chapter 3
These are answers to the exercises in the 3rd edition of Digital Multimedia (published February 2009) only. Do not try to use them in conjunction with the 2nd edition.
Test Questions
Using the computer graphics convention that y values increase downwards:
(a) (370.0, 250.0);
(b) (120.0, -130.0);
(c) (120.0+a, 250.0+a) where a2=80000, i.e. approximately (402.8, 532.8).
If you prefer the mathematical convention that y values increase upwards:
(a) (370.0, 250.0);
(b) (120.0, 370.0);
(c) approximately (402.8, -32.8).
In pixel coordinates, the values would have to be integers (whole numbers), so if X and Y were pixels the values for (c) could only be stored as an approximation (403, 533).
- True, in principle, but note the remark about sub-pixel anti-aliasing in Chapter 9 (p. 352). The physical construction of real devices means our idea that a pixel is a perfect rectangle is not entirely accurate.
- The path will leave P4 at the same rate as it entered it, but instead of continuing its direction it will be reflected.
- Please note the erratum to this question and only consider the two lower shapes in Figure 3.24. Of these two lower shapes, the one on the left, which is entirely filled – the pentagon in the middle is inside the shape – has used the non-zero winding number rule. The shape at the lower right of Figure 3.24 – with the pentagon unfilled because it is outside – has used the even-odd rule. A line drawn from the centre of the star is crossed by the path twice, both times in the same direction. (Try it.) So the winding number is 2, which is even. (Note that in the inside vertices, where the path crosses itself, it must be counted twice, but since the rules let you construct any line you can always avoid such points.)
The first of these is actually the most difficult. One way to do it is by moving (p, q) to the origin, rotating (x, y) about it using the equation on page 80, and then moving it back. Alternatively, just use trigonometrical identities to derive it from first principles.
(a) Rotate clockwise through an angle θ (y increases down; if y increases up, rotate counter-clockwise to get the same result):
x′ = p + (x-p)cosθ - (y-q)sinθ, y′ = q + (x-p)sinθ - (y-q)cosθ.(b) Reflecting in x = p, x′ = 2p-x, y′ = y.
(c) Reflecting in y = q, x′ = x, y′ = 2q - y.
(a) right;
(b) right;
(c) left;
(d) right.
On each hand, try writing x on your thumb, y on your first finger, z on your middle finger, as in Figure 3.30 and see which hand you can twist your hand so the fingers point as described in the question. (Don't hurt yourself trying this last one.)
Any pair of left-handed coordinate systems are related by one or more rotations. Going from left to right-handed or vice versa always requires a reflection.
Discussion Topics: Hints and Tips
- Consider both implementation issues such as ease of programming, compactness of representation and efficient implementation on current graphics hardware, and issues that affect the user, such as the naturalness of drawing tools and the accuracy of the drawn shapes. If you are discussing this in a group, discover whether individual views on this topic vary according to the background of the student.
- Think about this for yourself first, but then investigate how it is done in SWF and PDF.
- Does every image have to look like a photograph? How may different types of 3-D "scenes" can you think of (forget about games for a moment).
Practical Tasks: Hints and Tips
- Yes, this is a pretty dull exercise but it will help you to understand how Bézier curves work. You can make sketches on graph paper, or use a drawing program. In the latter case, mark the points on a separate layer, and use them to line up the direction lines as you draw each curve with the pen. If you do it this way you can test your intuitions about which pairs of curves can be transformed by trying it. If you really can't face drawing 24 curves you could write a program but it will probably take you longer.
- You should be able to draw an ellipse using four Bézier curves.
- Check your sketch using a 3-D program that supports constructive solid geometry, if you can.
- Real hats will have imperfections that you can ignore; you can also assume that the brim of a top hat or bowler is the same all round – some other hats always have the brim turned down on one side, though. Where features such as a peak interfere with the radial symmetry, can you break the hat into separate pieces, one or more of which can be made by lathing, the others using some other operation? For the case of the Tam o'Shanter – which is almost symmetrical but not quite, because of the way it is made out of several pieces sewn together – try making the best approximation you can with lathing and then map a surface over it the makes it appear more realistic.
A 42nd Street skimmer is one of those flat-crowned straw hats that were popular in the United States during the first half of the 20th century – a species of boater. If you are not familiar with the shapes of the other hats, you can research them on the Web.