Jump to content

How To Find Closest Point Along Normal/ray


andrewlowell

Recommended Posts

So you don't want the closest point, but the distance in a certain direction?

What happens if the ray misses the line?

Well, I want it to do both ... I want it to find the closest point on the line, which lines up to that vector. It would be ideal if I could just use that circle and slice the line, then get the point that it sliced at.

Link to comment
Share on other sites

If you just want the closest point can't you just ray by minimum distance?

Sorry I'm not making myself clear. Yeah I could use the ray but I don't want the closest point, I want the closest point ... but which aligns itself along the blue line (normal) as well. So, if that blue line could chop like an axe into the line, the point where it hit would be what I would need. Or, put another way ... the point where that line intersects the circle in the diagram.

Link to comment
Share on other sites

Hi Andrew,

Point clouds could be a good start. If your point cloud contains that curve from the picture and you open a point cloud at the point No 0 (I mean that point on your picture) you can find a nearest point (same as using of Ray SOP) but there is another way... Go through all the points on your curve and calculate the distance from current point to point No 0. In this case you even no need to use point clouds. Just select the minimum distance. That minimum distance should be (?) the distance to point in circle (what if there is no point in slice? i.e. circle doesn't contains a point... or you need not actual points on the curve but rather position sampled from the curve?).

Arhhh... This idea could work for your picture but for other topology it could be wrong <_<

So you have to sample the points inside that circle (or tube if you need some treshold). It doesn't matter In which way you will do it. You could create a tube and group all points inside it or group them using some maths. Then all what you need is just calculate the minimum distance. This will work.

Edited by hoknamahn
Link to comment
Share on other sites

How about reversing the problem..

For each point in your line make a normal that points at the next point along, then ray each point onto the circle, limiting the ray distance to the distance between the points. If you get a hit then that is the point you need...

Is it optimal way? In this case you should check all points.

Link to comment
Share on other sites

Is it optimal way? In this case you should check all points.

I haven't looked at any of these answers, but I've done something similar in the past where I copied a line onto the point (aligned to the test direction) so I had two lines cross each other (just missing). Now you can use nearpoint() or one of those [combinations of] expressions to find the point where they are closest. Sorry I cant remember the exact expression... but there is something there. Basically it helps to put the ray in a piece of geometry instead of trying to keep it pure and mathematical.

Link to comment
Share on other sites

Sorry just checking this now guys. All great suggestions. I'm having a hard time articulating this issue. I think my use of the work "nearest point" threw everyone off.

I don't actually want to find the nearest "houdini point / vertex etc" on the line. I want to find the nearest "location" on the line ... which is also aligned to the direction of the normal or circle etc. Most likely a primitive etc.

So, wherever that circle (which is aligned to ray / normal / etc) intersects with the line, I want to make a new "Houdini point" at that location.

I'm familiar with the near point and ray stuff but what I can't seem to find a good setup or combination for this particular issue. Thanks again for help!

Jason that seems to make sense though, are there a lot of points on this geometry ray, and just sampling along the ray, or is there a way that it finds an exact intersection or location?

Edited by andrewlowell
Link to comment
Share on other sites

Is it optimal way? In this case you should check all points.

Well it depends how many points you have of course...

But perhaps it could be improved by build a bounding box (or similar) from the circle and then only testing points inside the bounds by using a group by object test first.

Link to comment
Share on other sites

Yeah, well maybe if I contextualize this a bit, someone will have a simple idea I'm not considering. I haven't tried this thing today but I'm guessing a multi-line-intersection is the way to go.

Anyway, this was supposed to be the "easy" part of this little setup, but basically I'm trying to get this cart to follow the train tracks. Easy job with the follow path object parameter, but the wheels didn't curve with the different tracks. So, naturally I constrained them to the offset tracks instead of the middle track, but then they are different lengths and don't work well with the percentage option (see offset in image).

So, now I'm trying to build some sort of line detection system that will get the right spot on the tracks relative to a vector or normal coming out of the cart so I can stick the wheels on that.

Am I missing something obvious here (most likely)?

post-3343-1201427771_thumb.jpg

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