Jump to content

VEX nearpoint


kashmere

Recommended Posts

Hello OD ones,

I am relatively new to vex and houdini but I am going with my guts on this. I want to get the nearpoint P2 on geo2(input1) for every point p1 on geo1(input0). I am doing this in a wrangle node, the wrangle node is in geo1 stream. I have a few restrictions

1) I am running the wrangle on primitives, so I am finding the nearpoint for all the points per primitive, the search is limited to a particular primitive on geo2 that shares a flag with the primitive on geo1.

2)since nearpoint doesn't allow me to make group in geo2(input1) [ or i could have just grouped the points on the specific primitve on geo2 on the run and use the actual 'nearpoint' function over that group]. So using nearpoint is out of question [or is it?]

3) So I wrote the code of how I think nearpoint would work [find distance from P1 to each point on the primitive on geo2, asign it to array and get the minimum value of array and find the ptnum of the point with the min distance value.]

4) but this is taking too long to run since I have hundreds of thousands of primitives to run on, I thought it will be fast but its not, using nearpoint is so much faster even when it runs on the whole geometry of geo2, but that will get me a point from a primitive that doesnt share the same flag which I set for each primitive on geo1. 

Any improvements to the algorithm or a function which i missed is much appreciated!!!

Link to comment
Share on other sites

  • 2 weeks later...

Hey Kashmere,

This may be way off-target, but maybe it'll still help!

I know you're going for a mainly vex focused approach, but if you're just trying to get a single point attribute of the nearest point between two pieces of geo, using an attribute transfer might be the way to go.

Set an attribute like "nearpointid" to the ptnum, and then attribtransfer that over. 

 

 

Edit: On second thought shouldn't a simple implementation of nearpoint in vex do what you're looking for? Maybe I'm completely mistaken.

i@nearestpoint = nearpoint(1,"",@P,ch("radius"));

 

Edited by coltonmil
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...