Selecting values in array

Discussions about SOFTIMAGEs© Interactive Creative Environment©
User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 22:38
Location: St. Thomas, Ontario

Selecting values in array

Post by Daniel Brassard » 10 Apr 2012, 16:53

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!
$ifndef "Softimage"
set "Softimage" "true"
$endif

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: Selecting values in array

Post by iamVFX » 10 Apr 2012, 17:45

Image
Last edited by iamVFX on 13 Oct 2012, 21:08, edited 1 time in total.

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 16:43

Re: Selecting values in array

Post by Chris_TC » 10 Apr 2012, 20:47

Hahaha, I love it. Such a simple yet awesome solution.

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 22:38
Location: St. Thomas, Ontario

Re: Selecting values in array

Post by Daniel Brassard » 10 Apr 2012, 21:05

Thank you IamVFX,

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

Cheers!

Dan
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 22:38
Location: St. Thomas, Ontario

Re: Selecting values in array

Post by Daniel Brassard » 11 Apr 2012, 01:11

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!
You do not have the required permissions to view the files attached to this post.
$ifndef "Softimage"
set "Softimage" "true"
$endif

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 16:43

Re: Selecting values in array

Post by Chris_TC » 11 Apr 2012, 19:28

Daniel Brassard wrote:The first step toward the marching cube or marching tetra!
Now that sounds promising! Keep going

kykeon
Posts: 4
Joined: 08 Oct 2012, 09:27

Re: Selecting values in array

Post by kykeon » 01 Feb 2013, 10:37

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!
You do not have the required permissions to view the files attached to this post.

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: Selecting values in array

Post by iamVFX » 03 Feb 2013, 20:29

Now, with recent Reinhard's found, you can do it without Find in Array node

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