jpmorr
jpmorr

Reputation: 636

How to find the centre and radius of a circle that passes through a specific point and is tangential to line

I am trying to numerically find the solution to a problem of finding the centre and radius of a circle that is tangential to a given line and passes through another given point. The problem is shown in the following image:

Circle that is tangential to a line and passes through a point in space

The circle must be tangential to the line Y=mx + c and must pass through the point. The centre of the circle will always lie on the x-axis (y=0) which is the bisector of the two lines as the problem is symmetric. Point A is always known, as is the angle theta. Point P is specified as the input

I can write down some of the equation for the right-angle triangle: Sin theta = BC / AC and I know that BC == PC == R, but I'm not sure how to solve this numerically as the equation of the line and the point will be different every time the code is called. Solving by hand would involve substituting A and P back into the equations of the lines I think.

I presume I need to solve some simultaneous equations using some scipy module, but don't know what exactly I should do. Hopefully someone can help.

Upvotes: 0

Views: 696

Answers (1)

John M.
John M.

Reputation: 795

I think there are two solutions which can work out by solving a quadratic equation.

The formula for a circle is (x ** 2) + (y ** 2) = r ** 2. Your point P(xp, yp) is a circle with centre C(xc, yx) so (xc - xp) ** 2 + (yc - yp) ** 2 = r ** 2. You also know yc == 0, so (xc - xp) ** 2 + yp ** 2 = r ** 2 where xp and yp are known constants.

You also know that ABC is a right angle triangle, so r / (xc - xa) = sin(theta), where xa is a known constant.

At which point you can substitute either r or xc to create a quadratic equation and solve using the standard formula see.

Upvotes: 2

Related Questions