For this programming assignment, you will be given a source code template (including a subroutine for reading the input data and writing out integer data to an image file). The source code fragment can be downloaded from the web page (see links at the bottom of this page). Please turn in one executable (with source code) for each of the 4 parts of the assignment.
Important note: All output for this programming assignment should put the (0,0) pixel in the lower left corner of the image. The image reading/writing subroutines we provide are based on an image represented by a 1D array of 'unsigned char' (one per greyscale pixel), which starts at the top left corner of the image and progresses left to right, top to bottom, to end at the bottom right.
Fill in the source code fragment to draw lines using the Bresenham
line drawing algorithm presented in class. The endpoints for the lines
should be read in from the data file "pa1_1.dat"
which is also available from the web. Your routine should determine
which pixels are turned on and set the appropriate values in the 1D
unsigned char array. The pixels that are turned on should be set to 255.
Be sure to handle all cases.
Read in a set of endpoints for a series of line segments from the file "pa1_1.dat". After clipping, use your code from Problem 1 to draw the clipped lines (again, by setting the appropriate pixels in the 1D unsigned char array). The clipping window is defined in the code fragment as
#define VIEWX0 15
#define VIEWY0 15
#define VIEWX1 85
#define VIEWY1 85
Add the Midpoint Circle-Drawing algorithm to the code of problem
2, and draw a partial circle with radius 30, centered at pixel (50,50),
starting at (71,71) and ending at (34,25) (progressing clockwise).
Do this after clipping the "pa1_1.dat"
data. This means that you DO NOT clip the partial
crcircle.
Image A: Translate: 0,0,0
Rotate: about Z 0, about Y 0, About X
0
(Angles in Degrees)
Image B: Translate -50,-50, -30
Scale 0.5, 0.5, 0.5 (This is so you can
see the whole object in your clipped window)
Rotate: about Z -45, about Y 0, About X
-45 (Angles in Degrees)
Translate +50,+50, +30 (Centers the object on our
screen)
| Problem 1 Code Template | pa1temp.c |
| Problem 1 PGM output Code | wrtimg.c |
| Problem 1 2D Data Reader | rdinput.c |
| Problem 1 3D Data Reader | rdinput3d.c |
| Line End Point Data file | pa1_1.dat |
| 3D Data set for part 4 | pa1-3D.dat |
| Optional Makefile |
Makefile |