Notes/Hints/Suggestions for the Recursive Buggle Quilts
problem
There are two main ways to decompose the recursive bagel quilt
design. Either decomposition is equally viable.
- Recursive Rug Decomposition: define the quilt as a
square rug that has triangles at all four corners and has a
smaller rug at its center. For example, here is the outer ring of
such a decomposition in a 16x16 grid:
- Repeated Recursive Quadrant Decomposition: define the
quilt as four rotated copies of a recursively defined quadrant
consisting of a sequence of smaller and smaller triangles. For
example, here is the quadrant for such a decomposition in a 16x16
grid.
The mathematics of the problem are a little bit tricky. The
following facts are likely to be extremely useful for you. Suppose
that:
- outSide is the side length of the
outer quilt;
- triSide is the side length for the
triangle of bagels in one corner of the outer quilt;
- inStep is the number of steps for
the buggle to move over and up to be in the lower left corner of
the inner quilt;
- inSide is the side length of the
inner quilt.
(You don't need to have variables with these names in your
program. They are used here for the sake of discussion.) Observe the
following:
- triSide should be outSide/2.
This works whether outSide is odd or
even because of the truncation of integer division in Java.
- inStep should be (triSide
+ 1)/2. You can convince yourself of this fact by drawing
some small examples (say triSide = 2
through triSide = 6) or studying the
quilts on the assignment.
- inSide should be
outSide - (2 * inStep). That is, the inner quilt must have a
length that is the length of the outer quilt with the two move
steps chopped out of it.
The above facts are all the math you should need in order to solve
the problem using the recursive quilt decomposition. In particular,
it is not necessary to test for evenness or oddness (though you may
do so if you like). The calculation of triSide
and inStep should be helpful even if you
are using the repeated recursive quadrant decomposition.