biigle / largo

:m: BIIGLE module to review image annotations in a regular grid
GNU General Public License v3.0
0 stars 1 forks source link

Fix division by zero error #127

Closed mzur closed 8 months ago

mzur commented 8 months ago

There can be a DivisionByZeroError here:

https://github.com/biigle/largo/blob/c322781a429609ff27a5a2ea2d7baf57edfda685/src/Jobs/ProcessAnnotatedFile.php#L426

@lehecht Can you please look into this?

lehecht commented 8 months ago

I don't think this can happen, because of this check here. Array $u and $v both have the same length, because the (tilted) vector $v is projected on the x-axis which is $u. If $v is equal to $u (there is no rotation), skip the computation and return zero.

But I agree that there is still something to do, because I compute the length twice for both vector. I will change that.

mzur commented 8 months ago

I can just tell you that this error happened a couple of hundred times since I deployed the feature on Friday :smiley: I will look up an example rectangle with coordinates.

lehecht commented 8 months ago

Ah okay. Then I will fix it. Sorry, I couldn't reproduce it and thought you mean that there is maybe just the possibility that this error could occur.

mzur commented 8 months ago

Here are the coordinates of a rectangle that caused the error:

[844.69,1028.44,844.69,1028.44,844.69,1028.44,844.69,1028.44]
mzur commented 8 months ago

Sorry, I couldn't reproduce it and thought you mean that there is maybe just the possibility that this error could occur.

No worries. Of course you can't fix an error that you can't reproduce.

The the points of the recangle above are all the same. That's probably the issue. Please also add a test case for this.

mzur commented 8 months ago

Seems like someone is having a really hard time drawing correct rectangles. I've created https://github.com/biigle/core/issues/763 as a follow-up.