






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lab assignment for implementing the codo language for affine geometry and generating fractals using iterated function systems. Students will write code to parse and execute commands, implement basic constructors, and utilize utility functions and constructor functions for geometry and transformations. The document also includes details on codo data types, constants, command syntax, and examples of simple shapes and operators.
Typology: Lab Reports
1 / 10
This page cannot be seen from the preview
Don't miss anything!







Due Monday, 2 October 2006, 11:59 PM
In this project you will implement the CODO (COnnect the DOts) language for affine geometry. Using this language, you will render simple and complex two dimensional shapes. You will also generate fractals using iterated function systems.
This project is due at 11:59 PM on Monday, October 2nd. It is worth 100 points. For this lab, you must work with a different partner than the one you worked with in lab 1. As soon as possible, send an email with your partner’s name and username to [email protected]. If you have trouble finding a partner, let us know and we will try to pair you up.
The user interface for this program is similar to the interface in your turtle program. The program will parse and execute commands entered by the user at the command line. In addition, the program will respond to certain keys, as noted below.
The first portion of the lab involves implementing the basic constructors of the CODO shapes. Higher-level constructors should be implemented in terms of simple constructors. For example, a polygon is created by applying rotation to an initial point. You will get no credit for turning in a turtle-based implementation of any command.
The global coordinate system is set up so that the origin lies in the center of the program window, the x-axis increases horizontally to the right, and the y-axis increases vertically.
Your program accepts one optional command-line argument, a string specifying the name of a file. The file will be executed as a script (see the section “Script Files,” below). Under Windows, opening your program by dragging a file onto the program’s icon will pass the name of the file as an argument to your main() routine.
CODO Data Types
There are four types of objects (or “data types”) that are specified in CODO:
Most of the commands listed below involve creating, manipulating, naming, and drawing these data types. Any object of any data type can have a name. Points and lines can be drawn on the screen, but vectors and transformations cannot.
The CODO Namespace
There is a single CODO namespace shared by all data types. Each name the user defines is associated with a unique data object. Once defined, a named object cannot be modified or removed from the namespace, except through the clearNames command. In particular, if a name exists in the namespace, a new object may not be associated with this name (until the namespace is cleared).
Names are not case-sensitive, so point1 is the same name as Point1. This year we will not require you to implement the CODO namespace functionality. Our neighborhood graduate student has provided this for you.
CODO Constants
Three constants are defined in CODO. These names cannot be modified or removed from the CODO namespace. (NOTE: If you attempt to modify these constants, the program will not crash; it will simply print error messages in the command prompt.
C: The point representing the origin of the global coordinate system, with affine coordi- nates C = (0,0,1).
W: The unit vector pointing along the x-axis of the global coordinate system, with affine coordinates W = (1,0,0).
I: The identity transformation, implemented as a 3x3 matrix with 1s on the diagonal and 0s elsewhere. NOTE: If you are using the support framework, you will have to provide the structure for the identity and add it to the environment. This will be discussed in the tutorial sessions.
CODO Command Syntax
The commands that your program must respond to are similar in format to the turtle commands of lab 1. As in lab 1, command tokens are separated by one or more blank spaces.
There are two kinds of CODO commands: utility functions and constructor functions. Utility functions do not “return” data; instead, they cause some kind of change to the program’s state, such as drawing new geometry. This year if you use the support framework, we will not require you to implement the utility functions. Once again, our neighborhood
Drawing commands
Geometry Fundamentals (5 Points)
Affine Transformations (15 Points)
Simple Shapes (15 Points)
Simple Operators (15 Points)
The Hangman Fractal, a Fractal Bush, and a Fractal Tree.
Turtle Bump Fractal (15 Points)
This function should create an iterated function system to build an equivalent fractal. Are there any cases where the IFS generates a shape that differs from the output of the corresponding turtle program? If so, why? If not, why not? (These questions should be addressed in your README file).
Pretty Pictures (15 Points)
Create new constructor functions or script files for interesting and unique geometry of your own. Be creative. You should document how to produce your pictures in your README file.
For full credit, you need to create at least four interesting pictures. At least two of these should be new fractal commands. The others may be new commands or interesting script files.
Your program should exit any time the user presses the escape key.
You should not use any OpenGL commands other than the ones you used in lab 1. OpenGL provides the ability to set up and apply transformation matrices, but you should not use OpenGL for this purpose within this lab. You will need to create your own facilities for composing and applying affine transformations.
There are no commands to define points and vectors by giving their coordinates. You should not extend the command set to allow such definitions. All points and vectors must be derived from the CODO constants by applying transformations. (This is an absolute condition for commands and script files).
Implementation Notes
Lab 2 has a framework that provides the base functionality of the CODO system. There is an environment for CODO in which objects are stored with their corresponding names (if they have them). There are blank class definitions for Polygons, Rosettes, Transformations, etc. It is your responsibility to fill out the definitions of these classes. The Point, Vector, and Line classes have already been populated for you to give you some hints as to how to proceed with your implementation. Each class has a draw method that is used to render itself. All rendering code should be placed in this function for an object type. Assume that this method is only called from the context of the rendering function callback. Each class also has Print and Copy methods that you will have to provide the intelligence for (including the Point, Line, and Vector classes).
One important implementation note, the CODO Namespace has a built in garbage col- lector that deletes objects that are not assigned to a variable name during each idle callback. This is important because when constructors are passed as arguments to other constructors, you must know that the input object will be deleted unless the object is already assigned or is being assigned to a variable name. If some of your classes contain pointers to other data types be sure to use the copy method for the input object(s).
Drawing Fractals
When drawing fractals there is one extra bit of functionality. When the user presses the ‘-’ or ‘+’ keys, the fractals should either decrease or increase their level of rendering. This does not apply to their base cases (so if a child fractal is the base case to a parent fractal then the child will not be affected this functionality). If you are using the framework then this functionality is handled by the incr and decr methods for fractals which you will need to implement.
The keystrokes ‘-’ and ‘+’ can only modify the geometry visible on the screen. Objects in the namespace are not affected.
As an example, consider the following set of commands.
Only one partner per group should turn in code. The other partner should put a README file in his or her own ~/comp360/lab2 directory that gives their partner’s name and username.
Do not touch the files in your submission directory after the project deadline. If your project will be completed late, email your labby and let him know. Otherwise, he may attempt to grade an incomplete or nonexistent project directory, and the project grade will reflect this.