给定三个点A,B和C
我如何找到一个起点为A,终点为C且经过B的弧; 它的中心坐标、半径和r和r'的角度?
有几种方法可以实现这一点。以下是其中一种算法:
获取您的 COORDS
A = {xA,yA}
B = {xB,yB}
C = {xC,yC}
d = {xd,yd}
计算线段 AB 和 BC 的中点
mid_AB = { (xA+xB)/2, (yA+yB)/2 }
mid_BC = { (xB+xC)/2, (yB+yC)/2 }
找到线段 AB 和 BC 的斜率
slope_AB = (yB-yA)/(xB-xA)
slope_BC = (yC-yB)/(xC-xB)
构造通过 mid_AB 和 mid_BC 垂直于 AB 和 BC 的线段(感谢 Yves 发现错误!)
Slope_perp_AB = -(slope_AB)^(-1)
Slope_perp_BC = -(slope_BC)^(-1)
*** Slope_perp_AB 的线段穿过 mid_AB
*** Slope_perp_BC 的线段穿过 mid_BC
将两个方程式设置为相等,解出交点! 这给出了点 d={xd,yd} !!!
该圆的中心与给定的三个点等距离:
(X-Xa)^2+(Y-Ya)^2 = (X-Xb)^2+(Y-Yb)^2 = (X-Xc)^2+(Y-Yc)^2
2(Xa-Xb) X + 2(Ya-Yb) Y + Xb^2+Yb^2-Xa^2-Ya^2 = 0
2(Xa-Xc) X + 2(Ya-Yc) Y + Xc^2+Yc^2-Xa^2-Ya^2 = 0
这个包含两个未知数的线性方程组可以使用Cramer定则轻松求解。
通过以中心为中心进行笛卡尔坐标系到极坐标系的转换,可以找到半径和角度:
R= Sqrt((Xa-X)^2+(Ya-Y)^2)
Ta= atan2(Ya-Y, Xa-X)
Tc= atan2(Yc-Y, Xc-X)
Ta
到 Tb
还是从 Tb
到 2 Pi
再到 Ta+2 Pi
,或者其他呢?答案并不像看起来那么明显,你可以尝试一下(因为三个角度 Ta
、Tb
和 Tc
都不能确定到一个 2 Pi
倍数,所以无法排序)!步骤1
找到AB和BC的垂直平分线。
步骤2
找到这些线相交的点。
你找到的点将是你所需的圆的中心。
步骤3
计算三个点中任意一个点到你在步骤2中找到的中心的距离。这将是你圆的半径。
注意 点A、B和C不能在同一条直线上。在执行步骤1至3之前,您需要进行检查。
解决方法与“非过定系统最佳拟合圆”的解法几乎相同。由于您有三个点恰好位于以(0,0)
为圆心的圆弧上(给定),因此可以精确解决该系统,而不需要进行最小二乘逼近。
Finding the Center of a Circle Given 3 Points
Date: 05/25/2000 at 00:14:35
From: Alison Jaworski
Subject: finding the coordinates of the center of a circle
Hi,
Can you help me? If I have the x and y coordinates of 3 points - i.e.
(x1,y1), (x2,y2) and (x3,y3) - how do I find the coordinates of the
center of a circle on whose circumference the points lie?
Thank you.
Date: 05/25/2000 at 10:45:58
From: Doctor Rob
Subject: Re: finding the coordinates of the center of a circle
Thanks for writing to Ask Dr. Math, Alison.
Let (h,k) be the coordinates of the center of the circle, and r its
radius. Then the equation of the circle is:
(x-h)^2 + (y-k)^2 = r^2
Since the three points all lie on the circle, their coordinates will
satisfy this equation. That gives you three equations:
(x1-h)^2 + (y1-k)^2 = r^2
(x2-h)^2 + (y2-k)^2 = r^2
(x3-h)^2 + (y3-k)^2 = r^2
in the three unknowns h, k, and r. To solve these, subtract the first
from the other two. That will eliminate r, h^2, and k^2 from the last
two equations, leaving you with two simultaneous linear equations in
the two unknowns h and k. Solve these, and you'll have the coordinates
(h,k) of the center of the circle. Finally, set:
r = sqrt[(x1-h)^2+(y1-k)^2]
and you'll have everything you need to know about the circle.
This can all be done symbolically, of course, but you'll get some
pretty complicated expressions for h and k. The simplest forms of
these involve determinants, if you know what they are:
|x1^2+y1^2 y1 1| |x1 x1^2+y1^2 1|
|x2^2+y2^2 y2 1| |x2 x2^2+y2^2 1|
|x3^2+y3^2 y3 1| |x3 x3^2+y3^2 1|
h = ------------------, k = ------------------
|x1 y1 1| |x1 y1 1|
2*|x2 y2 1| 2*|x2 y2 1|
|x3 y3 1| |x3 y3 1|
Example: Suppose a circle passes through the points (4,1), (-3,7), and
(5,-2). Then we know that:
(h-4)^2 + (k-1)^2 = r^2
(h+3)^2 + (k-7)^2 = r^2
(h-5)^2 + (k+2)^2 = r^2
Subtracting the first from the other two, you get:
(h+3)^2 - (h-4)^2 + (k-7)^2 - (k-1)^2 = 0
(h-5)^2 - (h-4)^2 + (k+2)^2 - (k-1)^2 = 0
h^2+6*h+9 - h^2+8*h-16 + k^2-14*k+49 - k^2+2*k-1 = 0
h^2-10*h+25 - h^2+8*h-16 + k^2+4*k+4 - k^2+2*k-1 = 0
14*h - 12*k + 41 = 0
-2*h + 6*k + 12 = 0
10*h + 65 = 0
30*k + 125 = 0
h = -13/2
k = -25/6
Then
r = sqrt[(4+13/2)^2 + (1+25/6)^2]
= sqrt[4930]/6
Thus the equation of the circle is:
(x+13/2)^2 + (y+25/6)^2 = 4930/36
- Doctor Rob, The Math Forum
http://mathforum.org/dr.math/
参考资料
<http://mathforum.org/library/drmath/view/55239.html>
(xA-xM)^2+(yA-yM^2) = R^2
等等。将B和C方程式减去A方程式得到:
2*(xB-xA)*xM+2*(yB-yA)*yM = xB^2-xA^2+yB^2-yA^2
2*(xC-xA)*xM+2*(yC-yA)*yM = xC^2-xA^2+yC^2-yA^2
有一个鲜为人知的结果,可以给出通过三个点的圆的隐式方程:
|Z X Y 1|
|Za Xa Ya 1|
|Zb Xb Yb 1| = 0
|Zc Xc Yc 1|
为了简洁起见,我们定义 Z:= X^2 + Y^2
。
计算3x3子式,我们发展成:
M00 Z + M10 X + M20 Y + M30 = 0
X^2 + Y^2 + 2U X + 2V Y + W = 0
这可以被重写为:
(X - U)^2 + (Y - V)^2 = U^2 + V^2 - W
立即给出中心点(U, V) = (-M10/2.M00, -M20/2.M00)
和半径R^2 = U^2 + V^2 - M30/M00
。
r == r'
。 - Thomas