c# – 获取矩形和直线的交点

前端之家收集整理的这篇文章主要介绍了c# – 获取矩形和直线的交点前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要获得矩形和直线的交点.
在矩形(矩形的中心)内有B点,在外面有A点.我需要在一个矩形边框上找到C点.
我也得到了矩形的宽度和高度.

所有这些都将是WPF应用程序,所以如果任何构建功能我将非常高兴.

解决方法

这是基本的数学求解线 – 线交叉,检查 tutorial的topcoder:

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

原文链接:https://www.f2er.com/csharp/100307.html

猜你在找的C#相关文章