The assignment: will have three parts:
Discussion/hints: Here is a possible method for implementing SRGP_lineCoord(x1,y1,x2,y2) (you may have a different way of implementing lines) :
if abs(x2 - x1) > abs(y2 - y1)
call xLine(x1, y1, x2, y2)
else
call yLine(x1, y1, x2, y2)
if x2 > x1
call xLineIncrease(x1, y1, x2, y2)
else
call xLineIncrease(x2, y2, x1, y1)
Further Hint: In the past, I received the following question from a student:
> Is it all right if (inside SRGP_polyLineCoord) we call SRGP_lineCoord > and let it call SRGP_Line, rather than having a SRGP_polyLine > (or polygon) procedure?Answer: You need to implement all 6 of the routines, but you can do so as simply as possible (i.e. do as little coding as possible) -- you need not implement each one "from scratch". For example, as you suggest, if you implement SRGP_line, then you can implement SRGP_lineCoord by a single call to SRGP_line (and a small bit of code), and in turn you can implement SRGP_polyLineCoord by a sequence of calls to SRGP_lineCoord (which, as you point out, will automatically call SRGP_line). Then SRGP_polygon can be implemented by one call to SRGP_polyLine and one call to SRGP_line. Similarly for SRGP_polygonCoord.
Actually, I myself would do things slightly differently: I would first implement SRGP_lineCoord "from scratch" and then SRGP_line would be a single call to SRGP_lineCoord, etc...
Other possible help: There are two sample programs, ( lab1sample1 - noninteactive, written by a student, and lab1sample2 - interactive, written by me) in the lab1 directory of the class account: /opt/local/studata/COURSES/cs5721. The README file describes all the files in lab1.
I broke up my C program into main.c, which contains an interactive loop, the SRGP module, mySRGP.h and mySRGP.c, and the interface module that handles user interaction, interface.h and interface.c. I used the Makefile to compile my program.
Extra Challenges/credit: (1 point each)
What to turn in:
Turn in the following items from the
Computer Science Lab Report Format:
1. (1 point) The Basic Information (your name, class, section,
TA's name, assignment number, and date) can be on a separate cover sheet or as
(highlighted) comments at the top of your main program file.
2. (1 point) The Problem Statement is a brief description of
The assignment: above. Note: the problem statement can (and should)
be in a comment at the top of your main program file.
4. & 5. (5 points) do this for your "line" algorithm
9. (up to 2 points if done) Document the Extra Credit part
of your program if you did it (by coded/hand-written comments and highlighting
-- as usual).
11. (5 points) Include all program listings and output.
These listings should show good style,
be appropriately commented, have the important parts
highlighted, and include handwritten explanations if it helps the
reader's understanding of the code.
13. & 14. (8 points) The most important part.
A program run (or separate program runs) should demonstrate that your
primitives work correctly.
The Test Descriptions are handwritten explanations on these
printouts of what each program run demonstrates.
15. Include a description of any Known Bugs if needed.
You may be able to gain back lost points by a careful analysis of
what went wrong and possible fixes.
16. This is optional (and no points usually),
but it is useful to think about Possible Improvements.
17. Comments on the lab assignment are also optional
(and again, no points usually), but appreciated!
Important Note: You may discuss algorithms with other students, but the program and lab report should be your own work.