generative modeling for Rhino
I have a small function component with an If/Then/Else statement in it to defend from a divide by zero call. Turns out that I'm getting a fault regardless. If this were using lazy evaluation I don't believe I should get a fault. Would it be possible to correct?
If(x≠0.0, (0.25/x), 1.0)
Attached is the (trivial) example file.
- Brian -
If() actually is a function, so the eval is not lazy.
While not making this lazy, you could still avoid the error with this trick:
0.25/If(x≠0, x, 0.25)
Fair enough, I'll go with that. Thx
Another option (less neat than Giulio's) would be:
If(x≠0.0, (0.25/Max(x, 1e-12)), 1.0)
where you can replace 1e-12 with whatever tolerance makes sense in the current case.