Asg 3: List of 3D Points

Objectives

To implement a point_t object, read a file, and add points to a list (std::vector).

Assignment

  1. Using the code from Assignments asg01 and asg02, read a file of 3D points into a list and print them out. You can use either a list of objects or a list of pointers to objects (more efficient).

Details

  1. Your point_t object should provide the following:

Requirements

  1. Your code should be such that the main() routine should be similar to those of Assignment 01 and Assignment 02.
  2. Make sure that you properly delete the list of points by deleteing each point pointer as you erase each one from the list

Input

  1. The pointdata.txt file used to test the above program is:
     1.0 -1.0  1.0
    -1.0 -1.0  1.0
    -1.0 -1.0 -1.0
     1.0 -1.0 -1.0
    	

Output

  1. Expected output with the above input file should resemble:
    *** printing list
    1.00, -1.00, 1.00
    -1.00, -1.00, 1.00
    -1.00, -1.00, -1.00
    1.00, -1.00, -1.00
    *** printing list again
    1.00, -1.00, 1.00
    -1.00, -1.00, 1.00
    -1.00, -1.00, -1.00
    1.00, -1.00, -1.00
    p_i[0] = 1.00 p_i[1] = -1.00 p_i[2] = 1.00
    p_i[0] = -1.00 p_i[1] = -1.00 p_i[2] = 1.00
    p_i[0] = -1.00 p_i[1] = -1.00 p_i[2] = -1.00
    p_i[0] = 1.00 p_i[1] = -1.00 p_i[2] = -1.00
    |p_0 - p_1| = 2.00
    *** deleting list
    *** deleting list again
    *** done
    	

Supplemental

  1. Here is a Makefile that you can use to compile the project:
    .SUFFIXES: .c .o .cpp .cc .cxx .C
    
    UNAME = $(shell uname)
    PLATFORM = $(shell uname -p)
    
    CC = g++
    COPTS = -g -Wall
    
    INCDIR =
    LIBDIR =
    
    ifeq ("$(shell uname)", "Linux")
    LIBS = -lm
    else
    ifeq ("$(shell uname)", "Darwin")
    LIBS = -framework Foundation -lstdc++
    endif
    endif
    
    .c.o:
    	$(CC) -c $(INCDIR) $(COPTS) -o $@ $<
    
    .cpp.o:
    	$(CC) -c $(INCDIR) $(COPTS) -o $@ $<
    
    all : main
    
    OBJECTS = \
    point.o
    
    main : $(OBJECTS) main.o
    	$(CC) -o $@ $(INCDIR) $(COPTS) $(OBJECTS) $@.o $(LIBDIR) $(LIBS)
    
    point.o: point.h point.cpp
    
    clean :
    	rm -f *.o
    	rm -rf main main.app
    	

Turn in

Turn in all of your code, in one tar.gz archive of your asg##/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    4. Lessons learned, identified interesting features of your program
    5. Any special usage instructions
  2. Makefile
  3. source code (.h headers and .cpp source)
  4. object code (do a make clean before tar)

How to hand in

See handin notes

Grading scheme