How to find external tangents between two closed planar curves (not circles)?

Hi, you can see in the top view two closed planar curves. The two curves are positioned in a diagonal axis. I am trying to find the two external tangents that are connecting the two curves. The problem is that I just can find tangent components that are relating to circles.

I know that the two curves looking similar to a circle geometry, but because of special conditions, I can not make them perfect circular. They are more like an ellipse.

Thanks a lot for your help! Please find my GH file attatched.

191017Forum.gh (9.7 KB)

Hi, you have already used the correct method for tangents so I’m assuming what you really wanted was the closest point to the other curve (right?)

also: the evaluate curve which you used works on all curves, not just circles.

moreover: by pressing ctrl+shift+Q you can take a screenshot of the canvas from within GH

prox.gh (8.7 KB)

Hi, thanks a lot for your response, but I think I was not clear enough. Hopefully my sketch can show you what tangents I am looking for:

Oh, this is a bit more complex. I don’t think I can help you with that.
The only -easy- solution that I could think of is approximating your curves into circles and then finding the tangents. I don’t know if that serves you with rest of your project.

prox.gh (11.0 KB)

First of all, thank you! Unfortunatly I cannot simplify the curves. I need a more precise result, relating to my original curves.

Maybe there is a native GH compnent but if no, here is simple code that does it:
CurveCurveTangent.gh (6.4 KB)

(RhinoCommon)

2 Likes

Thanks for your work. Because I am not that familiar with coding, I hope that you can explain the process behind the code. Maybe this can help me to understand the process and trying to translate it into native components. More over can you explain you Prm1 and 2 Value?

Here is the link to the method that does the job:
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Line_TryCreateBetweenCurves.htm

Most of GH components are wraps around corresponding method in RhinoCommon.
Usually methods need input values which will be processed by the code inside the method.
Particularry this method needs two curves, curve parameter on each curve (seed value) where to start calculation of finding tangent line,…
Here is updated GH definition where we:

  1. find 2 closest points between two curves,
  2. find curve parameters for thees points,
  3. increase and decrease these parameters by 1/4 (to give it more expecting value) for finding tangent line
  4. feed this data into C# script for processing - to find tangent lines
    CurveCurveTangent_2.gh (16.9 KB)
3 Likes

Quick approximate solution, divide your curves into many, many points (like, thousands), put all those points into a single list and use Convex Hull on it. The hull should contain lots of very short segments but two long ones. That’s your tangent lines.

2 Likes

This is the same method of @RadovanG using Python ,with care to avoid intersections when curves are not flipped right

tangent curves.gh (11.7 KB)

If you are after absolute performance (of course you are) I would suggest to exploit PlanB: get “start” circles, do the classic tangents + end prox pts etc etc … and thus limit the forward/backward recursion considerably (for big N of curves has a certain impact on elapsed times):

I made this component with Python ( my first component :smile: )
Right now after some tests it work fine

Tangent Lines.ghpy (37 KB)

3 Likes

congrats! nice work!
although, I just noticed: at 0:14 it should have produced a second tangent and it didn’t. Back to work you lazy scallywag!!! :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

There’d be two tangents at 0:14, you want both, the shortest one, the longest one, the inner most one, the outermost one, the one which doesn’t intersect the rest of the curve, … lot of decisions to be made here.

Yes i know it didn’t work with curves like that even we use regular components or c#
the method of David with convex hull work in this case

Isn’t there a single tangent that doesn’t intersect anywhere along its length? (the tangent at the second hump would intersect the shape two times)
edit: we are talking about the bottom side

You know I’m just teasing you right? (It’s easy to criticize when you don’t even code at all!)

I try now with using convex hull and python together; i think this will be a solution

Well … other than that and if we rely to that Method (instead of a Recursive (+/-) search):

Then the results (red, the blue are the circles “t1,t2 hint” tangents) are rather unpredictable:


1 Like

works pretty well for multiple curves