cg cga pdf 02 03 pop up cards 2 mar02

Upload: asd-dsssssss

Post on 03-Mar-2016

19 views

Category:

Documents


1 download

DESCRIPTION

pop up card

TRANSCRIPT

  • Pop-up cards are fun to create and receive. Theyrealso a great output medium for computer graphics,offering an economical and compact way to show 3Dscenes without the need for special glasses, shutters, orany other electronic hardware.

    In my last column, I talked about the geometry behindtwo basic pop-up mechanisms: the single-slit and the V-fold. These are the heart of my interactive pop-up designassistant, which I use to design cards on the computerthat I then print out and assemble.

    Happily, the single-slit and V-fold mechanisms arealso among the most general of all techniques used inpop-ups, since many of the other constructions are com-binations of these mechanisms or variations on theirgeometry.

    Of course, a variety of pop-up mechanisms exist thatarent captured by those ideas. Happily, most of thoseare straightforward to design and create with special-purpose code and dont present the sort of design chal-lenges that the slit and V-fold designs do. Well see someof them later.

    Building an assistantIn this section, Ill describe how I put together my pop-

    up design assistant. Lets begin with a quick review ofthe relevant geometry from my January/February 2002column.

    Figure 1 shows the basic geometry of a single slit from

    that column. To briey recap, recall that plane 1 doesntmove, while plane 2 rotates around the central fold LFby an angle . This tells us how to nd point C. The onlymissing point is B, which we nd by intersecting threespheres. Writing (A, r) for a sphere with center A andradius r, the spheres are (A, |AE|), (D, |DE|), and (C, |DE|).

    To create a V-fold, we only need to generalize this alittle bit. Figure 2 shows the new geometry, where B nolonger lies next to E. Remembering that B0 is the locationof point B when = 0, we can nd B by intersectingthree spheres with the same locations as the single slitbut with slightly different radii. The spheres are (A,|AB0|), (D, |DB0|), and (C, |DB0|).

    Thats the essence of the geometry. What remains arethe data structures, algorithms, and routines to evalu-ate the geometry. Lets take these in turn.

    The heart of any program lies in its data structures.For my assistant, the most important data structure isthe riser. A riser contains the information we need toposition all the points of a single-slit or V-fold element.

    The risers rst job is to help us identify points A, D, andC. I represent each point with three pieces of informa-tion: a pair of coordinates, a pointer to another riser, anda ag. To position a point, I retrieve the pointed-to riserand select either the left or right side as specied by theag. I then use the central fold and the appropriate bot-tom edge as two vectors that span a plane, scale those vec-

    AndrewGlassner

    Interactive Pop-up Card Design, Part 2 ________________

    Andrew Glassners Notebookhttp://www.glassner.com

    74 March/April 2002

    A

    D

    E

    (a) (b)

    A

    DE

    LFLF

    C0

    B

    B C

    1

    34

    2

    1 Geometry forthe single-slitmechanism.

  • tors by the coordinate values, and add those results togeth-er to nd the sought-after points position. Figure 3 showsthis idea. This recursion of risers pointing to other risersends with a special riser marked as the card.

    I maintain all of the risers in a list. I add new risers tothe end of this list as theyre created (and of courseremove them when the designer eliminates them fromthe model).

    To process the risers, I start at the beginning of the listand look for a riser that can be positioned; that is, bothrisers it depends on are already positioned, and it isntalready positioned itself. If I nd such a riser, I computeits points and mark it as positioned. When I reach theend of the list, if I positioned any riser on that pass, I goback to the start and go through the list again.

    When I pass through the list but nothing gets posi-tioned, then every riser should be accounted for. I scanthe list once more as a check and look for unpositionedrisers. If I nd any, I report an error.

    On the rst pass through the list I can only position thecard itself. Special-purpose code handles the card,because it doesnt depend on any other risers. I mark it aspositioned and then continue running through the list.Because the risers are strictly hierarchical, this algorithmshould always produce a completely positioned card.

    The two coordinates associated with each pointdescribe the scale factors on the edges of the riser onwhich the point depends. One of those edges is alwaysthe risers central edge. The other is the left or right bot-tom edge, as selected by the left or right ag.

    The system must reposition the entire card every timethe designer changes the opening angle, which occursfrequently. If efciency is an issue, you can preprocessthe list and build a tree structure that you can later tra-verse in a single pass. I found that repeatedly runningthrough the list of a dozen or so risers was no problemfor my 800-MHz Pentium III PC to handle in real time.

    Carrying the geometric ballLast time I described my algorithm for nding B as

    the intersection of three spheres. Here are the detailsbehind the heart of the routine.

    Suppose we have three spheres, S1, S2, and S3, withradii r1, r2, and r3. The radii neednt be different, but theygenerally will be. Figure 4 shows three such spheres, andthe plane that contains their centers. Ive also marked inblack one of their intersection points; theres anotherpoint symmetrically placed on the other side of the plane.

    Well work with these spheres in pairs. It doesnt mat-ter where we start, so lets pick S1 and S2. When twospheres intersect, the points in common form a circle.Our rst goal is to nd the plane that contains that cir-cle (see Figure 5).

    We saw last time how to nd the point J on the linethat contains the two sphere centers, as in Figure 6 (nextpage). To recap, the sphere centers are C1 and C2, theirradii are r1 and r2, respectively, and theyre distance dapart. We nd J by nding the distance a. We see fromtriangle PJC1 that a = r1 cos . We nd cos from theLaw of Cosines:

    IEEE Computer Graphics and Applications 75

    EDC

    B

    2 The basic V-fold is a generalization of the single slit.

    (,)

    3 To find a point on a riser, I use the coordinates (, )associated with that riser to scale the central fold andone of the lower edges, respectively. The point is thesum of these two scaled vectors.

    4 Threespheres thatmeet in a singlepoint.

    5 The pointscommon to twointersectingspheres lie in aplane thatsperpendicularto the line thatjoins theircenters.

  • cos = (d2 + r12 r22)/(2r1 d)

    so a = (d2 + r12 r22)/(2d). Using these values for a andd, we can nd

    Our plane passes through J with a normal parallel toC2 C1. Lets call this plane 12. I package this all up in aroutine that takes as input two spheres and returns theirplane of intersection.

    We can repeat this for the other two pairs of spheres,

    creating planes 23 and 13. Figure 7 shows all threeplanes.

    Now I intersect any two of these planes to find theline they have in common (as shown in Figure 8). Fornumerical stability, I use a robust technique publishedby Jim Blinn (see the Further Reading section for acitation). This algorithm takes as input two planes rep-resented with homogeneous coordinates and returnstheir line of intersection, if there is one (if the planesare parallel, they dont intersect and theres no com-mon line).

    Since Blinns paper presents the theory, Ill just sum-marize the necessary equations here. The input to thealgorithm is two planes, which Ill call P and Q. Plane Phas a normal given by (Px, Py, Pz) and an offset Pd; planeQ is similar. The output is a line dened by a point B anda direction vector V. The first step is to compute sixhandy terms p through u:

    p = Pz Qd Pd Qzq = Py Qd Pz Qys = Px Qd Pd Qxt = Px Qz Pz Qxu = Px Qy Py Qx

    These tell us all we need to nd the direction vector V:

    J C C C a d

    C C Cd r r

    d

    = +

    = + +

    1 2 1

    1 2 1

    21

    22

    2

    22

    ( )( / )

    ( )

    Andrew Glassners Notebook

    76 March/April 2002

    J

    P

    ad

    C1 C2

    r1 r2

    6 The geome-try of Figure 5.We are giventhe centers C1and C2, the radiir1 and r2, andthe distance dand use thisinformation tofind point Jthats containedin the plane.

    7 The threeintersectionplanes createdby the threespheres.

    8 Intersectingtwo planesgives us a line.

    Further ReadingIn my January/February 2002 column, I

    suggested a broad range of pop-up books tostudy, how-to books on their construction, and afew previous technical papers. All thosereferences contributed to my understanding ofthe field. I encourage you to return to thatcolumn for a complete list. As a reminder, thethree books that Ive found most useful fordiscussions of technique are The Elements of Pop-up by David A. Carter and James Diaz (Simon &Schuster, 1999), Paper Engineering by MarkHiner (Tarquin Publications, 1985), and The Pop-up Book by Paul Jackson (Henry Holt, 1993).

    The solution I presented here for finding theline of intersection formed by two planes waspublished by Jim Blinn in his classic Siggraph 77paper A Homogeneous Formulation for Lines in3-Space, in Computer Graphics (vol. 11, no. 2,1977, pp. 237241).

    A good place to start to learn about packingalgorithms in the textiles industry is Placementand Compaction of Nonconvex Polygons forClothing Manufacture, by V. Milenkovic, K.Daniels, and Z. Li, in the Proc. 4th Canadian Conf.Computational Geometry (1992, pp. 236-243).

    For information on ray tracing, and how tofind the intersection of lines with a variety ofgeometric objects including spheres, you canlook at An Introduction to Ray Tracing byGlassner et al. (Academic Press, 1989) or themore recent Practical Ray Tracing by PeterShirley (AK Peters, 2000).

  • V = (r, t, u)

    I then normalize Vthat is, I scale it so that it has alength of 1.0. Now we can nd the base point B. We havethree cases that handle any degeneracies and specialcases:

    if r 0 then B = (0, p/r, q/r)else if t 0 then B = (p/t, 0, s/t)else if u 0 then B = (q/u, s/u, 0)else error: planes are parallel

    Now we have the line in a convenient parametricform: L = B + tV, where the real number t sweeps usalong all the points on the line L with direction V andpassing through point B. In Figure 8, point B appears onthe line where it pierces the plane.

    It doesnt matter which pair of planes we choose tond L, since that line is common to all three planes, asshown in Figure 9. The line L is shared by all three pairsof planes. Here Ive also shown where L intersects oneof the spheres.

    Now that we have a sphere and a parametric line, wecan use standard ray-tracing techniques to intersect thatline with any of the three spheres. I use a library functionthat takes a line and a sphere and returns the two pointsof intersection. I wont give the details of that calcula-tion here, because theyre available in every book on ray-

    tracing (see the Further Reading section). For numer-ical stability, I use the sphere with the largest radius. (Ifmore than one sphere has the largest radius, I use one ofthem at random.)

    The result is a pair of points, as Figure 10a shows.Which one do we want? That depends on whether thecard designer wants the pop-up to rise out of the cardscenter or fall back behind it. We make this choice atdesign time, of course, and store it with the riser. I usethe normal of the riser thats referenced by point D to cat-egorize the two points. Each point will be on either therisers positive or negative side. The designers choice isstored in a ag associated with the riser. The most com-mon case is where the pop-up rises from the card.

    This linesphere intersection point is of course sharedby all three spheres, because its their point of commoncontact; Figure 10b shows the line and spheres.

    Another useful library routine is one that rotates apoint around a given line by a given angle. This is use-ful when we want to position points on risers as theyremoving around a fold axis. Suppose that we have a pointP and a line given by the two points A and B, and wewant to nd point Q, the result of rotating P around line(A, B) by an angle .

    You can write some efficient code to do this if youneed it. Heres a solution that uses only common vector

    IEEE Computer Graphics and Applications 77

    9 (a) Where L intersects the largest sphere. (b) In thisapplication, each pair of planes results in the same line.

    10 (a) The points of intersection of L with the largestsphere. (b) That intersection point is common to allthree spheres.

    (a)

    (b)

    (a)

    (b)

  • operations that should be available in almost any 3Dlibrary. Figure 11 shows the basic setup.

    We rst nd the point M which is the point on line AB,which is closest to P. I rst dene the vectors C = B Aand D = P A. Writing C for the normalized version ofC, we nd M by simply scaling C by the length of the pro-jection of D onto C:

    where Im using the dot product between C and D.Figure 11 shows point M in green.

    Now I make two vectors V and H that span the planethat includes this line and point:

    H = P MV = H C

    where is the cross product. I also nd the distance rfrom P to M:

    r = |P M|

    Figure 12 shows the vector H in red and V in purple.The new point Q is now easy to nd. Essentially, we

    rotate the point P in a circle spanned by the normalizedH and V vectors and then recenter it to point M:

    Figure 13 shows this circle and the position of the newpoint Q.

    GenerationsThe method presented in the last section for deter-

    mining a pop-ups points with respect to its base risersmakes it easy to provide designers with a techniqueknown as generations. Basically that just means cascad-ing a series of mechanisms one after the other. In termsof single-slit and V-fold mechanisms, it usually meansplacing a new mechanism on the card so that it isntpowered by the central card fold but rather by theinduced creases of an earlier riser. So as the riser popsup, its like a little card that is opening, and the fold ofthat little card drives another pop-up. Figure 14 showsthe basic idea schematically.

    The design assistant I described in the last sectionhandles this mechanism naturally, because it justinvolves placing the points of one riser with respect to anearlier one. Figure 15 shows an example of a card with

    Q M r r= + + H V cos sin

    M A= + ( )C C D

    Andrew Glassners Notebook

    78 March/April 2002

    11 Rotating a point around a line. The line AB is shownby point A in orange and point B in yellow. The point tobe rotated, point P, is in cyan off to one side. The pointM in green is the point on AB thats closest to P.

    12 The H vector is in red, and the V vector is in purple.

    (a)

    13 (a) The plane of rotation is formed by the H and Vvectors. The yellow ring shows the circle in this planewith center M and radius |MP|. The new point Q (in red)lies on this circle. (b) We find Q as a sum of scaledversions of the H and V vectors.

  • multiple-generation V-folds. Note that its hard to makemore than a few generations of V-folds on top of eachother. This is because each V-fold sits at an angle a littlecloser to the viewer than the one upon which its based.This means that eventually well run out of nice anglesfor viewing. More importantly, each generation reducesthe angle of the crease upon which the V-fold sits. Whena V-fold sits on an open card, the two sides are at. As thesides come together at a smaller angle, as they do onhigher generation V-folds, it gets more difcult to bothdesign and construct the card so that it both moves prop-erly and looks good.

    Other mechanismsAlthough the V-fold and the single slit provide the

    basic geometry for many pop-up designs, I support sev-eral other mechanisms in my design assistant. (Thebooks in the Further Reading sidebar provide moredetails on these mechanisms.) I wont describe thedetailed geometry of these mechanisms because theyreall either variations on what weve already seen, ortheyre pretty straightforward on their own.

    For simplicity, Ill discuss these mechanisms withrespect to the main card. Of course, they can all be builtwith respect to any two risers and built up in a genera-tions style, one upon the other.

    The double slit, as Figure 16 shows, is a minor varia-tion on the single-slit design. Although Ive shown it withcuts that are straight, perpendicular to the fold, and

    symmetrical about the fold, none of these need to holdtruethe cuts can be of any shape.

    Lets next look at the strap in Figure 17. The strap letsus do two things at once: displace the central fold to theleft or right, and reverse the folds direction. In Figure 17,Ive used the strap to move the fold to the right, andalthough the cards sides form a valley with respect tothe cards central fold, the straps sides form a moun-tain. The straps geometry is easy to implement, becauseit always forms a parallelogram with the card.

    Figure 18 shows a card built on a strap and two V-

    IEEE Computer Graphics and Applications 79

    14 The basic idea of creating generations by using oneV-fold as part of the base for another.

    15 A pop-upcard based ongenerations ofV-folds. Theyellow flowersare on a third-generation riser.

    16 A schematic for a double-slit mechanism.

    (a) (b)

    17 A schematicfor the strapmechanism.

    18 A greeting card that uses V-folds and a strap. The icebergs are V-folds.The ship is also a V-fold, based on one edge of a strap. (You can see thestrap to the left of the ship since the card is still slightly open.)

    Orig

    inal

    car

    d

    200

    2 A

    ndre

    w G

    lass

    ner

  • folds. The two icebergs are standardV-folds that rise off the cards sides.The ship is a V-fold that sits on oneend of a strap that straddles the cen-tral fold. Thus when the card opens,the ends of the strap atten out andthe ship pops up behind the iceberg.Because the card isnt fully open inthis image, you can see the strap tothe left of the ship where it hasntquite attened out.

    You can combine the strap withthe single slit to create the moving arm or pivot mecha-nism, as Figure 19 shows. The single slit may be a littlehard to see; think of the straps top as the slit. The mov-ing arm is the technique I used in Figure 1 of last issuescolumn to make the flag pop out of the mailbox.Combining such basic mechanisms is how we achievesome of the most surprising pop-up effects.

    Figure 20 shows a New Years card with a moving arm.The dragon pivots out of the card counterclockwise.

    You can create a layer thats parallel to the card butsits above it using the technique called the oating layer,as Figure 21 shows. Supports at the two sides hold upthe oating layer. The supports are generally the sameheight and placed an equal distance from the center fold,but they neednt be. For stability, one often includes asupport piece in the middle, as Figure 21 shows. Bychanging the heights of the three supports, you canchange the slope of the oating layers two sides from

    at to inclined in either direction. At the extremes, youcan shrink the side supports to create a mountain or tent,or shrink the support in the middle to make a valley. Theoating layer idea is versatile, and you can use it to makecomplex gures like boxes and cylinders.

    Figure 22 shows a party invitation that uses the oat-ing-layer technique for the dinner table. The two chairsare built out of V-folds.

    Pulling tabsSo far weve looked at pop-up mechanisms that work

    themselves. That is, all the reader has to do is open thebook or card and the paper does its thing. There are alsoa few popular mechanisms that let the reader take amore active role.

    One such device, known as the pull tab or pull-upplane, has various implementations. Figure 23 showsone of the basic versions. In this mechanism, two sheets

    Andrew Glassners Notebook

    80 March/April 2002

    (a) (b)

    19 A schematic for a moving-arm mechanism, createdby merging a strap with a single slit.

    20 A greeting card that uses the moving arm.

    21 A schematic for a floating layer mechanism.

    22 An invitation card that uses a floating layer for the table. The chairs areV-folds.

    Orig

    inal

    car

    d

    200

    2 A

    ndre

    w G

    lass

    ner

    Orig

    inal

    car

    d

    200

    2 A

    ndre

    w G

    lass

    ner

  • make up the page, sandwiching the mechanismbetween them. Ive drawn these obscured parts in gray.

    Its convenient to think of three parts to the pull tab,even though theyre all made out of one piece of paper.Theres the tab itself, which sticks out from the pagethrough a slot cut in the upper sheet. Then theres thevisible ap, which also sticks up through a slot. Finally,theres the bit underneath, which is a single rectangleof paper with a fold in it.

    As you pull the tab, the segment underneath tries tostraighten out and bulges downward. It tries to pull thevisible ap into the space between the paper, but this apis taller than the slot. Thus, the part underneath causesthe ap to pivot around the slot. When we pull out thetab all the way, the ap ips over and lies ush against thepage in the other direction, revealing the aps back andwhatever was on the page underneath it.

    You can get this effect for free if you use a completecollision-detection or constraint system, as I discussedlast time. But the mechanism is so simple that a bit ofspecial-purpose code to ip the ap around the slot cando the job quickly and accurately.

    The pull-tab is a nice way to create a card within acard. Really ambitious designers can include V-folds andother mechanisms inside this little minicard, but youmust be careful not to get carried away. The risk is thatpeople (both adults and children) often quite under-standably think that if pulling the tab opens the mech-anism, then pushing the tab should close it. Thissometimes works in simple cases, but often the flapunder the card buckles and then the mechanism neveragain works as it should. Sometimes designers reinforcethe hidden ap with additional layers of paper or thick-er board to prevent this problem.

    Spinning the wheelAnother popular device is based on the idea of a wheel.

    The wheel has four parts, as Figure 24 shows. In Figure

    24a, I show the front of the card. The notch on the leftgives the reader access to the wheels edge, and the holesin the card let whats printed on the wheel itself showthrough. Obviously, these holes can be of any shape andnumber as long as the card still holds together. A secondcard of the same size and shape (except without theholes) is usually made made for the back.

    Figure 24b shows the wheel itself, which has a rip-pled edge so that the reader can easily spin it. The twosmall parts in Figures 24c and 24d form the hub and nut,which Ill show in more detail in a moment. The nalcard (as seen from the front) is in Figure 24e. The wheelshows through the holes, and the reader can spin thewheel from the side.

    The hub is easy to make (once you know the secret).To make the wheels center we need one piece I call the

    IEEE Computer Graphics and Applications 81

    OPEN

    (a) (b)

    (d)(c)

    OPEN

    OPEN

    OPEN

    23 A schematicfor the pull-tabmechanism.Gray parts aresandwichedbetween thetop and bottomlayers of thecard.

    (a) (b)

    (e)

    (c)

    (d)

    24 The partsfor a wheelmechanism. (a) The frontcard with anotch that letsreaders accessthe wheelsedge, and holesthrough whichthey see thewheel itself. (b) The wheel.(c) The nut. (d) The butter-fly hub. (e) Thecompleted cardas seen fromthe front.

  • butterfly (Figure 24c) and one nut (Figure 24d). Youcan see the assembly process in Figure 25. Flip the topsheet over and glue two wings of the butterfly to theback of the front card. The red dots in Figure 25a showwhere the glue goes to afx the buttery to the cardsback. Then, we fold up the butterys wings and passthem through the hole in the wheels center. Next,straighten out the butterfly flaps and glue the top ofeach one to the nut that goes on the top of the stack.The red dots in Figure 25c show where to apply glue.Figure 25d shows the nal assembly. Notice that noth-ing gets glued to the wheel itself! Thats why it rotatesfreely. Cut the wings so that theyll t through the cen-ter of the wheel. Youll need to curl up the wings whenyou thread them, but theyll hold the wheel securelyonce the nut is in place. When the whole sandwich iscomplete, you can glue the cards front and back togeth-er around their rim. Make sure to leave enough roomfor the wheel to spin freely.

    Figure 26 shows a birthday card based on the wheel.The spokes on the unicycle turn when the wheel spins,and as the wheel turns, the rider rocks back and forth.To make the riders rock happen I perched the unicycliston an arm that passes through a slot in the cards front,as Figure 27 schematically shows. Inside the card, Iattached a larger disk behind the wheel with the spokesprinted on it and then placed another hub near the rimof that disk. Thus as the main wheel goes around, thesmaller hub on its edge goes with it. The rider is pulledup and down with the wheels motion and pivots whenthe wheel extends to the slots left or right.

    Staying in boundsWhen the card is folded at, we usually dont want

    any of the pieces to stick out beyond the cover. I checkfor this condition by setting the folding angle to 0 andthen calculating the position of every point in the card.I check to make sure that each point lies within theregion dened by the outermost card. If any points areoutside this region, theyll stick out when the card isclosed. I mark them with a bright color so that thedesigner can x the problem.

    Note that the shape of the outside card doesnt haveto be rectangular. Thats by far the most common shapefor self-contained cards, but theres no reason not to usea card cut into an ellipse or any other shape.

    Andrew Glassners Notebook

    82 March/April 2002

    (a) (b) (c) (d)

    25 Constructing a wheel. (a) Firstglue two wings of the butterfly tothe back of the front card. (b) Thread the other wings throughthe wheel. (c) Glue the top of thewings to the nut. (d) The completedsandwich seen from the back. Theblack line isnt part of the card, butis just to show how the pieces arevertically stacked.

    26 A birthday card based on a wheel mechanism. The rider sits on anextension affixed to the wheel. (a) The card at one position of the wheel.(b) When the wheel is turned, the spokes turn (they are visible through theholes in the front of the card), and the rider rocks back and forth.

    (a)

    (b)

    Orig

    inal

    car

    d

    200

    2 A

    ndre

    w G

    lass

    ner

  • CollisionsOne of the hardest problems to solve when manually

    designing a card is detecting and resolving collisions. Whenyou have several mechanisms moving at the same time, indifferent places and at different speeds, its all too easy toend up with the pieces banging into each other. This is badenough when the card is opening, but it makes it almostimpossible to close the card again without damaging it.

    I think the best way to handle collisions is to detectthem and then let the designer gure out how to resolvethem. One can certainly cook up all kinds of automaticschemes that move the points around algorithmically,and that would indeed solve the technical side of theproblem, but it may also change the aesthetics. Thepoint here is to make a designers tool, not nd a resultthat makes the computer happy! I prefer to let thedesigner know that theres a problem and use a humantouch to make things right.

    A careful, algorithmically complete job of collisiondetection would certainly work well. But it looks to melike it would be a complicated programId have to g-ure out the motion paths for every point, edge, andplane and then check them all against each other. Itseems easier to take a rough-and-ready approachinspired by point sampling rendering algorithms.

    To search for collisions, I simulate the cards openingby stepping the fold angle from 0 to . At each step, Icompletely position the card and then look for any edgesthat pass through any planes. If I nd any, I ag themand continue. When Im done, I highlight any offendingedges with a bright color. If the designer clicks on any ofthose edges, a display shows all the angles where colli-sions occurred. The designer can then click to set thecard to one of those angles, which will show the colli-sion. The designer can then manually adjust the pointsto repair the collision and can then go on to fix otherproblems, or run the collision-detection routine again.

    This scheme is fast and has always worked for me. Ithas the potential to fail when theres an intersection fora brief period of time between two of the checked angles.The easiest way to reduce the risk of a collision fallingbetween the cracks is to simply crank up the number ofsteps taken by . I use 250 steps by default, and Ive neverbeen surprised when building any cards. I bet you couldget away with 100 steps or even fewer if speed is an issue.

    Any collisions that sneak through this test are proba-bly not worth worrying about, because they come andgo so quickly the papers inherent exibility will proba-bly let it bend enough to avoid actually intersecting. Itspossible that some big collisions could sneak through(for example, two corners could just touch and lock upagainst each other), but Ive never seen any failures ofthis approach so far.

    Printing itAs I said in my last column, my reason for making my

    pop-up design assistant wasnt to create cards for view-ing on the computer, but rather to create cards to print,cut out, build, and share. So printing out the designedcard is important.

    The rst issue is making sure that you can easily andproperly assemble the card. Gluing down the risers in the

    right position has always been tricky for me. Its importantthat each piece is just where it should be so that the cardwill be at when folded shut, the pieces will rise and standup in the correct place and angle when the card is open,and we wont have any collisions along the way.

    Before we gure out how to glue the card together,we have to make sure that theres something to be glueddown! So far all my discussions have assumed that ris-ers are innitely thin and sit on the card, perched thereas if by magic. The stiff paper I use for construction isthin enough that I dont have to explicitly model itsthickness for most things. But somehow we do have toprovide tabs for gluing pieces into place.

    Figure 28 shows a typical V-fold riser and the two

    IEEE Computer Graphics and Applications 83

    27 A schematicfor the cammechanism ofFigure 26. Therider sits on apiece thatrotates arounda point on thewheel, throughthe use ofanother butter-fly hub and nutat that point.

    28 Creatinglittle glue-downtabs for a V-fold.

  • tabs that I automatically generate for gluing it downinto place. Note that these glue tabs are little trape-zoids, not rectangles; particularly at the center of a V-fold, rectangular tabs would overlap. This would createan ugly bump and also make the card a little harder toclose.

    To help me assemble cards, I have a switch to turn onthe printing of guidelines on all risers that have other ris-ers built upon them. This is just a colored line where theriser should be glued down. I then print the tabs withthe same color. So anywhere I see a red line, for exam-ple, I know that a riser with a red-colored tab should beglued down on that line.

    If you build a card, youll quickly discover that thepart of the tab that shows is the back of the page, whichcan look pretty bad if the color of the page doesnt blendin with the artwork. One solution is to cut a slit wherethe riser meets the card, and then slip the tab throughthe slit, gluing it to the underside of the card. Thisrequires a sharp crease to make sure the mechanismscan rise and fall properly. Another approach is to printthe base risers texture on the tab of the riser that sits onit, so that you can glue down the tab and the art is seam-less. This requires a color printer that can print on bothsides of the page with good registration.

    Now that we know how to assemble the card, weneed to get the pieces onto paper. Of course, we couldbe lazy and print one piece per page, but that would bewasteful. What we really want to do is to pack the piecestogether into the smallest number of pages.

    The best references I could nd for this process werein the clothing manufacturing industry, where itsimportant to conserve materials. Every bit of waste isexpensive, so they work hard to lay out the pieces asefciently as possible, including rotating them and thenotherwise shuffling them around to get the densestpacking. (The Further Reading section identifies agood paper for getting into that literature.)

    Those algorithms can be complex. As always, I prefersimple solutions that get me 90 percent of the way thereover complex solutions that get me to 100 percent.Achieving that last 10 percent often requires 10 times

    more work! My simple technique is a greedy algorithmthat packs the pieces in one at a time from largest tosmallest.

    I begin by creating a data structure called a page,which contains a list of rectangles, representing regionsof the page that havent yet been printed upon. This listbegins with a single rectangle that covers the page. Irun through the list of pieces as a one-time preprocessand sort them by the size of their bounding rectangles.I start with the largest rectangle and work my way downto the smallest, placing them as I go and creating newpages when necessary.

    To place a piece, I look at the rst page and its list ofavailable spacethat is, the list of rectangles repre-senting blank space on the page. I try to position thepieces bounding rectangle on this page, trying it in bothhorizontal and vertical orientations. If theres a way toget the current pieces bounding rectangle onto thepage, I place it as snugly as I can. I then use simplegeometry to remove that rectangle from the pagesavailable rectangle list. If the rectangle wont t on thispage, I repeat the process on the next page. If it doesntfit on any existing pages, I create a new page. In thisway, I tend to make a bunch of pages that start out withjust one or two big pieces and a lot of empty space, butthen that space gets nibbled away by the smaller piecesas they arrive and are placed.

    Figure 29 shows the result of this algorithm for thecard design in Figure 18. Note that the algorithm rotat-ed one of the icebergs and the strap 90 degrees to t thepage. Without this rotation, the pieces would have takenup two pages.

    This algorithm isnt perfect by any means. Theressome waste, and the pieces could surely be packed moretightly. But I usually get pretty good density on thepages, and the algorithm has the benets of being easyto program and fast to run.

    Moving upThere are lots of ways to extend my pop-up card

    design assistant. One thing Id really like to try is apply-ing computer-vision segmentation techniques to pho-

    84 March/April 2002

    Andrew Glassners Notebook

    29 The finalcutout pages forFigure 18. Iveturned on theoptional heavyblack outline forthese pieces tomake themeasier to cut. (a) The cardsbase. (b) Thepieces to be cut.Notice that thestrap and one ofthe icebergs arerotated 90degrees.

  • tographs, automatically dividing them into severalplanes based on distance. For example, we could havea foreground, several middle grounds, and a back-ground. The system could then take these segmentedregions of the photo, place them on a series of V-foldsspaced roughly like the objects in the scene, and cre-ate a 3D version of a photograph (sort of like Figure18). If a couple of versions of the photo are available,you could use them to fill in the holes in the back-ground layers where the foreground information wascut. Alternatively, you could ll in the holes using tex-ture synthesis methods.

    Another fun project would be to create pop-ups auto-matically from 3D scene descriptions. Pop-up designershave many special-purpose tools up their sleeves, fromself-assembling tables and cubes to lattices and stacks.It would be very cool to take a 3D modelsay of a car,teapot, or amingoand automatically generate a pop-up version for 3D, interactive, ofine viewing. Even sci-entific visualizations could be done this way. Theadvantage is that we can make the pieces available onany image medium, from a printed journal to the Web.Then someone just prints them out, assembles them,and enjoys the view.

    It would be interesting to automatically incorporateforced-perspective illusions onto the planes to give thecard an even richer illusion of depth.

    Id also like to add support for nonrigid constructions,such as curved folds and pressure forces. For example,in Figure 1b of last issues column, I showed a movingcard I designed where I made three V-folds with holescut through them. As the card opened and the V-foldsrose, they pulled up a oating layer that passed throughthem. Theres no direct mechanism here that causes thisto happen; its just that theres nowhere else for the oat-ing layer to go, so it must rise up with the V-folds them-selves. There are many such possibilities, and it wouldbe nice to provide them to the designer.

    Id like to esh out my program with some of the otherspecial-purpose pop-up mechanisms, such as pulleys,Venetian blinds, cylinders and cubes, and other uncom-mon but useful constructions.

    Finally, Id like to bundle up my design system into aplug-in for a commercial modeling package. That waypeople could use systems theyre already familiar withand use all the tools they already know for modeling,texturing, lighting, rendering, and so on.

    I think that these are all rich research topics full of juicypieces of geometry, optimization, segmentation, and inter-face esign. I encourage you to play around with this excit-ing new form of graphics output technology.

    AcknowledgmentsThanks to Sally Rosenthal for pop-up advice and

    encouragement, and Bryan Guenter for pointing me toseveral useful references. I modeled all the computer-rendered pop-ups in this column with my assistant andlit and rendered them with Discreets 3DS Max 4.

    Readers may contact Andrew Glassner by email [email protected].

    For submission instructions visit

    http://computer.org/cga

    Call for Papers

    January/February 2003 issue on

    Web Graphics

    Guest Editors:Rynson W.H. Lau and Tosiyasu L. Kunii

    Submissions due: 1 May 2002

    With the popularity of the Internet, wereseeing a migration from traditionalapplications to those that run in the Webenvironment and a growing demand for morepowerful Web-based applications. Fused bythe increasing availability and dramaticreduction in the cost of 3D graphicsaccelerators, a new direction of research,called Web Graphics, is emerging. It includesdeveloping graphics applications and toolsthat support these applications in Webenvironments. This special issue will explorerecent research results in this area.

    IEEE CG&A coversa wide range oftopics in computergraphics, bridgingthe gap betweentheory and practice.

    IEEE

    AND APPLICATIONS