Hey there,

this a problem with the Compute model that I have several times run into:

Why does the following dxscript not work :
-----------------------------------B
data    = Construct([-5 -5 -5 ],[1 1 1],[10 10 10],0);
pos     = Mark(data,"positions");
mag     = Compute("mag($0)",pos);
inv     = Compute("$0 > 0 ? 1.0/$0 : 0.0",mag);
-------------------

As you can see, I want to inverse a data field containing a zero value.
To prevent a devision by zero error, I use a ternary operator that checks
if the data is greater than zero before inverting, and else sets zero.

This construct apparently is not allowed, because I still get a
division by zero error message.

Until so far I have solved the problem by adding a very small number to the
data field, like:
inv     = Compute("$0 > 0 ? 1.0/($0+.000001) : 0.0",mag);

but this is not very clean, because it also affects the other data.

Does anybody has a better solution?

Thanks in advance!

Regards

Eelco

Reply via email to