differences
kjyv opened this issue · comments
I didn't test it but your lines
if (isConvex) {
figsVec.push_back(queue.front());
queue.pop();
}
seem to do something different from the original
if (isConvex) {
figsVec.push(queue.shift());
}
Cheers
Hey Stefan,
Thanks for your input =)
I'm pretty sure both snippets are doing the same thing.
AS3's array method, shift(), simply pops the front element off of the array and returns it as a value
myArray = ["a","b","c","d"];
trace(myArray);
front_elem = myArray.shift();
trace(myArray);
trace(front_elem);
// OUTPUT
// a,b,c,d
// b,c,d
// a
So, referring to the snippet in question:
// queue = ["a","b","c","d"]
//push "a" onto figsVec AND remove "a" from queue
figsVec.push(queue.shift());
// queue = ["b","c","d"]
I'm implementing the same behavior in C++ by using an actual STL queue
//queue = ["a","b","c","d"]
//first push "a" onto figsVec
figsVec.push_back(queue.front());
//then, pop "a" from queue
queue.pop();
//queue = ["b","c","d"]
In any case, the class has since been tested and ot works =D so go ahead and try it!
Oh, sorry my fault then. I was thinking that pop removes from the end. But a proper queue does it like this STL queue I guess :)
I was just looking at your code to compare and find bugs in a javascript port im trying to debug (but I didn't find any other differences).
It seems that validate and det have problems with some polygons with some very close vertexes. I'm still not sure validate works alright...