Jump to content

Intersection with primitive along vector


MAYA_

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!

Link to comment
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?

Link to comment
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
Link to comment
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 :) 

Link to comment
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 !!!

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