线段圆交点 [英] Line Segment Circle Intersection
问题描述
我试图确定线段与圆相交的点。例如,给定P0和P3之间的任何点(还假设你知道半径),确定P3的最简单方法是什么?
I am trying to determine the point at which a line segment intersect a circle. For example, given any point between P0 and P3 (And also assuming that you know the radius), what is the easiest method to determine P3?
推荐答案
方程组。该圆定义为: x ^ 2 + y ^ 2 = r ^ 2
。该行由 y = y0 + [(y1 - y0)/(x1 - x0)]·(x - x0)
定义。将第二个代入第一个,得到 x ^ 2 +(y0 + [(y1 - y0)/(x1 - x0)]·(x - x0))^ 2 = r ^ 2
。解决这个问题,你会得到0-2的值。将它们插回到任一等式中以获得y的值。
You have a system of equations. The circle is defined by: x^2 + y^2 = r^2
. The line is defined by y = y0 + [(y1 - y0) / (x1 - x0)]·(x - x0)
. Substitute the second into the first, you get x^2 + (y0 + [(y1 - y0) / (x1 - x0)]·(x - x0))^2 = r^2
. Solve this and you'll get 0-2 values for x. Plug them back into either equation to get your values for y.
这篇关于线段圆交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!