Triangle Classifier
- Due Aug 31, 2015 by 11:59am
- Points 10
- Available until Aug 31, 2015 at 11:59am
The classifier takes six command line arguments. The first two are respectively the x and y coordinates of the first vertex of the triangle, the second two are respectively the x and y coordinates of the second vertex, etc. Each coordinate is a decimal integer in the range –(2^30 – 1) to (2^30 – 1).
The output of the triangle analyzer is a single line of text that is terminated by a newline. The triangle analyzer should output “error” if the input format does not match the one specified above. Otherwise, it should output either "not a triangle" or the result of the analysis of the triangle. The output should match this regular expression:
(((scalene|isosceles|equilateral) (acute|obtuse|right))|not a triangle|error)\n
Three vertices are not a triangle if they are colinear. A triangle is equilateral if all three sides have the same length, isosceles if exactly two sides have the same length, and scalene otherwise. A triangle is right if one of its angles is 90 degrees, it is obtuse if one of its angles exceeds 90 degrees, and is acute otherwise.
Non-functional requirements:
- The classifier must be written in C that can be compiled by GCC and Clang on a Linux machine. The test machine is x86-64, but your code should also work when compiled to a 32-bit target, and should in general be as portable as possible.
- It is fine to use external libraries but please email me if you want to use something that is not standard.
Submission:
- Push your analyzer to a directory in the class github repo called "triangle/username" where "username" is your github user name.
- Include a makefile so that when someone types "make" in your triangle directory, the result is an executable called "triangle".
- Do not add your executable to git.
- Try not to make your code or makefile machine- or OS-specific; ideally it can be compiled on any Linux machine.
Finally, apart from the above, also submit a collection of reasonable tests (at least 10) along with your code.