It is currently 19 Jun 2013, 10:51

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Selecting values in array
PostPosted: 10 Apr 2012, 18:53 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 460
Location: St. Thomas, Ontario
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


Top
 Profile  
 
 Post subject: Re: Selecting values in array
PostPosted: 10 Apr 2012, 19:45 
Offline

Joined: 24 Sep 2010, 18:28
Posts: 595
Image

_________________
Constantine
Learnable Programming


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

Top
 Profile  
 
 Post subject: Re: Selecting values in array
PostPosted: 10 Apr 2012, 22:47 
Offline

Joined: 22 Mar 2010, 18:43
Posts: 391
Hahaha, I love it. Such a simple yet awesome solution.


Top
 Profile  
 
 Post subject: Re: Selecting values in array
PostPosted: 10 Apr 2012, 23:05 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 460
Location: St. Thomas, Ontario
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


Top
 Profile  
 
 Post subject: Re: Selecting values in array
PostPosted: 11 Apr 2012, 03:11 
Offline
User avatar

Joined: 19 Mar 2010, 00:38
Posts: 460
Location: St. Thomas, Ontario
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_test_in_out.jpg [ 82.04 KiB | Viewed 843 times ]
Implicit_in_out_on.jpg
Implicit_in_out_on.jpg [ 66.55 KiB | Viewed 843 times ]
implicit_inside_outside.jpg
implicit_inside_outside.jpg [ 63.02 KiB | Viewed 843 times ]

_________________
$ifndef "Softimage"
set "Softimage" "true"
$endif
Top
 Profile  
 
 Post subject: Re: Selecting values in array
PostPosted: 11 Apr 2012, 21:28 
Offline

Joined: 22 Mar 2010, 18:43
Posts: 391
Daniel Brassard wrote:
The first step toward the marching cube or marching tetra!

Now that sounds promising! Keep going


Top
 Profile  
 
 Post subject: Re: Selecting values in array
PostPosted: 01 Feb 2013, 12:37 
Offline

Joined: 08 Oct 2012, 11:27
Posts: 3
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
DataArrayFilter.jpg [ 179.42 KiB | Viewed 492 times ]
Top
 Profile  
 
 Post subject: Re: Selecting values in array
PostPosted: 03 Feb 2013, 22:29 
Offline

Joined: 24 Sep 2010, 18:28
Posts: 595
Now, with recent Reinhard's found, you can do it without Find in Array node


_________________
Constantine
Learnable Programming


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group