【问题标题】:Determine the coordinates of a segment确定线段的坐标
【发布时间】:2014-11-09 08:28:18
【问题描述】:

如何使用atan2 确定线段结束的坐标,知道它的起点坐标 (x, y)、线段的角度和线段的长度?

你能告诉我一个解决方案,它不必只使用 atan2...

【问题讨论】:

    标签: atan2


    【解决方案1】:

    你有一个直角三角形,你可以假设点 A 在 (x,y) 处,这使用一些图表更容易解释:

    现在我们已经知道 c 的值是多少,因为这是段的长度,我们想知道 a 和 b 的值,因为终点在 (x+b, y+a)

    从三角学我们知道角度和边的比率之间的关系是什么

    sin(theta) = opposite/hypotenusecos(theta) = adjacent/hypotenuse

    代入我们知道的值:

    sin(theta) = opposite/c
    c = opposite * sin(theta)
    

    cos(theta) = adjacent/b
    b = adjacent * cos(theta)
    

    我们知道终点在(x+b, y+a),给定我们找到的边的值是(x+adjacent * cos(theta), y+opposite * sin(theta))

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-17
      相关资源
      最近更新 更多