Assignment 2: Convex hull with Graham's scan
In this assignment you will write code to find the convex hull of
a set of points (in 2D) using Graham's scan. You will receive starter
code on Github which contains two versions: one in c and and one in
cpp. The code should compile as is, and provides the graphical
interface.
What you need to do:
- Fill in the graham_scan function, and anything else that
may be necessary to make it all work.
- Come up with an interesting configuration of points on which to
compute the hull, and write the corresponding initializer
function. It can be easy, but should not be trivial. Post your
special initialier function to the whole class (maybe on Slack).
- Include your classmates test cases in your code.
Work in style
As usual, you need to strive to write not just code, but code that is simple,
elegant and easy to understand. Furthermore, you need to strive
to do this out of habit, as you start, and not only at the
end as an afterthought. Writing good code has to become your second nature. Write good
code not because I tell you to do it, but because you don't know any other
way. Just do it.
People often disagree what consitutues elegant when it comes to
coding, but everyone agrees on the following:
- layer your code into small functions with intuitive
arguments that allow you to test your code incrementally after every
function you add
- test everything you write
- 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 directly proportional to how easy and
enjoyable is to debug and update/extend your code. If you find
debugging is frustrating and exhausting and like searching for a needle in a haystack...
then your style needs to improve. Programming is supposed to be fun.
Pair programming
You are encouraged to find a partner and work as a team (make sure you
read and follow the pair-programming policy on class website). But if
you would rather work alone, or if you don't know anyone in the class
yet --- that's totally fine, work alone.
What and how to turn in
You will receive the assignment on GitHub. Push your code into your
github repository for this assignment.
You are encouraged to do pair-programming, but feel free to work
alone.
Provide a README that describes the state of your code (does it work on
all test cases, do you know of any bugs, any extra features).
Enjoy!
Last modified: Wed Sep 22 12:58:43 EDT 2021