get curve intersection in world space

get curve intersection in world space

coeuscreative
Enthusiast Enthusiast
795 Views
2 Replies
Message 1 of 3

get curve intersection in world space

coeuscreative
Enthusiast
Enthusiast

Is there any way to get the intersection of two curves in world space?

 

I can only think of a really convoluted way of doing it as follows. (Which wouldn't really be quick enough for my use case, anyway)

  1. Use cmds.curveIntersect to find the point along the curve that they intersect
  2. Create a curve animation using one of the curves and dummy object
  3. Use the animation to move the dummy object to the intersection point.
  4. Query the position of the dummy object toget the world coordinates.

Surely there must be a better way than that!

Thanks in advance
 

 

0 Likes
796 Views
2 Replies
Replies (2)
Message 2 of 3

mcw0
Advisor
Advisor

I believe the curveIntersect function creates locators on each of your curves.  Just query the worldPosition of the locators.  I used this recently.

0 Likes
Message 3 of 3

olarn
Advocate
Advocate

Not any less convoluted but with the API:

  1. Get MFnNurbesCurve from Curve 1
    https://help.autodesk.com/view/MAYAUL/2020/ENU/?guid=Maya_SDK_MERGED_cpp_ref_class_m_fn_nurbs_curve_...
  2. Get MFnNurbesCurve from Curve 2, sample it to arbitrary precision using getPointAtParam (worldspace)
  3. At arbitrary tolerance, test all sampled points with B's closestPoint, see if any hits (worldspace)

Another way would be to use curveIntersect node directly to find location of intersection on each curve, if any.

https://help.autodesk.com/cloudhelp/2020/ENU/Maya-Tech-Docs/Nodes/curveIntersect.html

Then use getPointAtParam (worldspace) to find the actual point

0 Likes