计算弧和线之间的相交点 [英] Calculate intersect point between arc and line

查看:183
本文介绍了计算弧和线之间的相交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算弧和线之间的相交点。我拥有线和弧的所有数据。

对于直线:起点和终点。

对于弧:起点/终点,起点/终点角度,半径和中心点。 / p>

我在这里附上一张图片。在这张下面的图片中,我画了一条弧线,线条与弧线相交。

现在我想找到相交点。请给我一些算法或想法,或者如果有任何可用的代码。



解决方案

弧线上的点有坐标

  R.cos(t)+ Xc 
R.sin(t)+ Yc

使用线性方程式的隐式(无论是给定还是从两个给定点中获得的),

  AX + BY + C = 0 

然后

  ARcos(t)+ BRsin(t)+ A.Xc + B.Yc + C = 0 

为了解决这个三角函数方程,首先将两个成员除以R.√A²+B²,给出

  c.cos(t)+ s.sin(t)= d 

可以重写,其中 tan(p)= s / c d = cos(q)
$ $ $ $ code $ cos $(tp)= cos($)
pre>

然后

  t = p +/- q = arctan (B / A)+/- arccos( - (A.Xc + B.Yc + C)/R.√A²+B²)

最后,您需要检查这些值 t 落在(开始,结束)范围内,模2π。

I want to calculate the intersect point between arc and line. I have all the data for line and arc.

For line : start and and end point.
For arc : start/end point, start/end angle, radius and center point.

I have attach here one image. In this below image I have draw one arc and line where line intersect the arc.

So now I want to find the intersect point. Please give me some algorithm or idea or if any available code.

解决方案

A point on the arc has coordinates

R.cos(t) + Xc
R.sin(t) + Yc

Using the implicit form of the line equation (either given or obtained from two given points),

A.X + B.Y + C = 0

then

A.R.cos(t) + B.R.sin(t) + A.Xc + B.Yc + C = 0

To solve this trigonometric equation, first divide both members by R.√A²+B², giving

c.cos(t) + s.sin(t) = d

which can be rewritten, with tan(p) = s/c and d = cos(q):

cos(t-p) = cos(q)

then

t = p +/- q = arctan(B/A) +/- arccos(-(A.Xc + B.Yc + C)/R.√A²+B²)

Eventually, you will need to check if these values of t fall in the range (start, end), modulo 2π.

这篇关于计算弧和线之间的相交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆