我需要得到矩形和直线的交点。 我在矩形内有 B 点(矩形中心),在外面有 A 点。我需要在其中一个矩形边界上找到 C 点。 我还得到矩形的宽度和高度。
所有这些都是 WPF 应用程序,所以如果有任何内置功能我会很高兴。
最佳答案
这是解决直线交点的基本数学问题,请查看 topcoder 以获得 tutorial :
Line-Line Intersection One of the most common tasks you will find in geometry problems is line intersection. Despite the fact that it is so common, a lot of coders still have trouble with it. The first question is, what form are we given our lines in, and what form would we like them in? Ideally, each of our lines will be in the form Ax+By=C, where A, B and C are the numbers which define the line. However, we are rarely given lines in this format, but we can easily generate such an equation from two points. Say we are given two different points, (x1, y1) and (x2, y2), and want to find A, B and C for the equation above. We can do so by setting A = y2-y1 B = x1-x2 C = A*x1+B*y1
关于c# - 获取矩形和直线的交点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5221725/