Jump to content


Is there a way to find the closest found point in a point cloud?


  • Please log in to reply
29 replies to this topic

#1 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,287 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 15 August 2012 - 02:04 PM

Hi,

I know that there is pcfarthest function. But is there a way to find the closest? Something like pcclosest?


Thanks :)

#2 SpencerL

SpencerL

    Illusionist

  • Members
  • PipPipPip
  • 468 posts
  • Joined: 26-July 04
  • Location:Sony Imageworks - Los Angeles
  • Name:Spencer Lueders

Posted 15 August 2012 - 02:58 PM

View Postmagneto, on 15 August 2012 - 02:04 PM, said:

Hi,

I know that there is pcfarthest function. But is there a way to find the closest? Something like pcclosest?


Thanks :)

If you are using H12, you can use the Point Cloud By Index VOP.  The other way would be inside a while loop and when pciterate is equal to 0, thats your closest point.

#3 graham

graham

    Houdini Master

  • Moderator
  • 666 posts
  • Joined: 13-September 06
  • Location:Santa Monica, CA
  • Name:Graham Thompson

Posted 15 August 2012 - 03:05 PM

Can't you just only search for a single point when you open it?
I write python and break things.

#4 Solitude

Solitude

    Initiate

  • Members
  • PipPip
  • 189 posts
  • Joined: 12-April 06
  • Name:Ian Farnsworth

Posted 15 August 2012 - 03:11 PM

View Postgraham, on 15 August 2012 - 03:05 PM, said:

Can't you just only search for a single point when you open it?

Yeah I'm pretty sure when you set max points to 1 it returns the closest point.

--Ian

#5 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,287 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 15 August 2012 - 03:28 PM

Thanks alot guys.

@Spencer:

So the first indexed point will always be the closest? I thought the order was random?

@Graham, and Solitude:

I could do that, but right now I am getting all the points within the radius, and need to find the closest and the furthest points.

If I use the pcopen function twice (one for all points and one for the closest), , would it not incur the pcopen overhead twice? It would be cool if I could get all this info from my single pcopen function, just like pcfarthest allows :)

#6 anim

anim

    Houdini Master

  • Members
  • PipPipPipPip
  • 910 posts
  • Joined: 23-August 07
  • Location:Slovakia, Bratislava
  • Name:Tomas Slancik

Posted 15 August 2012 - 05:29 PM

View Postmagneto, on 15 August 2012 - 03:28 PM, said:

...
So the first indexed point will always be the closest?
...

I wouldn't bet on that, I rather never consider them ordered, but I would like to hear from some developer if that really the case

View Postmagneto, on 15 August 2012 - 03:28 PM, said:

...
I could do that, but right now I am getting all the points within the radius, and need to find the closest and the furthest points.
...
if you query more than one point you usually loop through them in For or While loop, therefore it is easy to store maximum and minimum distance within the same loop (remember you can import point.distance directly, then just compare to previous minimum/maximum and store if it's smaller/larger)
Tomas Slancik
Generalist
Slovakia

#7 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,287 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 15 August 2012 - 06:14 PM

Thanks anim. I will have to do something like you mentioned. Reason I didn't do it is because I want to use the closest and farthest points right off the bat for each found point.

So I will either loop the pc result twice, or find the closest and store the points as I loop, and then loop this collection and use my closest and farthest points.

Not saying it's involved, just wanted to make sure I am not doing something unnecessary since I am still new to point clouds :)

#8 ikarus

ikarus

    Illusionist

  • Members
  • PipPipPip
  • 295 posts
  • Joined: 19-February 10
  • Location:Los Angeles
  • Name:Raymond P

Posted 15 August 2012 - 07:59 PM

Pretty sure pc samples points based on distance from the reference position.  

Try sampling a cloud where you have more samples than the max points, itll return the closest points to the lookup position.

#9 bhaveshpandey

bhaveshpandey

    Illusionist

  • Members
  • PipPipPip
  • 273 posts
  • Joined: 12-October 08
  • Location:London
  • Name:bhavesh pandey

Posted 16 August 2012 - 03:17 AM

if your looking up the nearest neighbour within the input point cloud then using 1 as max num of points will always return the original point.
so you need to query 2 max points.

if you need to check nearest point in another point cloud or collection of points then setting it to 1 will work.

#10 anim

anim

    Houdini Master

  • Members
  • PipPipPipPip
  • 910 posts
  • Joined: 23-August 07
  • Location:Slovakia, Bratislava
  • Name:Tomas Slancik

Posted 16 August 2012 - 07:09 AM

View Postikarus, on 15 August 2012 - 07:59 PM, said:

Pretty sure pc samples points based on distance from the reference position.  

Try sampling a cloud where you have more samples than the max points, itll return the closest points to the lookup position.

I think you are right, I tested this on simple pointcloud and it seems that they are ordered from closest to furthest (but I am pretty sure somebody was saying to be careful about this assumption)
in that case you can use pcimportbyidx() to get any point by index within found points, first will be closest(or itself as Bhavesh mentioned) last furthest (idx = pcnumfound()-1 )
Tomas Slancik
Generalist
Slovakia

#11 hopbin9

hopbin9

    Houdini Master

  • Members
  • PipPipPipPip
  • 803 posts
  • Joined: 14-March 10
  • Location:Canada
  • Name:Hop Bin

Posted 16 August 2012 - 07:31 AM

View Postmagneto, on 15 August 2012 - 02:04 PM, said:

I know that there is pcfarthest function. But is there a way to find the closest? Something like pcclosest?

You need one of these.

Posted Image

THERE IT IS!
Posted Image
Come download the free open source asset library for Houdini.
Help us reach 1,000 fans on facebook!

#12 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,287 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 16 August 2012 - 02:35 PM

Thanks guys.

@bhavesh: How do you check the nearest point in another point cloud? You use pcopen ( handleToAnotherPCloud )?

@anim: Is there a function called pcimportbyidx? I couldn't find anything other than pcimport. There is a VOP to index, but didn't see a function to index into a point cloud.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users