I want to put a circle between two lines However, I only want to use one line for the creation of the circle. So my approach is to select points on line 1. For each point on line 1: I want to create circles with increasing radius which are tangential to the point 1 on line. Increase the radius, until the circle intersects also the other line. Decrease afterwards the radius in smaller steps until the circle is tangential to both lines. Proceed with next point on line 1.
Somehow, I am not able to find a clean and crisp code to do that. The points on the line can be done using line.arbitrary_point. How can I create a circle with radius R to the point p1 so that it is tangential in the best way?
Thanks!
The center of a circle of radius
Rthat is tangent to two liness1ands2is the intersection of two other lines, each one is parallel by a distanced= RLet line
s1fromA1= {ax1,ay1}toB1= {bx1,by1}ands2fromA2= {ax2,ay2}toB2= {bx2,by2}Using parametric representation, a point in
s1iswhere
k1is a different value for each point and{v1x,v1y}is unitary vector in directionA1,B1:Same goes for line
s2:Now, to get a parallel to
s1we just change pointA1by adding a vectorvp1perpendicular to A1-B1 with lengthd= R. The perpendicular unitary vector is:vpu1= {-v1y, v1x}. Attention: if you want the other solution, at the other side of both lines, then use{v1y, -v1x}instead.So, with
vp1 = vpu1·Randvp2= {-v2y, v2x}·Rthe new points for parallels tos1ands2areNow we must find the intersection
Cof theses lines:Solving for
k1, k2, sp1x, sp1ywe get:Pay attention to the value of
den. Itabs(den) < smallValue(IOW, this denominator is close to zero), thens1ands2are parallel or the same straight. In this case, there isn't a solution.Finally, the tangent points are now easy: