Another update for you guys.... I coded up an OPTIMAL solution. It's so damn inefficient it can't handle more than 13 vertices. Professor said my other algo wasn't good enough, so he made me code up this POS. The other one can handle over 500 vertices in the blink of an eye and is optimal 99.9% of the time... (I can't find a case where it's not, but maybe I'm just stupid).
Anyway, if you're intrigued, the optimal sol'n works like this (it's O(n^4)... at least)
Code:
EdgeList Polygon::decomp() {
Edge diag;
EdgeList min, tmp1, tmp2;
int nDiags = std::numeric_limits<int>::max();
bool found = false;
for (int i = 0; i < v.size(); ++i) {
if (isReflex(i)) {
for (int j = 0; j < v.size(); ++j) {
if (canSee(i, j)) {
tmp1 = copy(i, j).decomp();
tmp2 = copy(j, i).decomp();
tmp1.insert(tmp1.end(), tmp2.begin(), tmp2.end());
if (tmp1.size() < nDiags) {
min = tmp1;
nDiags = tmp1.size();
diag = Edge(at(i), at(j));
found = true;
}
}
}
}
}
if (found) min.push_back(diag);
return min;
}