【问题标题】:from 2 points and an angle get position of tird从 2 点和一个角度得到 tird 的位置
【发布时间】:2020-11-24 17:53:18
【问题描述】:

我有 2 个点和一个角度,想找到第 3 个点在哪里。一幅画:

我知道 a、p1、p2 以及它们之间的距离 d。现在我想找到 p3 的坐标。 例如:a = 30°; p1 = (10,10,10); p2 = (10,10,20); p3 = (?,10,?) 注意:由于轴的命名方式,y 值保持不变。 我该怎么做?

【问题讨论】:

  • 您需要更多数据。知道a,p1,p2 会直接告诉p1->p3,但不是p3 点。为此,您还需要例如距离 p1-p3 或 p2-p3。
  • p3和p1之间的距离等于p1和p2之间的距离。

标签: python-3.x geometry coordinates trigonometry


【解决方案1】:

给定点P1P2,我们计算它们之间的距离:

d12 = sqrt((P2.x - P1.x)*(P2.x - P1.x) + (P2.y - P1.y)*(P2.y - P1.y) + (P2.z - P1.z)*(P2.z - P1.z))

请注意,您也可以使用 math.pow(P2.x-P1.x, 2) 而不是重新乘法

我们也计算P1到P2的角度,知道.y的坐标是一样的:

aP1P2 = math.atan2(P2.z-P1.z, P2.x-P1.x)  # In radians, not degrees

现在我们减去给定的a 角度:

aP1P3 = aP1P2 - math.radians(a)  # 'a' is given in degrees, but we use radians

最后点 P3 由 P1、距离和计算的角度给出:

P3.x = P1.x + d12 * math.cos(aP1P3)
P3.y = P1.y # same as P1 an P2
P3.z = P1.z + d12 * math.sin(aP1P3)

【讨论】:

    猜你喜欢
    • 2011-08-29
    • 2010-12-19
    • 1970-01-01
    • 2013-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多