找到一个圆的中心(x和y位置),只有2个随机点和凸起(Find the center of a circle (x and y position) with only 2 random points

编程入门 行业动态 更新时间:2024-10-28 14:32:16
找到一个圆的中心(x和y位置),只有2个随机点和凸起(Find the center of a circle (x and y position) with only 2 random points and bulge)

我试图找到一个圆的中心。 我唯一的信息是:圆圈中的两个随机点和圆形凸起。 到目前为止,我已经设法计算圆的半径(至少我认为我做了)。 不幸的是,到目前为止,我已经使用过这种方法。

这些只是随机值,会根据用户输入而改变)

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的范数。

现在,让我们计算一下

uv )=( B - A )/ || B - A ||

然后||( uv )|| = 1,( v , - u )与B - A正交,我们有

C =( v-ud +( 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:

enter image description here

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)

更多推荐

本文发布于:2023-08-03 21:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1401824.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   中心   center   Find   circle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!