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

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...