How to find minimum in a bunch of vectors?

 

Hi there.

Maybe it's because of the temperatures outside, but I think I'm having a brainfreeze... :-)

So I have a bunch of XYZ Vectors, all inside one huge Vector set like:

-19.000000,19.000000,158.000000,
-148.000000,17.000000,59.000000,
-271.000000,17.000000,-153.000000,
-319.000000,17.000000,-333.000000,
-373.000000,17.000000,-481.000000,
-611.000000,38.000000,-918.000000,
-423.000000,38.000000,-853.000000

Now I want to split those into triples and iterate *only* through the Y Values to find the smallest one.
(obviously 17 in this case... :-))

A setup like this will only give me the *first* value, though:

As said before....probably a brain freeze since I'm dmn sure this can be done without a dedicated Lua script... :-)

Thanks for any hints.

Eric.


   EricWest

 
Profile Image
Ahmed@Aximmetry
  -  

Hello Eric,

To do that, we need to use the so-called Array Compound. We are in the process of creating comprehensive documentation about it, but for now, I will give you the essentials to get you going.

This type of compound is basically a loop that runs X times inside of your flow. Whatever is inside of it will run X times. 

To create an Array Compound, Right Click and pick New Simple Compound.

Right Click on the new Compound and press Setup Array:


Choose the number of times you want to execute the loop (if you have N vectors, your array should be of size N as well):

 

The solution I’m giving here is a generalized version for other users to refer to in the future as well.

This is the final look at the flow at the zero level of the compound hierarchy:


The above Vector Concat Multi is used to make a data set like in your comment.

Inside the array Compound it looks like this:

The Array Index outputs the current iteration number. Note that inside the array, it will always display the array with the 1st index. So, you won't be able to see the loop actually moving.
This Array Index value is then multiplied by 3 and 1 is subtracted from it. This is done in order to get the Y values of the vector set by using the Vector Item module. Then all these Y values are put together into one vector by the Array Vector Concat module.

Finally, outside the compound, the Vector Minimum module will give us the lowest of these Y values.

Best regards,