algorithmic modeling for Rhino
Tags:
Hi Brian,
you could be suffering from rounding errors. Floating point numbers in Grasshopper have ~16 decimal places, but I only typically show 6 in the UI.
If you want to replace 2*pi with zero, using an expression would be better. Create an expression component with a single variable (x) and an expression:
If(Abs(x - 2*pi) < 0.01, 0.0, x)
This works as follows. The If() function requires 3 arguments, i.e. it looks like If(X, A, B). The X part must resolve to a Boolean value (True/False). If X = True, then the function returns A, otherwise the function returns B.
So in this case, we measure the absolute difference between x and 2*pi, then compare that difference to a small (but non-zero) threshold value. You should never compare floating point numbers with zero tolerance because there is almost always some noise in the least significant digits after a few mathematical operations.
If you want to tighten up the comparison, use a number smaller than 0.01. If you want a really tight (but still non-zero) comparison, you can use the roughly-equals operator:
If(x ≈ 2*pi, 0.0, x)
which compares only the ten most significant digits.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Actually something quite different, still about member index though.
Why is it not possible to have automatic path to string on member index?
And why is my Data still a Path here, even thoug I did a conversion via param before?
Thanks,
Phillip
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by