Voronoi (Mesh Lib) ArrayIndexOutOfBoundsException

edited July 2016 in Library Questions

It's not the first time I'm having issues using Mesh Lib from Lee Byron. When there is a strange value of x or y, Voronoi throws ArrayIndexOutOfBoundsException.

I was able to detect when exception occurs that one particle had x value of 1.3E-44

What kind of float number is that? Is that a way to convert it back to float, or to check if it's greater/lesser than one value and constrain it before sending it to Voronoi?

Thanks!

Answers

  • Hey, if you were able to read it then I will think you could compare it. That number if very small (1E-44), caused by internal round errors and it is zero by definition (unless you are working with string theory in the domain of physics). I suggest before you send it to Voronoi (is it a lib?), you could set it to a value of zero.

    I hope this helps,

    kf

  • What kind of float number is that?

    a very small one! the E denotes engineering notation where the number after the value is the mantissa. that is 1.3 x 10 to the power of -44.

    https://en.wikipedia.org/wiki/Engineering_notation

    Is that a way to convert it back to float

    is IS still a float. how it's displayed changes when it's tiny like that, but the number is still a float.

    i'm not sure what your problem is though, the ArrayIndexOutOfBounds, without seeing more code.

  • Thank you, guys

    Yes, I think this is not the problem...

    Anyway, I'm filtering this values by multiplying by 1000, converting to int and dividing by 1000.0

    float[][] points = new float[particles.size()][2];
    
    int k = 0;
    
    for (Particle p : particles) {
        points[k][0] = int(p.PL.x * 1000) / 1000.0;
        points[k][1] = int(p.PL.y * 1000) / 1000.0;
        k++;
    }
    

    But the error still occurs... I checked all the points values, and I think the real problem is when a particle is exactly in the same X Y position than another.

  • edited July 2016

    Yes, that was it. Solved the problem by checking if particles has same position, and moving one of them by a pixel.

Sign In or Register to comment.