Assignment: Convex hull with Graham's scan algorithm
Develop code in C/C++ to compute the convex hull of a set of
points in 2D using Graham's scan algorithm.
Base code is provided here.
You will see two versions of the code: one in c and and one in cpp. It will be
nice if you use this class as an excuse to learn more c, but if you
want to do cpp, that's fine too (you will probably not write OO code,
just c plus the vectors and linked lists that come conveniently
with cpp).
The code should compile as is, but it does not do anything besides
the interface. You need to fill in the graham_scan function, and
provide some interesting test cases (configurations of points) on
which to compute the hull. Every team, please email your special test_cases to the whole class, so that everyone can include everyone's test cases in their code, and check that their CH code works well in all cases.
Team work
You are encouraged to work with a partner, but you don't have to. If you work with a partner, you will be held to higher standards than if you work alone; put differently, you'll need to do more work than if you work alone.
When you decide one way or the other, email me so that I can ask DJ to set up the svn folders.
Good style
As usual, you need to strive you write not merely code, but simple,
elegant and easy to understand code. Furthermore, you need to strive
to do this out of habit, as you start programming, and not only at the
end. Writing good code has to become your second nature. Write good
code not because you have to, but because you don't know any other
way.
People often disagree what consitutues elegant when it comes to
coding, but everyone agrees on the following:
- structure your code into small functions with intuitive
arguments that allow you to test your code incrementally after every
function you add
- code should be well documented, ideally at block level but
certainly at function level. Every function should have a header
specifying what are the expected input values, what is the return value, and what
does the function actually do.
- no function should be longer than a screen
- code should be accompanied by a README tha details how to run
it, and whether there are any known bugs that the user shoud be
aware of
- [insert here all style guidelines that you know from pevious classes]
How do you know if you write good code? My theory is that the the
quality of your code is ditrectly proportional to how easy and
pleasant is to debug and update/extend your code. If you find debugging is frustrating and like searching a needle in a haystack, then your code style is probably not good.
Submitting your work
Make a folder called convexhull in your svn folder on
microwave. I will have access to this svn, so no need to submit
anything --- just make sure everything is checked in.
Enjoy!
Last modified: Mon Mar 28 18:26:56 EDT 2016