Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException: 0 in MPolygon #2

Closed
acdean opened this issue Aug 12, 2017 · 6 comments
Closed

ArrayIndexOutOfBoundsException: 0 in MPolygon #2

acdean opened this issue Aug 12, 2017 · 6 comments

Comments

@acdean
Copy link

acdean commented Aug 12, 2017

please see this thread on the processing forum
https://forum.processing.org/two/discussion/23772/paid-help-to-debug-patch

@acdean
Copy link
Author

acdean commented Aug 15, 2017

// small example of the error
import megamu.mesh.*;

float[][] p = {
{142.78653, 364.8811},
{142.80171, 361.90747},
{142.8004, 361.91183},
{141.72589, 363.63394},
};

Voronoi v = new Voronoi(p);

@acdean
Copy link
Author

acdean commented Aug 15, 2017

// if called with 0 then this creates a non-array
public MPolygon(int points){
coords = new float[points][2];
count = 0;
}

// which this then tries to access element 0 of, causing the error.
public void add(float x, float y){
coords[count][0] = x;
coords[count++][1] = y;
}

@acdean
Copy link
Author

acdean commented Aug 15, 2017

but i think that the problem is actually that the MPolygon is ever being called with 0

problem in Voronoi constructor?
//regions[i] = new MPolygon(pointBuckets[i].length); // wrong?
// should that be this?
regions[i] = new MPolygon(faceOrder.length);

@lquinn2015
Copy link
Contributor

I can confirm that this seems to fix the issue. I can try and create a pull request for this but is @leebyron still around to accept it. I ran into this when trying to regularize Voronoi graphs.

@leebyron
Copy link
Owner

leebyron commented Aug 3, 2019

PR it!

@lquinn2015
Copy link
Contributor

@leebyron I made a pull and it fixed that issue that I was having and the issue that acdean was defining however if you have some more test cases to but it through that's probably smart. I've only been using the library for a week so my testing code is pretty limited

leebyron added a commit that referenced this issue Aug 17, 2020
Fixing issue #2 in Voronoi.java line 143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants