Student: minneyar Assignment: 2 Grader: Damian ************************************************ Bresenham: program runs, buggy (55): 55 correct implementation of Bresenham (20): 10 no floats and divides (20): 20 extra credit (5): 5 ---------------------------------------------- total (100): 90 Cohen-Sutherland: program runs, buggy (55): 40 inside case correct (10): 10 outside case correct (10): 0 one clip correct (10): 10 two clips correct (10): 10 extra credit (5): ---------------------------------------------- total (100): 70 Comments: ---------------------------------------------- Bresenham Algorithm: A mostly functioning implementation of the algorithm, although it fails in the case where x1 > x2 and dy=0 (i.e. a horizontal line drawn right to left). In terms of your implementation, you really don't need to write that much code to handle the special cases. In fact, things like horizontal lines -- and CERTAINLY diagonal lines -- should be automatically handled by Bresenham. Maybe you could make the argument that handling the special cases separately is more efficient, but that efficiency in run-time does not make up for the loss of efficiency of resources, space, understandability etc. CohenSutherland Algorithm: Yikes! Your CohenSutherland algorithm has a very serious error, I suspect a "looping forever" error. This occurs when a line is drawn from the region to the right of the viewport to the area to the top-right of the viewport, or vice versa. I'm not going to go through and debug your code, but that's definitely something to be fixed. I'm not sure, but it might be a problem with the way you are calculating the outcodes -- which is not correct. You're treating the outcodes as integers, when you add result = result + 1000 or result = result = 0100. That just means that you end up with outcodes like 1010 or 1011 DECIMAL, not binary. What you need to do is add numbers who binary representation is the bit-string 0100 or 1000 etc. i.e. rather than doing result = result + 1000 you need to say result = result + 8, because 8 (decimal) = 1000 (binary). *************************************************