Connect 2 circles with tangent lines + remove inner parts

Hello All,

First question here about Grasshopper, consider myself as absolute beginner. As a challenge I am trying to use Grasshopper for a parametric design.

I want to two circles , connect them with tangent lines, and remove the inner parts of. circles left, so I get a shape like


PS: I asked Google Gemini, but that was more confusing then helpfull, but you never know, could have worked.

Regards, Eef

2 Likes

3. Attach minimal versions of all the relevant files

5 Likes

Dear @Eef_Weenink

welcome to the forum.
you can drag and drop .gh files to post/edit window.

here is my approach:

circle-circle_convexhull_00.gh (9.2 KB)

there is a gh-plugin called sunglasses, it will add the additional info / text above the components.

hope this helps.

kind regards - tom

2 Likes

I added only two components to what @Eef_Weenink had in his image but before @Tom_P or I could respond constructively, we BOTH had to independently reconstruct that code :bangbang:

Not cool at all to be so inconsiderate. How many others went through the same process as they considered a reply? Now multiply that by ten threads per day
 It quickly adds up. :man_facepalming:


one.gh (8.6 KB)

another ‘fun’ way:
two.gh (16.3 KB)

4 Likes

Thanks for your answers. Learned from @Tom_P and @Joseph_Oster that I could have better uploaded the *.gh file instead of image. Sorry for the inconvenience.

  1. I have to study more the commands: Merge, Region Union and Ruled Surface, to understand what they do (“under the hood”).
  2. I will check “sunglasses”, am using “bifocals” now. Guess simular function?
  3. @RenĂ©_Corella, I understand the Loft has same function as “ruled surface”. I will need much more time to understand the number “two” “fun” version.
    Just rhetorical questions for me to work on. (no answer needed for now).

As I understand all your approaches, the (simplified) process is to:

  • first transform the circles + lines into a surface (and there are several ways for that).
  • then only keep the outer (poly)line
    Correct?

I can work with this. But
 (there is a last question):

  • Could I have avoided this process, by starting with two arcs + tangent lines; and make directly a polyline from that? I have no idea how I could find the connecting points

Regards, Eef

2 Likes

Dear Eef

The Tangent Lines (Ex-ternal) has the geometry-math inside to find those 4 points.(start / endpoint of the lines).
Of course you can re-implement the math. mathworld.wolfram or wikipedia might offer starting points - but of course this effort is not necessary. And you still struggle the issue, how to find the right portion / side of the arc.

Region Union is similar to rhinos curveBoolean command and is curved based. Not surface based. The output surface from ruled srf is “casted” to a curve - by just duplicating its boarder. This implicit (“invisible”) casting from one type to another is done in grasshopper all the time - this might decrease complexity / number of components, but in my opinion might not increase readability.

merge will allow you to define the precise order of data - instead of plugging multiple wires to one parameter.

happy spaghetti
 - cheers tom

4 Likes

Today I have been working on this last question: “Could I have solved this, by starting with two arcs + tangent lines; and make directly a polyline from that?”

And yes, I think I succeeded quite well, but can probably be better.
This is what I made:
Screenshot 2024-10-17 at 23.13.12
ARCS.gh (14.2 KB)

  1. I discoverd that external tangent lines along two arches are placed exactly as if it where circles. So they are placed when there is an arc with length=0 (so the arcs are not visible. but the tangent lines are where they should be.
  2. I used the connecting points to create two new arcs with 3 points.
    I used two of the tangent connecting points + the curve middle of the arc. (for this the arc must have a length > 0. (or it will give an error).
  3. And merged all to a polyine .

rest a couple of minor questions:

  • is there a way to create the new arcs, other then the 3 points arc (so the length of the first arcs can be “0”. then these would be only virtual “placeholders”.
  • I was not able to move the starting planes of the first arcs around, so if the arcs are on other orientations there might be errors
  • I could not find a way to force the arc to always go to the “outer” line. Now when the arcs switch in from smaller to greater then the other, the new arc flips the wrong way.

Would be nice to get some suggestions on those issues. Regards, Eef

Uh, no. Why arcs when TanEx expects circles? I can’t see the arc with zero angle.

WHY :question: Start with two circles and avoid using TanEx and I’ll be impressed.
But again, why bother?

Arcs with zero angle are invisible. (And give an error, I should have set the second arc (left bottom) to angle>0 too)
That is why I create new arcs.
If only I was able to let the first arcs stop exactly at the connections points of the tangent lines, that would be best (functions like a constraint).

Please explain your reaction “Why border?”.
I do border, because I need this polyline to create a parametric thing to be 3D-printed. And as long I, being a newbie, here, do not know better solutions, I do border (or ?)

I said “why bother?”, not “why border?”.

It can be done without RuleSrf and RUnion if you must - and you should!

Here is a hint. It’s complicated. Is it clear now why the shortcut of RUnion was used?

1 Like

I sure would like too (just for the learning. Probably have to go into the mathematics then, no idea). Untill then I will use you solution (what works very well)

PS: English is not my native language, so bother, border (sounds almost the same, and would be hard for me to explain the difference).

Regards Eef

1 Like

just for pure academic / intellectual fascination
at the border of being bothered but staying on board (?? - not a native speaker, too)

2d at origin

ok let s reduce the problem:

  • 2d / World XY-Plane
  • center of first Circle at 0,0
  • center of 2nd Circal at x0,0
    to get a general solution without this limitations, transform the problem from a plane defined by the first circle with a x-Axis-rotation defined by the second center


math

here are the equations for the external tangent points

    x1=(((r2*r1)+(r2*r2*(-1.0))+x_0*x_0)*(1.0)/(x_0));
    y1=(Sqrt((x_0*x_0+(Pow(((r1*(-1.0))+r2),2.0)*(-1.0))))*(1.0)/(x_0)*r2);
    x2=((r1+(r2*(-1.0)))*(1.0)/(x_0)*r1);
    y2=(Sqrt((x_0*x_0+(Pow(((r1*(-1.0))+r2),2.0)*(-1.0))))*(1.0)/(x_0)*r1);

:nerd_face:

in gh


circle-circle_convexhull_B_00_math.gh (15.4 KB)

6 Likes

Math is not required.

P.S. I hope you understand the value of posting code?

TanEx_2024Oct17a.gh (15.5 KB)
TanEx_2024Oct16a.gh (7.8 KB)

:rofl:

that s all impression I get ?

Your math skills are impressive. But my code yesterday was SO MUCH SIMPLER :bangbang:
(TanEx_2024Oct16a.gh)

just passing by, just learned the other day about CreateBooleanRegions so I thought i might test it out here.

import Rhino.Geometry as rg

crv = rg.Curve.CreateBooleanRegions(curves, plane, _bool, tolerance)

region = []
for i in range(crv.RegionCount):
    for seg in crv.RegionCurves(i):
        region.append(seg.DuplicateCurve())

edit:
2circles_tangent.gh (10.5 KB)

1 Like

I see two circles in the code that have the same radius? Which is not what I see on the inset image (green curve)? Then both circles and the two tangent lines are merged before entering the Python “black box”
 Set type hints on the inputs and ‘List Access’ on the ‘Curves’ input


Would have been nice if you had posted code. :wink:
I guess this is doing a form of Region Union without the Ruled Surface, eh?
Would be nice if it derived ‘plane’ from the circles.

‘_bool’ toggle looks useless!

Cumbersome but interesting, thanks.

but still both unnecessary I guess (any surface) when you consider connecting curves:

Meh - it could have been a bit less ‘fun’ by (again) connecting curves instead of whatever I did before:

I like your invalid arc approach :wink:

Indeed, that looks familiar. Maybe naming the variable Combine would have made its utility more apparent.