22C:030/115 Computer Science III

Fall 2001

Program 3: Polylines

DUE DATES:


This program requires you to design, implement and test a templated class called Polyline. The Polyline class represents a connected sequence of three-dimensional line segments. You are to write a program demonstrating your classes that generates a set of Polylines approximating several mathematically defined shapes including spiral curves, sine waves, and Kock snowflakes. The assignment will give you experience in developing a clear specification from a problem statement, experience in the use of linked lists, and additional experience in software coding and testing.



 
 
 
What to submit:
You should submit a directory that includes:
  1. README: A file giving a overview of the contents of the directory including:
  2. polyline.h: The header file for the new Polyline class.
  3. polyline.template: The implementation file for the new Polyline class.
  4. polylinetest.cxx: An program that tests the Polyline class.
  5. polylinedemo.cxx: An demonstration program.
  6. polyline.dat: The output of your demonstration program including polylines approximating spirals, sine curves, a Koch snowflake.
  7. A printed copy of the files README, polyline.h, polyline.template, polylinetest.cxx, and, polylinedemo.cxx to be submitted in lecture at the beginning of class on the due date.

The Polyline Class

You are to design, implement, and test a new templated class called Polyline that represents a sequence of n three-dimensional line segments connecting a series of n+1 three dimensional points. For example, the Polyline
p = ((1.0,1.0,0.0), (-1.0,1.0,0.0), (-1.0,-1.0,0.0),
                                (1.0,-1.0,0.0), (1.0,1.0,0.0)
defines four line segments that form a square in the z=0 plane centered on the origin as pictured below.

In addition to its shape, a Polyline should have a color attribute expressed by three values giving red, green, and blue components of the color. You should use the Point3D class from the first project to represent the points in a line segment.

A Polyline must be represented as a linked list of points.  You may choose to use either a singly or doubly linked list. You should base the Node class and linked list toolkit on the versions defined in the text. A templated version of this code is available in the class account in the directory /group/class/c030/programs/chapter6. The node structure for a singly linked list is pictured below.
 


 

The Polyline class should include the following functions and operations: