我试图找到一个圆的中心。 我唯一的信息是:圆圈中的两个随机点和圆形凸起。 到目前为止,我已经设法计算圆的半径(至少我认为我做了)。 不幸的是,到目前为止,我已经使用过这种方法。
这些只是随机值,会根据用户输入而改变)
PointA(x = 10,y = 15)PointB(x = 6,y = 12)
circle_bulge = 0.41
距离= PointB - PointA
radius =(距离/ 4)*(circle_bulge +(1 / circle_bulge))
如果这个数学不正确,请告诉我,但请记住,我需要找到圆心的X和Y坐标
im trying to find the center of a circle. the only information I have is: Two random points in the circle and the circle bulge. So far i've manage to calculate the radius of the circle (at least i think i did). Ill post bellow the equasions ive used so far.
these are just random values and will change on user input)
PointA(x = 10, y = 15) PointB(x = 6, y = 12)
circle_bulge = 0.41
distance = PointB - PointA
radius = (distance / 4) * (circle_bulge + (1 / circle_bulge ))
if this math is incorrect, please let me know, but keep in mind that i need to find the X and Y coordinates of the center of the circle
最满意答案
这是问题的图片:
根据定义,凸起是b = tg( Alpha / 4)
从三角公式:tg(2 角度 )= 2tg( 角度 )/(1-tg 2 ( 角度 ))
应用于角度 = Alpha / 4并使用凸起的定义:
tg( Alpha / 2)= 2 b /(1- b 2 )
另一方面
tg( Alpha / 2)= s / d
然后
s / d = 2 b /(1- b 2 )和
d = s (1- b 2 )/(2 b )
这允许我们计算d因为b是已知的并且s = || B - A || / 2,其中|| B - A || 表示向量B - A的范数。
现在,让我们计算一下
( u , v )=( B - A )/ || B - A ||
然后||( u , v )|| = 1,( v , - u )与B - A正交,我们有
C =( v , -u ) d +( A + B )/ 2
UPDATE
用于计算中心的伪代码
输入:
A = (a1, a2), B = (b1, b2) "two points"; b "bulge"计算:
"lengths" norm := sqrt(square(b1-a1) + square(b2-a2)). s := norm/2. d := s * (1-square(b))/(2*b) "direction" u := (b1-a1)/ norm. v := (b2-a2)/ norm. "center" c1 := -v*d + (a1+b1)/2. c2 := u*d + (a2+b2)/2. Return C := (c1, c2)注意:中心有两种解决方案,另一种是
c1 := v*d + (a1+b1)/2. c2 := -u*d + (a2+b2)/2. Return C := (c1, c2)Here is a picture of the problem:
By definition the bulge is b = tg(Alpha/4)
From the trigonometric formula: tg(2 angle) = 2tg(angle)/(1-tg2(angle))
applied to angle = Alpha/4 and using the definition of bulge:
tg(Alpha/2) = 2 b/(1-b2)
On the other hand
tg(Alpha/2) = s/d
Then
s/d = 2 b/(1-b2) and
d = s(1-b2)/(2 b)
which allows us to calculate d because b is known and s = ||B - A||/2, where ||B - A|| denotes the norm of the vector B - A.
Now, let's calculate
(u,v) = (B - A)/||B - A||
Then ||(u,v)|| = 1, (v,-u) is orthogonal to B - A, and we have
C = (v,-u)d + (A+B)/2
UPDATE
Pseudo code to compute the center
Inputs:
A = (a1, a2), B = (b1, b2) "two points"; b "bulge"Calculations:
"lengths" norm := sqrt(square(b1-a1) + square(b2-a2)). s := norm/2. d := s * (1-square(b))/(2*b) "direction" u := (b1-a1)/ norm. v := (b2-a2)/ norm. "center" c1 := -v*d + (a1+b1)/2. c2 := u*d + (a2+b2)/2. Return C := (c1, c2)Note: There are two solutions for the Center, the other one being
c1 := v*d + (a1+b1)/2. c2 := -u*d + (a2+b2)/2. Return C := (c1, c2)更多推荐
发布评论