Jump to content
Sign in to follow this  
SquirkyTurtle

Intersection with primitive along vector

Recommended Posts

I have two points and I am trying to figure out if there is a primitive "between" them (just if a straight line from A to B will intersect with it) but I am slightly stuck. I attempted this by calculating the distance between them and the distance along vector AB to the intersection and comparing the two values. But I can't seem to calculate the second. I have been using xyzdist() but I am not sure about how to approach the "along the vector" side of this as (as far as I understood it), xyzdist() just gives me the closest intersection without regarding a direction vector? Is there any function I could use for this?

I would appreciate any help :)

Thank you!

Share this post


Link to post
Share on other sites

you should be able to repro this easily..I just whacked the nodes in no mods necessary....(except for the non-straight line)

intersect1.jpg

Share this post


Link to post
Share on other sites
7 hours ago, Noobini said:

you should be able to repro this easily..I just whacked the nodes in no mods necessary....(except for the non-straight line)

intersect1.jpg

Hello :) Thank you very much! That is cool but I need to figure out how to do this in VEX as well as I need it further down the line in my code. Would you know how to approach this?

Share this post


Link to post
Share on other sites
2 hours ago, Maurits said:

Hey

I think the intersect_all function in Vex is what you are looking for.

http://www.sidefx.com/docs/houdini/vex/functions/intersect_all.html

 

 

 

Yeah, I used intersect() and it works fine but, I assumed that &p:

 int  intersect(<geometry>geometry, vector orig, vector dir, vector &p, float &u, float &v)

would write out the point of intersection between the ray and geometry. For me, it just copies @P (orig vector) giving me the points position as the intersection point which clearly doesn't make sense. Did I understand it wrong?

edit: I changed the orig vector to something else and &p gives me the orig vector every time? The dir vector is (goal - orig)

Edited by SquirkyTurtle

Share this post


Link to post
Share on other sites
21 minutes ago, SquirkyTurtle said:

Yeah, I used intersect() and it works fine but, I assumed that &p:

 int  intersect(<geometry>geometry, vector orig, vector dir, vector &p, float &u, float &v)

would write out the point of intersection between the ray and geometry. For me, it just copies @P (orig vector) giving me the points position as the intersection point which clearly doesn't make sense. Did I understand it wrong?

edit: I changed the orig vector to something else and &p gives me the orig vector every time? The dir vector is (goal - orig)

Okay, I figured it out. It was because for some calculations the point was past the point of the dir vector, so it just returned 0 because I assume it wasn't 'long' enough. I multiplied it by 10 and it works fine now :) 

Share this post


Link to post
Share on other sites
5 hours ago, SquirkyTurtle said:

Hello :) Thank you very much! That is cool but I need to figure out how to do this in VEX as well as I need it further down the line in my code. Would you know how to approach this?

yeah sorry it wasn't a direct answer coz I'm not a VEX expert myself...but I was hoping that would provide you with a spark with the thought process, it did !!!

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  

×