Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

In a cartesian system I have 2 lines (an input and an output) and want to find the radius (r) and centre (c1, c2) of the two circles of equal radius that are touched tangentially at the end point of the input line (p1) and the start point of the output line (p2), and touch each other tangentially. The desired outcome is that a smooth path will be possible from the input line, onto the first circle, onto the second circle where they touch and then onto the output line.

I got part way through a solution but failed: Assuming that I can work out the direction of the lines perpendicular to input/output lines (d1, d2) that the circles' centres should lie on to give the optimal (smallest radius) solution, I noted that sliding c1 and c2 along these lines by an amount (t) would give the correct result (t = r) when the distance between c1 and c2 was 2t.

c1 = p1 + t * d1
c2 = p2 + t * d2
|c1 c2| = 2t

This all seems correct to me, but my method of solving it from there involved making a quadratic equation and solving for t. For my simple test data (below) this resulted in a division by zero and taking the root of a negative number (it is possible that I expanded incorrectly, but have checked several times and can't find the error).

Sample data:

p1 = (0,0)
p2 = (5,2)
d1 = (1,0)
d2 = (-1,0)

I am looking for either a quadratic equation that works or an entirely different method of working it out, I'm just after a generalised solution (I can find a solution for the sample data through trig but I don't know of a trig method that generalises well).

share|improve this question
    
From what you write it doesn't appear to be clear what you want. And if you want what I think you do then your problem doesn't have a solution. Maybe you can clarify: You have two given line segments with endpoints $p_i$ and $d_i$ respectively. Now you want two circles of the same radius such that... right? –  Simon Markett May 24 '12 at 9:52
    
@Simon: Sorry it isn't very clear. p1 and p2 are the end and start points of two directed line segments. d1 and d2 are unit vectors perpendicular to the direction of the line segments (perpendicular in opposite directions, so d1 is 90 degrees to the right of the line ending at p1, and d2 is 90 degrees to the left of the line that starts at p2, or vice versa). I'm reasonably sure that if p2 is rotationally right of the line ending at p1 then d1 should be to the right of this line also for the optimal solution, otherwise it is to the left. –  Byker Dave May 24 '12 at 10:34
    
It's still not very clear, $p_1$ and $p_2$ are start end point of both lines? Or do you mean: you have two lines parallel to the $x$-axis (or line segments, but this should change your situation) passing through $(0,0)$ and $(5,2)$, respectively. Now you want two circles of equal radius such that the first line touches the first circle in $(0,0)$, the second line touches the second circle in $(5,2)$ and the two circles touch in one point? –  Simon Markett May 24 '12 at 10:46
add comment

2 Answers

up vote 0 down vote accepted

Suppose we let $q_1$ and $q_2$ denote the centers of circles c1 and c2 respectively, and let $r$ denote their radii. We know that $$q_1 = p_1 + r*d_1$$ $$q_2 = p_2 + r*d_2$$ $$distance(q_1, q_2) = 2r$$ Substitute $q_1$ and $q_2$ from the first and second equations into the third, and you get a quadratic that you can solve to get $r$. Substitute back into the first and second equations to get $q_1$ and $q_2$.

share|improve this answer
    
Thanks for the response. This is the path I went down, and was having problems when using the sample data I provided (negative square root and division by zero in the quadratic formula). It turns out I was being a little dumb and hadn't realised that for data like the sample it is linear, and has only one solution, so just needed to special case for that. Giving you the answer as you are correct, and I have a solution now. Thanks again. –  Byker Dave Jun 6 '12 at 10:34
add comment

Given two lines and a point on one of the line, there is already a unique circle that is tangent to the lines and passes through the point.

You demand in addition that two such circles through two arbitrary points have the same radius. This is something that you cannot demand and therefore, your argument is flawed as well, because there are two different radii to use in the formula.

share|improve this answer
    
I've just spent a good few minutes putting together an image to clearly explain my problem, only to be informed that I can't submit pictures until I up my reputation. I have solved the problem I was having, with A equal to zero the radius is simply -C/B. –  Byker Dave May 24 '12 at 13:13
    
One last attempt at clarification, I think I missed a couple of 'respectively's out of my description that might have cleared things up. Circle 1 touches p1, and c1 is on the line p1 + t * d1. Circle 2 touches p2, and c2 is on the line p2 + t * d2. If i manage to up my reputation before I forget this question I will answer with an image and my values for the quadratic equation (or linear in the case where d1 and d2 are parallel). –  Byker Dave May 24 '12 at 13:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.