galagast Posted June 10, 2017 Share Posted June 10, 2017 I'm ran into an issue where: I have a default resampled Line. Calculated Normals using PolyFrame set to First Edge. @N: { 0,-1, 0 } Reversed the Normals using Facet.@N: {-0, 1,-0 } Scattered points, inheriting Normals. @N: { 0, 1, 0 } Finally used a wrangle to check if Normals == {0,1,0} The results were a bit random. Sometime it is true, sometimes it is false. I did find a couple of solutions to work around this for what I was doing, but I believe something in this simple sequence of nodes is not doing its job properly. I just wanted to hear your thoughts about this before (or even if I needed to) send this as a bug. Thanks! negative_zero.hiplc - H16.0.600 Indie Quote Link to comment Share on other sites More sharing options...
Skybar Posted June 10, 2017 Share Posted June 10, 2017 If you test like this it seems its the -1 it fails on: int test1 = @N.x == 0; int test2 = @N.y == -1; int test3 = @N.z == 0; if(test2) i@check = 1; Might be a rounding issue somewhere, because if you then change it to int test2 = @N.y >= -1; it works fine. Also if you normalize N in your example it works. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 12, 2017 Share Posted June 12, 2017 (edited) It's not a negative zero, it's a very small value (-0.0000000596046) shown as a negative zero by Spreadsheet. To understand problem, compute: @N = {0, -1, 0} - @N; Borrow any good one "almost equal" function example from the web. Here is one of simpler versions: // Simplified port of CPython's math.isclose() function. int isclose(float a, b, rtol, atol) { if (a == b) { return true; } float d = abs(b - a); return ((d<=abs(rtol*b))|| (d<=abs(rtol*a))) || (d <= atol); } It will make your comparisons more robust: almost_equal_example.hipnc Edited June 12, 2017 by f1480187 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.