Wooshum Posted May 9, 2016 Share Posted May 9, 2016 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: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect http://math.stackexchange.com/questions/406864/intersection-of-two-lines-in-vector-form This should be a trivial solution but I have been way off the mark with my attempts. Any help is much appreciated! vector_intersection.hip Quote Link to comment Share on other sites More sharing options...
acey195 Posted May 9, 2016 Share Posted May 9, 2016 I used those resources to create something similar as well, so it is possible. While I can't give you my code, I saw some stuff in this topic which is basically that: Quote Link to comment Share on other sites More sharing options...
Popular Post Wooshum Posted May 9, 2016 Author Popular Post Share Posted May 9, 2016 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); 10 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.