Saint Louis University |
Computer Science 144
|
Dept. of Math & Computer Science |
For this assignment, you must work individually in regard to the design and implementation of your project.
Please make sure you adhere to the policies on academic integrity in this regard.
The book's use of the star shape to build a "mandala" had me reading more about true mandalas, which are spiritual patterns that represent the Universe in Hinduism and Buddhism. (Read more on wikipedia.) For this project you are to design and build a mandala pattern of your choosing. The mandala must be centered around the middle of a canvas with your choice of dimensions, with a pattern than demonstrates rotational symmetry on a variety of underlying shapes (more technical requirements below).
For more inspiration, feel free to see:
In class, we have demonstrated techniques for drawing regular polygons and stars that demonstrate symmetry about their center. More generally the same principles can be used to make copies of any shape with such rotational symmetry. For this assignment you have two options:
If you wish to tackle all the mathematics yourself, you are welcome to implement the entire sketch from scratch. (In that case, feel free to ignore the rest of this section.)
We are offering the following framework that you may choose to use as your starting point. It has a few "magical incantations" that we have not yet explained, but it should make it relatively easy to stamp a pattern around the center at your chosen radius and scale.
To begin, our code provides the regular polygon and star
implementations from class. But the cooler framework that we are
providing is a new function with signature:
void stamp(Pattern model, int number, float radius, float scale, float theta)
This function will place 'number' copies of the model pattern
(more about that soon), placed evenly around the origin at
distance 'radius'. The images will be drawn with the given scale
factor and the images will be placed so that the first one is at
angle 'theta' relative to the center.
We need a little magic for you to be able to define a general
pattern to stamp in such a way. As an example, assume that you
want to use horses in your mandala. You would do this by using
the following syntax:
class Horse implements Pattern {
void draw() {
// give commands here that draw a single horse pattern
// ...
}
}
Note well: for proper use with our framework, such a draw() routine should layout the geometry so that the pattern is drawn relative to the origin (0,0), with the bottom of the pattern as drawn being the side that will be drawn oriented inward toward the center. Our stamp() function will combine other transformations to replicate the pattern.
Once you have defined a pattern such as Horse, you may
use it with the stamp() function using a syntax such as
the following:
stamp(new Horse(), 4, 200, 0.5, QUARTER_PI);
This command would cause 4 horses to be drawn, each at radius
200 from the center and at half-scale relative to the original
pattern definition, and such that the first of the four hourses
is drawn at angle QUARTER_PI.
If you are interested in using our framework, please use this source code as your starting point for the project.
To better explain usage of this framework, we have designed a sample
sketch with this framework (sample source
code). It generates the following (not particularly artistic) image
If examining the source code, note well that the Smiley pattern is described so that the center of the face is at (0,0), and that is the reference point that is drawn at precisely the given radius during the stamp() function. Similarly, the Arrow pattern is described with the origin within the middle of the polygon.
Your sketch must meet the following technical requirements:
Please see details regarding the submission process from the general programming web page, as well as a discussion of the late policy.
For this project, we ask that you submit the following three files:
save("mandala.jpg"); // or any other such filename
The assignment is worth 70 points, which will be assessed as follows: