find point of intersection between two arc

时间:2017-12-18 06:37:00

标签: actionscript-3 flash math

I'm creating a game for kids. It's creating a triangle using 3 lines. How I approached this is I create two arcs(semi circle) from two end points of a base line. But I couldn't figure how to find the point of intersection of those two arc. I've search about it but only found point of intersection between two straight lines. Is there any method to find this point of intersection? Below is the figure of two arcs drawn from each end of the baseline.

enter image description here

3 个答案:

答案 0 :(得分:2)

While you have not stated clearly, I assume that you have points with coordinates <div class="EditBoking"> <div class="title"> Din nuvarande bokning </div> <div> <ul class="listOneRow"> <li> <span>Startdatum: 2017-12-12</span> </li> <li> <span>Slutdatum: 2017-12-12</span> </li> <li> <span>Program: some program</span> </li> <li> <span>Miljö: Arrendator</span> </li> </ul> </div> </div> <div class="EditBoking"> <div class="title"> Din nuvarande bokning </div> <div> <ul class="listOneRow"> <li> <span>Startdatum: 2017-12-12</span> </li> <li> <span>Slutdatum: 2017-12-12</span> </li> </ul> </div> </div> <div class="EditBoking"> <div class="title"> Din nuvarande bokning </div> <div> <ul class="listOneRow"> <li> <span>Startdatum: 2017-12-12</span> </li> <li> <span>Slutdatum: 2017-12-12</span> </li> </ul> <ul class="listOneRow"> <li> <span>Startdatum: 2017-12-12</span> </li> <li> <span>Slutdatum: 2017-12-12</span> </li> </ul> <ul class="listOneRow"> <li> <span>Startdatum: 2017-12-12</span> </li> <li> <span>Slutdatum: 2017-12-12</span> </li> </ul> </div> </div> and (A.X, A.Y) and lengths of two sides (B.X, B.Y) and LenA and need to find coordinates of point C.

So you can make equation system exploiting circle equation:

LenB

and solve it for unknowns C.X, C.Y.

Not that it is worth to subtract A coordinates from all others, make and solve simpler system (the first equation becomes (C.X - A.X)^2 + (C.Y - A.Y)^2 = LenA^2 (C.X - B.X)^2 + (C.Y - B.Y)^2 = LenB^2 ), then add A coordinates again

答案 1 :(得分:2)

Assume centers of the circle are (Parameters, x1) and (y1, x2), radii are y2 and R1. Let the ends of the base be R2 and A and the target point be B. We know that T = AT and R1 = BT. IMHO the simplest trick to find R2 is to notice that difference of the squares of the distances is a known constant T. And it is easy to see that the line the contains points meeting this condition is actually a straight line perpendicular to the base. Circles equations:

(R1^2 - R2^2)

If we subtract one from another we'll get:

(x - x1)^2 + (y-y1)^2 = R1^2    
(x - x2)^2 + (y-y2)^2 = R2^2

Let's (x2 - x1)(2*x - x1 - x2) + (y2 - y1)(2*y - y1 - y2) = R1^2 - R2^2 and x0 = (x1 + x2)/2 - the coordinates of the center. Let also the length of the base be y0 = (y1 + y2)/2 and its projections L and dx = x2 - x1 (i.e. dy = y2 - y1). And let's L^2 = dx^2 + dy^2 So we can see that

Q = R1^2 - R2^2

So the line for all 2 * (dx * (x-x0) + dy*(y-y0)) = Q pairs with (x,y) = R1^2 - R2^2 = const is a straight line orthogonal to the base (because coefficients are exactly Q and dx).

Let's find the point dy on the base that is the intersection with that line. It is easy - it splits the base so that difference of the squares of the lengths is C. It is easy to find out that it is the point on a distance Q from L/2 + Q/(2*L) and A from L/2 - Q/(2*L). So now we can find that

B

Substituting back TC^2 = R1^2 - (L/2 + Q/(2*L))^2 and simplifying a bit we can find that

Q

So let's

  TC^2 = (2*L^2*R1^2 + 2*L^2*R2^2 + 2*R1^2*R2^2 - L^4 - R1^4 - R2^4) / (4*L^2)

Note that formula for a = (R1^2 - R2^2)/(2*L) b = sqrt(2*L^2*R1^2 + 2*L^2*R2^2 + 2*R1^2*R2^2 - L^4 - R1^4 - R2^4) / (2*L) can also be written in a different form:

b

which looks quite similar to the Heron's formula. And this is not a surprise because b = sqrt[(R1+R2+L)*(-R1+R2+L)*(R1-R2+L)*(R1+R2-L)] / (2*L) is effectively the length of the height to the base b from AB in the triangle T so its length is ABT where 2*S/L is the area of the triangle. And the triangle S obviously has sides of lengths ABT, L and R1 respectively.

To find the target R2 we need to move T along the base and a in a perpendicular direction. So coordinates of b calculated from the middle of the segment are:

T

Here Xt = x0 + a * dx/L ± b * dy / L Yt = y0 + a * dy/L ± b * dx / L means that there are two solutions: one on either side of the base line.

Partial case: if ±, then R1 = R2 = R and a = 0 which makes obvious sense: b = sqrt(R^2 - (L/2)^2) lies on the segment bisector on a length of T from the middle of the segment.

Hope this helps.

答案 2 :(得分:1)

所以我实际上需要这个来设计一个漏斗,以便在葡萄酒收获期间提升葡萄。试图自己解决,但代数太可怕了,所以我在网上看看 - 最后我自己做了,但引入了一些中间变量(我在 Excel 中计算 - 这也应该适用于 OP,因为目标是一个计算的解决方案)。公平地说,这与之前的解决方案非常相似,但希望更清晰一些。

问题: 点 P(Xp,Yp) 到点 Q(Xq,Yq) 的距离 Lq 和到点 R(Xr,Yr) 的距离 Lr 的坐标是什么?

让我们首先将问题映射到以 Lq 为原点的新坐标系上,因此 Q' = (0,0),让 (x,y) = P'(Xp-Xq,Yp-Yq) 并让(a,b) = R'(Xr-Xq,Yr-Yq).

我们现在可以写:

x^2 + y^2 = Lq^2 -(1)

(x-a)^2 + (y-b)^2 = Lr^2 -(2)

扩展 2:

x^2 – 2ax + a^2 + y^2 -2ay + b^2 =Lr^2

减1并重新排列

2by = -2ax + a2 + b2 - Lr^2+ Lq^2

为方便起见,设c = a^2 + b^2 + Lq^2 + Lr^2(这些都是已知常数,所以c很容易计算),因此我们得到:

y = -ax/b + c/2b

代入1我们得到:

x^2 + (-a/b x + c/2b)^2 = Lq^2

将整个方程乘以 b^2 并收集项:

(a^2 + b^2) x2 -ac x + c/4 + Lq^2 b^2 = 0

设 A = (a2 + b2), B= -ac , and C= c/4 + Lq^2 b^2

使用二次方程的一般解

x = (-B +-SQRT(B^2-4AC))/2A

代入1得到:

y= SQRT(Lq^2 - x^2 )
(这避免了 b = 0 时的计算困难)

映射回原始坐标系

P = (x+Xq, y + Yq)

希望这会有所帮助,抱歉格式化,我在 Word 中很漂亮,但丢失了