Assignment 1 -- Bresenham Line Scan Conversion
How do I get started?
Open up a browser and get to the Educational Fusion page. The URL is
Choose "Enter Educational Fusion." This should take you to
the URL
Log in using your Athena username (the first time you log in, you will
be asked to choose a password). Only those who provided their Athena username
on the in-class signup sheet will have Fusion logins. If you did not make
it to class, or are otherwise unable to log in, email fusion@graphics.lcs.mit.edu
to request an account.
After successfully logging in, be patient; it may take a minute or two
for code to download to your browser. At this point, you may wish to make
your browser full-screen to give yourself more room.
What's going on here?
For this assignment, you will implement the Bresenham line scan conversion
algorithm. This algorithm takes a 2D line segment specified by its endpoints,
and determines which discrete pixels should represent it. You will write
Java code in a text window to implement the algorithm. The text is then
shipped to a server, where it is compiled and sent back to your browser
to be executed.
Please note that this is a new system that has never before been used
for an assignment. Please bear with us if the system is slow or doesn't
work exactly as described. We will do our best to correct problems
as they arise. We think that despite the experimental nature of the
Fusion system, you will enjoy using it (now, where have you heard that
before!). Your comments and bug reports (filed via two buttons always present
at the lower right of the screen) will help us improve the system for the
benefit of current and future students.
How do I use the system?
Once you are logged in, you will see three frames.
- The frame at top left, called the Collaborator, allows you to
collaborate with other students via a chat window and shared whiteboard,
and place yourself on a TA queue to get help. (You can click on the "Next"
and "Previous" buttons at the bottom of the frame to cycle through
the different features.)
- The frame at bottom left, called the Concept Graph, allows you
to choose which assignment you want by double-clicking on a topic module.
(Start with Bresenham.)
- The frame at right, called the Topic Module, is where you will
write, compile, test, and eventually submit your Java code.
When you are ready to begin, do the following:
- If you don't see two "modules" (colored rectangles) in the
concept graph, click inside its frame and hit 'l' (lowercase L). A dialog
box will then ask if you want to re-load "Default.cg". Click
YES.
- Open your browser's "Options" menu and click on the "Show
Toolbar", "Show Location", and "Show Directory Buttons"
toggles. This should remove some of the controls at the top of your browser,
giving you more room to work.
- Click on and drag the frame borders to change how much space each frame
consumes. This will let you make the most of your screen real-estate.
- Double-click on the Bresenham module in the concept graph. Your topic
module should now contain the Bresenham applet.
- At the top of the Bresenham applet are four buttons: "Correct",
"Manual", "Yours", and "Difference". Click
on the "Correct" button. In this mode, a correct version of the
algorithm is demonstrated. Try drawing lines in the 2D plane with the mouse.
You will see that for each pair of endpoints you specify, some set of pixels
are illuminated.
- Click on the "Manual" button. In this mode, you are challenged
to specify a representative set of pixels "by hand"; that is,
non-algorithmically. Draw a line, then follow the instructions in the text
box to the right of the applet. These instructions will step you through
the algorithm.
- Click on the "Yours" button. In this mode, you are executing
your own compiled code. Since you haven't written any code yet, no pixels
will be illuminated when you draw a line.
- Click on the "Difference" button. In this mode, you will
see the difference (if any) between your solution and the correct
solution when you draw a line.
- To start the assignment, change to "Yours" mode. The
text box at the bottom of the applet contains the body of the function
drawLine(int x1, int y1, int x2, int y2). (Right now it contains
only comments.) Write Java code to complete the body of the function.
You must call the function setPixel(x, y) to illuminate an individual
pixel at coordinate (x,y).
- When you are ready to compile your code, click on the "Evaluate"
button below. Any compiler error you get will be reported in the text box
to the right. Note that you can toggle back and forth between Correct,
Yours, and Difference modes as you wish, and that all "evaluated"
code snapshots are saved for you and available by selection.
- Try some test cases. Does your code handle shallow lines? Steep ones?
One-pixel segments? Don't kill yourself implementing code for all eight
symmetry cases; you need submit code only for the case in which (x1
<= x2) and |y2-y1| <= |x2-x1|.
- When you are finished with the assignment, click on "Submit
for Grading" to hand it in. Your code will be stored at the server,
and you will be brought to a brief form asking for feedback about the system.
Please fill out the form; doing so is part of the assignment.
What if I have never used Java before?
The Java language is very similar to C/C++. There are, however, minor
differences. If you are having problems compiling, you may want to look
at The Java
Language Specification.
Don't Forget:
Scan converting lines is fun! Think of the applications!