【问题标题】:Calculate the coordinates of a point in a line计算直线中一点的坐标
【发布时间】:2015-01-20 17:30:30
【问题描述】:

我有一个像这样表示的游戏:

我想计算点 x4,y4 的坐标。 我所知道的是: y4 = y3, x4 在 x1,y1,x2,y2 线上,线为 45°(度)

我试过 x4 = y4 - y1 + x1 但效果不是很好..

有什么想法吗?

【问题讨论】:

    标签: geometry line detection point


    【解决方案1】:
    m= (y2-y1)/(x2-x1) = (y4-y1)/(x4-x1)=1 as slope is 45 degree.
    so x4=x1+y4-y1;
    substitute y4=y3;
    then X4 = x1+y3-y1;
    

    【讨论】:

      【解决方案2】:

      这个video 应该可以帮助您获得正确的公式。

      应该是:

      m = (y2 - y1) / (x2 - x1)
      b = y2 - m * x2
      x4 = (y3 - b) / m
      

      【讨论】:

      • 以上可以简化为x4 = x1 + (y4-y1)/m
      【解决方案3】:

      由于直线呈 45° 角,因此直线上两点之间的 dx=dy。因此:

      x4 = x1+(y1-y4)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-01-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-05
        • 2014-04-11
        相关资源
        最近更新 更多