-1

I know the angle at point A and that the circle goes through point A and point B. There should be a unique solution that gives me the circle center (C) and radius (R) from this information. I've tried to find a formula as follows.

R^2 = (Bx - Cx)^2 + (By - Cy)^2
Cx = Ax - R*dy
Cy = Ay + R*dx

(dx,dy) is a unit vector for the tangent to the circle at point A, which can be found from the angle at point A with sin,cos. The center of the circle is distance R from point A in the direction perpendicular to (dx,dy).

Putting this together gives me

R^2 = (Bx - Ax + R*dy)^2 + (By - Ay - R*dx)^2

Multiplying this out gives me a quadratic for R, but the denominator of the quadratic (the /2a part) is

dx^2 + dy^2 - 1

Since (dx,dy) is a unit vector, the denominator is always 0 and I get a divide by zero error. Where have I gone wrong?

XylemFlow
  • 963
  • 5
  • 12
  • "I know the angle at point A"? What about angle? Unclear. -1. – peterh Jun 23 '14 at 15:02
  • please add a drawing - if that is the angle of the line linking point A to center, there are infinite circles passing between the two points along that line - in the image A and B are the point, alpha is a possible interpretation of angle to A, and c - c' are two circle centers that both satisfy all conditions but describe different circles http://tinypic.com/r/9lj3ps/8 – Lorenzo Boccaccia Jun 23 '14 at 15:06
  • Do you mean the angle between the line segment AB and the tangent to the circle at A? – Thomas Andrews Jun 23 '14 at 15:56
  • Looking at the equation for the center the user means the angle of the tangent. – Salix alba Jun 24 '14 at 00:06

3 Answers3

0

Assuming you mean the angle between the line AB and the tangent line. l, of the circle at A:

The key is to draw the perpendicular bisector of AB and the line perpendicular to l through A, and find the intersection. That will be the center of your circle.

Thomas Andrews
  • 1,577
  • 1
  • 13
  • 31
0

The formulation seems fine to me. Lets expand the expression

R^2 = (Bx - Ax + R dy)^2 + (By - Ay - R dx)^2

this gives

R^2 = Bx^2 + Ax^2 + R^2 dy^2 + 2 Bx R dy - 2 Ax Bx - 2 Ax R dy
    + By^2 + Ay^2 + R^2 dx^2 - 2 By R dx - 2 Ay By + 2 Ay R dx

Rearrange

(1 - dx^2 - dy^2) R^2 + 2 (Ax dy - Ay dx - Bx dy + By dx) R + 2 (Ax Bx + Ay By) = 0

You are correct in that if (dx,dy) is a unit vector the R^2 term vanishes. This is not a problem it just means you have a linear equation to solve.

2 (Ax dy - Ay dx - Bx dy + By dx) R + 2 (Ax Bx + Ay By) = 0

which is easy to solve

R = - (Ax Bx + Ay By) / (Ax dy - Ay dx - Bx dy + By dx)

Things are a little simpler if you let U = (u,v) = (Bx-Ax,By-Ay) be the vector from A to B our equation becomes

R^2 = (u + R dy)^2 + (v - R dx)^2
    = u^2 + 2 u dy R + dy^2 R^2 + v^2 - 2 v dx R + dx^2 R^2

Rearrange

(1-dx^2-dy^2) R^2 + 2 (v dx - u dy) R - u^2 - v^2 = 0

Let T=(dx,dy) be the tangent, and N=(dy,-dx) is normal. If they are unit length it simplifies to

  2 (N . U) R - U . U = 0

giving

 R = (U . U)/ 2 (N . U)
Salix alba
  • 7,536
  • 2
  • 32
  • 38
  • Many thanks. I feel stupid for not realising that the R^2 term vanishes. If I had written it out instead of trying to save time by using a symbolic math tool then I probably would have realised. I didn't expect it to simplify so much. The final solution is incredibly simple. Here's some Matlab code I wrote to test it. p1 = [2 2]; p2 = [5 5]; angle = 20; d = [sind(angle) cosd(angle)]; n = [d(2) -d(1)]; pd = p2 - p1; r = (pd * pd') / (2 * (n * pd')); c = p1 + r*[d(2) -d(1)]; plot([p1(1) p2(1)], [p1(2) p2(2)], 'r.') hold on rectangle('Position', [c-r 2*r 2*r], 'Curvature', [1 1]) axis equal – XylemFlow Jun 24 '14 at 16:25
  • I'm sure there is a geometrical explanation for the final formula. – Salix alba Jun 24 '14 at 16:53
0

I have solved from my theory. The slope of the circle is the radius equal 1.

Therefore: the slope=(rise^2+run^2)^(1/2)=1, so dy^2+dx^2=1^2 and (dy^2+dx^2)^(1/2)=1.

Jeffrey Bosboom
  • 13,313
  • 16
  • 79
  • 92