lab3 - CSS 342: Mathematical Principles of Computing Lab 3:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Lab 3: Recursion Professor: Munehiro Fukuda Assigned: See Our Syllabus Purpose This laboratory draws a simple fractal figure using recursive calls. Part 1 implements a simple class named "Turtle" to draw a line segment or changes its forward direction. Thereafter, Part 2 derives Sierpinski allowhead, using "Turtle". Turtle Graphics A Turtle graphics tool behaves as a pen point. Given initial (x, y) coordinates, it responds to one of the following three messages at a time: draw draw a straight line with a given distance from the current point and move to the other end point of this line. move move straight to the destination whose distance from the current point is given as an argument. Do not draw any line segments. turn turn left by a given angle. Turtle is initialized to draw/move to the right direction. If it is ordered to turn by 90, 180, 270, and 360 degrees, it is ready to draw/move to the up, left, down, and right direction, respectively. Since C++ cannot draw any graphical image directly on a computer display, Turtle should output its locus in postscript format. A Minimalist Overview of the Postscript Language We cover only the most basic, simplified aspects of the Postscript language necessary for this assignment; a more complete reference to the language is the PostScript Language Reference . Postscript is a stack-based, interpreted language, and a function is called by first pushing its arguments onto a stack and then specifying the function name. Any time a literal integer argument appears in the input, it is pushed onto the stack. Thus, the command 0 0 moveto calls the moveto function, which takes two arguments (which were pushed onto the stack first). Because Postscript is a graphics language, there are a host of basic functions which produce graphical output. We will need the use of only a few basic commands, which are part of Level 2 Postscript: moveto Set the current point to (x, y) . Takes two arguments: x and y . rmoveto
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 12/20/2009.

Page1 / 5

lab3 - CSS 342: Mathematical Principles of Computing Lab 3:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online