微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/csharp/100307.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐