【问题标题】:Given top left and bottom right points, how can I find all points inside a rectangle?给定左上角和右下角点,如何找到矩形内的所有点?
【发布时间】:2013-04-22 19:08:59
【问题描述】:

我正在尝试实现类似 excel 的单击+拖动功能,用户单击单元格并拖动。当用户停止拖动时,我可以计算矩形的左上角和右下角。我也可以很方便的计算出矩形的长、高、面积,但是如何计算矩形内的坐标呢?

【问题讨论】:

  • 使用两个循环,一个从 x1 到 x2 的外循环和一个从 y1 到 y2 的嵌套内循环?实际上,我不确定您所说的“矩形内的坐标”是什么意思...
  • 嵌套两个循环就够了,但真正的问题是:为什么需要这个?

标签: c# .net wpf geometry shape


【解决方案1】:

伪代码:

for i = left_edge to right_edge
    for j = top_edge to bottom_edge
        add [i, j] to list of points inside rectangle

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-17
    相关资源
    最近更新 更多