challenge: design a function that takes a list of vertex's (how ever you choose) that form a convex polygon. then computes the surface of that polygon.
judging criteria:
1. who can make the function with the least lines.
2. who can make the function that calculates the area fastest.
all calculations have to be 98% accurate.
note: you can have two entries, one function for the fewest lines, and one function for the speed.
i will supply a file with a large convex polygon, and also a function for reading in the polygon.
however you are free to do it on your own.
thanks, and good luck!
here is a sample polygon at 10000 vertex's
http://www.mediafire.com/file/mzaiamjztnz/poly.bin
edit: polygon reader/parser
Code: Select all
void loadPoly(char *fileName)
{
fstream binGet(fileName, ios::binary|ios::in);
int num = 0;
float data = 0;
binGet.read((char*)&num, sizeof(int));
printf("Number of vertex's = %d\n", num);
for(int a = 0;a < num;a++)
{
binGet.read((char*)&data, sizeof(double));
// set your vertex's X value here
binGet.read((char*)&data, sizeof(double));
// set your vertex's Y value here
}
binGet.close();
}