计算负坐标系中两点之间的直线的方位角

时间:2013-10-18 04:19:27

标签: python orientation

我有一个问题,我似乎无法解决。我也找不到任何先前帖子的解决方案。

我在公制坐标系中工作,其中所有变量都是负值(例如:origin = -2,-2; north = -2,-1; east = -1,-2; south = -2, -3, west = -3,-2)。这是一个南半球坐标系。我需要计算通过两个点的线的方位角方向和斜率,假设第一个点是原点。

我已经能够使用Python编写一个脚本来计算每对点的方向(0-360度),但根据我比较的参考数据集,许多值相反180度我的结果反对,已经计算了这些值。

如果我使用ATAN2然后将弧度转换为度数,那么线条经过的2D图形上的哪个象限是否重要?我需要根据象限添加或减去0,90,180,270或360吗?我认为这是我的问题,但我不确定。

最后,上面假设我分别在2D空间中进行方向和斜率的计算。是否有更简约的方法来计算3D空间中的这些变量?

我附上了当前的代码块,其中包括每个象限的方位角计算。我非常感谢你们所提供的任何帮助。

    dn = north_2 - north_1
    de = east_2 - east_1
    x = x + 1


    if dn<0 and de<=0:
        q = "q3"
        theta = math.degrees(math.atan2(dn,de))
        orientation = 90- theta
    if dn>=0 and de <0:
        q = "q4"
        theta = math.degrees(math.atan2(dn,de))
        orientation = 270-theta
    if dn>0 and de>=0:
        q = "q1"
        theta = math.degrees(math.atan2(dn,de))
        orientation = 270-theta
    if dn<=0 and de>0:
        q = "q2"
        theta = math.degrees(math.atan2(dn,de))
        orientation = 90-theta

0 个答案:

没有答案