Page 1 of 1

Selecting values in array

Posted: 10 Apr 2012, 18:53
by Daniel Brassard
Maybe I have being on this too long that I cannot see the forest for the tree anyway

say you have this array {-6,0,1,3,-5,0,-2,7,0,-10,2}

You want to be able to find all the negative numbers in this array and return the index value. The answer in this case {0, 4, 6, 9}

I tried the "find in array" node but it can only take a value, nor "if" or "lower than" node as input.

I would like to avoid the repeat node if possible. Thanks for the help!

Re: Selecting values in array

Posted: 10 Apr 2012, 19:45
by iamVFX
Image

Re: Selecting values in array

Posted: 10 Apr 2012, 22:47
by Chris_TC
Hahaha, I love it. Such a simple yet awesome solution.

Re: Selecting values in array

Posted: 10 Apr 2012, 23:05
by Daniel Brassard
Thank you IamVFX,

Like Chris_TC said, simple but elegant. It never occured to me to feed the second port.

Cheers!

Dan

Re: Selecting values in array

Posted: 11 Apr 2012, 03:11
by Daniel Brassard
With this simple trick, I was able to do this:

Test if a point is inside, on the surface or outside. The first step toward the marching cube or marching tetra!

Re: Selecting values in array

Posted: 11 Apr 2012, 21:28
by Chris_TC
Daniel Brassard wrote:The first step toward the marching cube or marching tetra!
Now that sounds promising! Keep going

Re: Selecting values in array

Posted: 01 Feb 2013, 11:37
by kykeon
Nice one, so usefull... I was stuck on my problem untill I found this topic.

Here how I used your trick:

I was making some tracks on the ground on the path of a snake.

Let's say the ground is hit by the snake at each frame. Each points receive a boolean data "touch" when they are touched for the first time. At each frame I also create a scalar data called "DisplacementY", which is the current Y distance to the initial Y position. Afterwards I create a "get nearby points".

Here was my problem: get the average "DisplacementY" of the nearby points using the already touched points only.
I use the index array in "find in array" to remove this array from the other array...
Many thanks again!

Re: Selecting values in array

Posted: 03 Feb 2013, 21:29
by iamVFX
Now, with recent Reinhard's found, you can do it without Find in Array node

[rimg=1100]http://i.imgur.com/WpRrDy9.png[/rimg]