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

标签 c# wpf math

我需要得到矩形和直线的交点。 我在矩形内有 B 点(矩形中心),在外面有 A 点。我需要在其中一个矩形边界上找到 C 点。 我还得到矩形​​的宽度和高度。

enter image description here

所有这些都是 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/

相关文章:

c# - Dapper 函数不映射存储过程中的字符串值,但正确映射其他值

c# - MetroTabItem Mahapps 不触发事件 MouseDown

function - 在谷歌表格中,如何找到非数值数据的众数?

c# - 如果我在 for 循环 c# 中运行几次,为什么我运行一次方法几乎同时完成工作

c# - 使用 OpenXML 在 Word 中获取复选框

wpf - 列表框数据模板文本溢出

具有多种目标类型的 WPF 命令

php - 数学符号到php中的html?

java - 以围绕保留中心框的圆形图案将网格框分配给用户

c# - .Net 核心 API 在 linux 机器上的监控