next up previous
Next: Use drawPolygon Up: Part One Previous: Part One

Noah


\begin{figure}
\centerline{
\psfig {figure=fig_ass7.eps,width=3.0in}
}\end{figure}

I want you to build me an arc. And I want it to be width cubits wide, and I want it to be height cubits high. And I want it to be x cubits from the corner that is the upper left hand corner in the direction that runs from east to west. And I want it to be y cubits from the corner that is the upper left hand corner in the direction that runs from north to south.

Although biblical idioms have some of the properties of formal languages, conciseness and lack of ambiguity are not among them.

1.
Create a new project of the Applet variety, and name it Noah.
2.
Using the first draft you worked on in class, write a method called paintArc that takes a Graphics object and a Rectangle as arguments and that draws an arc as in the figure on the next page.

3.
Modify paint so that it creates a Rectangle, puts in values of x, y, width and height, and invokes paintArc.

HINT: No, you may not use the drawArc method.

HINT: To test your method rigorously, give it a Rectangle that is not the bounding box of the screen. In other words, use values of x and y that are not 0, and values of width and height that are not the size of the screen, and not equal to each other.

HINT: Make it easy to configure your program to draw more or fewer line segments. If you are feeling clever, you might even make the number of line segments proportional to the size of the bounding box. That way, small arcs are drawn quickly and large arcs are drawn accurately.

HINT: If you can, write your program so that each point along the arc only gets evaluated once.

HINT: Be careful about the last point. Make sure that you don't stop short of $\theta = \pi/2$ and that you don't go beyond it. You might want to draw the bounding box before you call paintArc and then make sure that paintArc does the job correctly.


next up previous
Next: Use drawPolygon Up: Part One Previous: Part One
Allen B. Downey
3/18/1998