Hello all!
I ran into a problem trying to do division in Grasshopper. The problem seemed to be present both with the Functions component and the Division component. The idea was to have two values (a, b) and divide them both by three values (x, y, z) resulting in six numbers (a/x, b/x, a/y, b/y, a/z, b/z).
To achieve this, I tried branching them up. I was expecting the operation to look something like this:
:{0;0} a b
/
:{0;0;0} x
:{0;0;1} y
:{0;0;2} z
→
:{0;0;0} a/x b/x
:{0;0;1} a/y b/y
:{0;0;2} a/z b/z
This worked fine with only one set (meaning, one branch {0;n}
and the corresponding branches {0;n;i}
). However, when I tried adding more than one set, the results came out all wrong in multiple ways.
First, the branches did not match up as expected. This image is from a file where I tried replicating the issue:
Based on the idea above, I thought my items in branch {0;0}
would divide by each item in branches {0;0;0}-{0;0;2}
, and the items in branch {0;1}
would then divide by each item in {0;1;0}-{0;1;2}
. However, the results show that the component divided branch {0;0}
with {0;0;0}
, then for some reason chose {0;1}
to divide with {0;0;1}
, and the continued to use {0;1}
to divide with every subsequent branch.
Second, the results changed when more sets were added. Here is a series of images from a similar test:
Two sets:
Three sets:
Four sets:
Notice, for example, how the results on branches {0;0;2}
, {0;1;0}
, {0;1;1}
and {0;1;2}
changes every time a new set is added.
In another setting, I found that the more sets I added, the more sets at the end the sets became identical. Here is a picture of this:
Notice how the sets for Fx branch {0;20}
-{0;23}
have different Fx values, meaning they should yield different results, however branches {0;20;0}
-{0;20;2}
are identical to the branches of the other sets, repeating the same pattern. In this example I have 24 sets total, and the last 16 are identical.
Is this a bug, or am I just doing something wrong? Perhaps division in Grasshopper isn’t meant to work this way? Any and all help is welcome.
My sample files:
Larger sample division bug script.gh (25.8 KB)
Simple division bug script.gh (7.1 KB)