Jump to content

Vector Intersection in VEX


Recommended Posts

I have been losing my mind a little on this one:

I am wanting to find the intersection point of two vectors in VEX (i.e. a version of the simplified Curvesect SOP). The goal is to implement this through and Attrib Wrangle node. At this stage I have tried implementing the solutions to the problem presented on the following forums but they are suited to 2D:



This should be a trivial solution but I have been way off the mark with my attempts.

Any help is much appreciated!


Link to comment
Share on other sites

Thanks for the tip @acey195 and @petz thanks for the solution. Here is the quick VEX snippet that I tested, works a treat!

// Get Lines
vector A = point(0, "P", 0);
vector B = point(0, "P", 1);
vector C = point(1, "P", 0);
vector D = point(1, "P", 1);

// Calculate Line Vectors
vector AB = B-A;
vector CD = D-C;

// Calculate To Vector
vector toVec = A - C;

// Calculate Intersection
vector vecx = cross(AB, CD);
float val1 = dot(vecx, cross(CD, toVec));
float val2 = dot(vecx, vecx);
vector pos = A + (val1 / val2) * AB;

addpoint(0, pos);


  • Like 9
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.

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