[FIXED] BayazitDecomposer issue.

Topics: Developer Forum
Feb 20, 2013 at 7:54 AM
Edited Feb 20, 2013 at 7:57 AM
Hello,

Everything was working fine and then I changed the shape of my polygon. Now the Bayazit Decomposer is throwing an exception. I am poked around behind the scenes but I am confused into why only one vertex is getting passed in and how to fix it. Below I have included a zip of the broken project and an image of the exception.

Visual Studio Project

Image

Thanks for your help,
Ian
Developer
Feb 20, 2013 at 10:12 AM
I don't know why there is only one Vertice but there is definitely an off-by-one error in the code. It should read:
return vertices[i < 0 ? s - 1 - ((-i - 1) % c) : i % s];
Developer
Feb 20, 2013 at 10:24 AM
Sorry. It should read:
return vertices[i < 0 ? s - 1 - ((-i - 1) % s) : i % s];
Don't know where that 'c' came from.

Ian: I just had a quick look at the repository and it was still in there. I just fixed it, assuming you'd like to map [-1 .. -Count] to [Count-1 .. 0]. I had a quick look at all the samples/tests which use the decomposer and it broke nothing so far. Still other parts of the code may be affected.
Feb 20, 2013 at 9:59 PM
Thank you for the fast response Elsch!

Well that fixes one problem, though I'm still not sure why there is only one vertex and its throwing a more readable error. Care to check out my sample project I posted?
Feb 22, 2013 at 12:51 AM
Andddd I crossed the streams. If you map out the vectors they cross over and it breaks, I fixed the vectors and it works know.
Coordinator
Feb 24, 2013 at 1:59 AM
Edited Feb 24, 2013 at 2:01 AM
Elsch:

The code is the original from Mark Bayazit, and I've seen that issue multiple times. There are little documentation, but the At function should return the vertex at point i, wrapped within [0 .. n-1) if I remember correctly. However, his own code uses 'i < 0 ? i % n + n : i % n'.