Courses‎ > ‎Computer Graphics‎ > ‎


  • You must include a makefile for each assignment!
    • The makefile should invoke whatever is needed to compile and/or run your program. When I type make, I expect to have your program generate an image.
  • Every assignment (unless otherwise noted) will require both a github submission and an image gallery submission. Full credit will require both.
  • All github repos should be named exactly as described.
      • When working with a partner
        • BOTH members make the repo. One will be used, the other will be empty.
        • The non-empty repo should list both partners names.
        • The empty repo should link to the non-empty repo.
  • NEVER EVER EVER add image files to github
    • Adding image files will result in deductions
    • You can include a .gitignore if you want to help avoid issues!
  • Gallery submissions should be made here:
sample gitignore:

Scanline Deadline

posted Apr 17, 2019, 5:24 AM by Konstantinovich Samuel

The deadline for the scanline assignment is Thursday 3pm.

2019-04-09 ScanLine-ZBuffer

posted Apr 10, 2019, 12:14 PM by Konstantinovich Samuel   [ updated Apr 10, 2019, 12:15 PM ]

Add scanline conversion and z-buffering to your graphics engine.
  • Parser Note:
    • In the previous assignment, I noted that the clear command was no longer needed, because we immediately clear the polygon/edge matrix after a shape is drawn. In order to test Scanline conversion on multiple shapes, a different version of clear is useful. Now, clear will clear the screen and zbuffer, allowing us to reset and test multiple shapes in the same script. 
    • I have added this command to the provided source code, but everyone should implement it.
  • Scanline conversion
    • Create a new function that handles the scanline conversion.
    • Call this in your draw_polygons function.
    • Make sure that you change color values for each triangle.
  • z-buffering
    • In the base files provided, I've added a z-buffer argument to the necessary functions, but have not done anything with it.
    • The z-buffer should only be modified in your plot function, or when clear_zbuffer is called.
    • You will need to calculate z values in both scanline_convert and draw_line.
      • Your z values are not limited to the integers.
GitHub repository:

2019-04-03 07FatCoordinateStacks

posted Apr 3, 2019, 10:33 AM by Konstantinovich Samuel   [ updated Apr 3, 2019, 10:34 AM ]

Due: 8am Monday, 4/8


Repo:  MKS66-CoordinateStack

Note: If you are working in c, I have provided a basic stack library that you can use in the 66source repository

To implement a relative coordinate system... system, add/modify your current parser so it has the following behavior
  • push
    • push a copy of the current top of the coordinate system (cs) stack onto the cs stack (a full copy, not just a reference to the current top... I'm looking at you python people)
  • pop
    • removes the top of the cs stack (nothing needs to be done with this data)
  • translate/rotate/scale
    • create a translation/rotation/scale matrix
    • multiply the current top of the cs stack by it
    • The ordering of multiplication is important here.
  • box/sphere/torus
    • add a box/sphere/torus to a temporary polygon matrix
    • multiply it by the current top of the cs stack
    • draw it to the screen
    • clear the polygon matrix 
  • line/curve/circle
    • add a line to a temporary edge matrix
    • multiply it by the current top
    • draw it to the screen (note a line is not a solid, so avoid draw_polygons)
  • save
    • save the screen with the provided file name
  • display
    • show the image
  • Also note that the identapply and clear commands no longer have any use

2019-03-22 PTC

posted Mar 22, 2019, 5:57 AM by Konstantinovich Samuel


In observance with the longstanding tradition of 'gooning' I now solicit volunteers to be the meatshields between me and the hoards of parents in the upcoming week.

Please send an email to me with the subject line: (depending on which day you can make it)

"PTC Volunteer Spring 2019 Thr"
"PTC Volunteer Spring 2019 Fri"
"PTC Volunteer Spring 2019 Thr Fri"
I will reply This weekend so please send the email sooner rather than later!

Thursday is 5pm-8pm
Friday is 1pm-330pm
I need at least one laptop to help with organization, so please let me know if you normally bring a laptop.

2019-03-21 06Triangles

posted Mar 21, 2019, 6:21 AM by Konstantinovich Samuel

You must do the following things:
  1. Write correct, functioning code.
  2. Submit code that runs the provided testing script
  3. Upload an original picture to the gallery
The Drawing:
  • Create new functions to add a polygon to a matrix, and go through the matrix 3 points at a time to draw triangles.
    • You should have a new triangle matrix that exists alongside the edge matrix. The edge matrix should be used for the shapes that are exclusively 2d (lines, circles, splines), and the triangle matrix for our 3d shapes.
    • Anything aside from shape drawing that modifies/uses the edge matrix (apply, clear, display, save) should now modify/use the triangle matrix as well.
  • Modify add box, add sphere and add torus to add triangles instead of points.
  • Make sure the parser calls the draw_polygons functions when needed instead of draw_lines
  • More to come...

Repo:  MKS66-Triangles

Basefile including the old assignment's parser can be found in the source repo:

2019-03-15 05ThreeDee

posted Mar 15, 2019, 11:50 AM by Konstantinovich Samuel   [ updated Mar 21, 2019, 6:19 AM ]

We will now begin to add 3d shapes (as points only) to our already simmering graphics stew.

Deadline Wednesday March 20th 8am.
You must do the following things:
  1. Write correct, functioning code.
  2. Create a script file
  3. Upload a new picture to the gallery
  • add the following commands to the parser
    • clear: clears the edge matrix of all points
      • c people: this is an incredibly simple operation that shouldn't involve futzing with any of the points in the edge matrix.
    • box: adds a rectangular prism (box) to the edge matrix - takes 6 parameters (x, y, z, width, height, depth)
    • sphere: adds a sphere to the edge matrix - takes 4 parameters (x, y, z, radius)
    • torus: adds a torus to the edge matrix - takes 5 parameters (x, y, z, radius1, radius2)
      • radius1 is the radius of the circle that makes up the torus
      • radius2 is the full radius of the torus (the translation factor). You can think of this as the distance from the center of the torus to the center of any circular slice of the torus.
  • To future-proof your code, you should split sphere/torus creation into 2 parts:
    • Generating only the points on the surface of the shape.
    • Adding the points to an edge matrix so that they can be drawn.
      • Eventually, this part will be changed to handle solid shapes, but the points part will stay the same.
  • You should actually add edges to draw the box.
  • For the sphere and torus, just add the points for each point on the surface, and an edge from it to a point 1 pixel away to make it easier to see.

2019-03-08 04Curves

posted Mar 8, 2019, 9:28 AM by Konstantinovich Samuel   [ updated Mar 21, 2019, 6:19 AM ]

It's time to add curves to the graphics engine. Everything will work as before, we will just have three more shapes to draw .

Add the following commands to the parser
  • circle: adds a circle to the edge matrix - takes 4 parameters (cx, cy, cz, r)
  • hermite: adds a hermite curve to the edge matrix - takes 8 parameters (x0, y0, x1, y1, rx0, ry0, rx1, ry1)
    • The curve is between points (x0, y0) and (x1, y1).
    • (rx0, ry0) and (rx1, ry1) are the rates of change at each endpoint
  • bezier: adds a bezier curve to the edge matrix - takes 8 parameters (x0, y0, x1, y1, x2, y2, x3, y3)
    • This curve is drawn between (x0, y0) and (x3, y3)
    • (x1, y1) and (x2, y2) are the control points for the curve.

Basefile including the old assignment's parser can be found in the source repo:

2019-02-28 03Transform

posted Feb 28, 2019, 6:05 AM by Konstantinovich Samuel   [ updated Feb 28, 2019, 6:05 AM ]

  1. Make a repo: MKS66-transform, get your base code, and the script file from:
  2. Write code to work with transformation matrices:
    • create a translation matrix
    • create a scale matrix
    • create a rotation matrix about the x-axis
    • create a rotation matrix about the y-axis
    • create a rotation matrix about the z-axis
      • Note: The trig functions in python and c take radians as parameters, but you should assume degree input, make sure to convert or things won't look right.
  3. Modify your main routine so that it keeps track of:
    • A single edge matrix
    • A single master transformation matrix
  4. Create a parser that will interpret a script to be used to draw an image.
    • Each command is a single word without spaces in it, and if it takes arguments, the line after will contain the arguments, separated by spaces. For example, a line of the file might look like this:
      • line
      • 0 0 0 100 100 0
    • Here is the full list of commands:
      • line: add a line to the point matrix -  takes 6 arguemnts (x0, y0, z0, x1, y1, z1)
      • ident: set the transform matrix to the identity matrix
      • scale: create a scale matrix, then multiply the transform matrix by the scale matrix -  takes 3 arguments (sx, sy, sz)
      • move: create a translation matrix, then multiply the transform matrix by the translation matrix - takes 3 arguments (tx, ty, tz)
      • rotate: create a rotation matrix, then multiply the transform matrix by the rotation matrix - takes 2 arguments (axis theta)
      • apply: apply the current transformation matrix to the edge matrix
      • display: clear the screen, draw the lines of the point matrix to the screen, display the screen
      • save: clear the screen, draw the lines of the point matrix to the screen/frame save the screen/frame to a file - takes 1 argument (file name)\
  5. The included script tests the various transformations, it should be used when I run make. You still need to create your own image and submit it to the gallery. Please include your script code only when you upload code to the gallery, this way it will be easy for others to try out your pictures!


posted Feb 25, 2019, 7:10 AM by Konstantinovich Samuel

Make sure you create your repos with the correct name as soon as you start an assignment.
You should be commiting and pushing any progress you make.
-Not committing regularly is not acceptable, you should be doing that when you make any reasonable progress.
-Not pushing regularly can make your life harder when you forget to push at the end of your session and can't build on what you worked on.

I should be able to clone the repos and check on progress at any point in the lab.

2019-02-13 02Matrix

posted Feb 13, 2019, 11:48 AM by Konstantinovich Samuel   [ updated Feb 28, 2019, 6:06 AM ]

There is no spoon.

This will be due Monday, 2/25

Implement the following features but you cannot trivialize the problem by using a structure that already exists in the language you choose:
  • Create a repo: mks66-matrix
  • General Matrix stuff
    • matrix multiplication  (you may assume a 4by4 times a 4byN)
    • creation of an identity matrix
    • displaying a matrix in a reasonable manner
  • Graphics matrix stuff
    • add a point to an edge matrix
    • add an edge to an edge matrix (should call your add point routine)
    • go through an edge matrix and draw the lines stored in the matrix (should call your draw line routine)
    • output and display an image file
  • Demonstrate your multiply works using the following: (do not reset the values of A and B after each operation)
    • A = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}
    • B = {{11,12,13,14},{15,16,17,18},{19,20,21,22},{23,24,25,26}}
    • mult(A,B)
    • print A
    • print B
    • mult(B,A)  
    • print A
    • print B
    • mult(IDENT,A)
    • print A
  • Upload an image to the gallery page.

READ THROUGH ALL THE SOURCE FILES. Detailed instructions are provided as comments. 

Here is an example of what would happen if you added 2 points and multiplied:
Testing add_edge. Adding (1, 2, 3), (4, 5, 6) m2 = 
1.00 4.00 
2.00 5.00 
3.00 6.00 
1.00 1.00 

Testing ident. m1 =
1.00 0.00 0.00 0.00 
0.00 1.00 0.00 0.00 
0.00 0.00 1.00 0.00 
0.00 0.00 0.00 1.00 

Testing Matrix mult. m1 * m2 =
1.00 4.00 
2.00 5.00 
3.00 6.00 
1.00 1.00 

Testing Matrix mult. m1 =
1.00 4.00 7.00 10.00 
2.00 5.00 8.00 11.00 
3.00 6.00 9.00 12.00 
1.00 1.00 1.00 1.00 

Testing Matrix mult. m1 * m2 =
40.00 76.00 
47.00 92.00 
54.00 108.00 
7.00 16.00 

1-10 of 13