Selecting values in array

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

Selecting values in array

Post by Daniel Brassard » 10 Apr 2012, 18: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, 18:28

Re: Selecting values in array

Post by iamVFX » 10 Apr 2012, 19:45

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

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

Re: Selecting values in array

Post by Chris_TC » 10 Apr 2012, 22:47

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

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

Re: Selecting values in array

Post by Daniel Brassard » 10 Apr 2012, 23: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, 23:38
Location: St. Thomas, Ontario
Contact:

Re: Selecting values in array

Post by Daniel Brassard » 11 Apr 2012, 03: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!
Attachments
implicit_test_in_out.jpg
Implicit_in_out_on.jpg
implicit_inside_outside.jpg
$ifndef "Softimage"
set "Softimage" "true"
$endif

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

Re: Selecting values in array

Post by Chris_TC » 11 Apr 2012, 21: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, 11:27

Re: Selecting values in array

Post by kykeon » 01 Feb 2013, 11: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!
Attachments
DataArrayFilter.jpg

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

Re: Selecting values in array

Post by iamVFX » 03 Feb 2013, 21: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]

Post Reply

Who is online

Users browsing this forum: trendiction [Bot] and 31 guests