How to create tangent arc witch specified radius to two cricle

How to create tangent arc witch specified radius to two cricle?

As showed on photo below

Thank in advance for help :slight_smile:

Pretty sure you could offset each circle by the radius, intersect the offset circles with each other, draw lines from the intersection point ti each original circle point, and then build the arc between the intersection of the lines with the respective original circles and the offset circle center point as the other end.

Of course it works, but how to draw it using nodes in dynamo?

I don’t know how to find point of corss of two offseted circles

curve.offset

geometry.intersect

Arc.ByCenterPointRadiusAngle

etc….

1 Like

Have a go at building this :wink:

import clr
clr.AddReference('ProtoGeometry')
fromAutodesk.DesignScript.Geometryimport *
import math

center1 = IN[0]
radius1 = IN[1]
center2 = IN[2]
radius2 = IN[3]
radius3 = IN[4]

# Get 2D coordinates
x1, y1 = center1.X, center1.Y
x2, y2 = center2.X, center2.Y
z = center1.Z # Use same Z coordinate

# Distance between the two circle centers
d = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)

# Required distances for tangent circle
d1 = radius1 + radius3 # Distance from center1 to center3
d2 = radius2 + radius3 # Distance from center2 to center3

# Check if solution exists
ifd <abs(d1 - d2) or d > d1 + d2:
# No solution exists
OUT = "No tangent circle possible with these parameters"
else:
# Use trilateration to find center3
# Formula for finding intersection of two circles
a = (d1**2 - d2**2 + d**2) / (2 * d)
h = math.sqrt(d1**2 - a**2)

# Point along the line between centers
x3_mid = x1 + a * (x2 - x1) / d
y3_mid = y1 + a * (y2 - y1) / d

# Two possible solutions (above and below the line)
# Solution 1 (typically the "upper" tangent circle)
x3 = x3_mid + h * (y2 - y1) / d
y3 = y3_mid - h * (x2 - x1) / d

# Solution 2 (typically the "lower" tangent circle)
x3_alt = x3_mid - h * (y2 - y1) / d
y3_alt = y3_mid + h * (x2 - x1) / d

# Create center point for tangent circle (using solution 1)
center3 = Point.ByCoordinates(x3, y3, z)
center3_alt = Point.ByCoordinates(x3_alt, y3_alt, z)

# Create the three circles
circle1 = Circle.ByCenterPointRadius(center1, radius1)
circle2 = Circle.ByCenterPointRadius(center2, radius2)
circle3 = Circle.ByCenterPointRadius(center3, radius3)
circle3_alt = Circle.ByCenterPointRadius(center3_alt, radius3)

# Output both solutions
OUT = circle1, circle2, circle3, circle3_alt, center3, center3_alt

5 Likes

Hi,

a little variant with Arc.ByStartPointEndPointStartTangent()

arc_tangente_test

import sys
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

circle1 = IN[0]
circle2 = IN[1]
cord_radius = IN[2]

p1 = circle1.CenterPoint
r1 = circle1.Radius
p2 = circle2.CenterPoint
r2 = circle2.Radius

temp_c1 = Circle.ByCenterPointRadius(p1, cord_radius + r1)
temp_c2 = Circle.ByCenterPointRadius(p2, cord_radius + r2)
intersections = temp_c1.Intersect(temp_c2)

if intersections and len(intersections) > 0:
    # get the intersection top point
    arc_center = max(intersections, key = lambda p: p.Y)
    
    # calculate Tangent Points (Start and End of Arc) and reverse because is top point
    vec1 = Vector.ByTwoPoints(arc_center, p1).Normalized()
    vec2 = Vector.ByTwoPoints(arc_center, p2).Normalized()
    #
    start_pt = arc_center.Translate(vec1, cord_radius)
    end_pt = arc_center.Translate(vec2, cord_radius)
    # create an arc assuming that circle 1 rotates clockwise
    para1 = circle1.ParameterAtPoint(start_pt)
    vector1 = circle1.TangentAtParameter(para1).Reverse()
    result_arc = Arc.ByStartPointEndPointStartTangent(start_pt, end_pt, vector1)
    
    OUT = result_arc
else:
    OUT = "Circles are too far apart for this radius."
5 Likes

Alternative use Heron’s formula for a scalene triangle. I’ve been a bit lazy and used Geometry.ClosestPointTo nodes, however you could also maths these points out


5 Likes

Hi guys, your help was not evaluated, thank you!

2 Likes