Jump to content
Sign in to follow this  
kashmere

VEX nearpoint

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!!!

Share this post


Link to post
Share on other sites

You could potentially run a for each loop per primitive and then iterate over each primitive using nearpoint function to get those nearpoints per prim. or use primpoints function and store them in an array.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×