我有两个点的三维尺寸(x,y,z),我想要计算方位角,然后使用Python3。先谢了。
发布于 2021-10-09 11:41:31
请试试这个,
在解析几何中,
距离=平方((x2-x1)2+(y2-y1)2+(z2-z1)2)
纵倾=弧心((z2 - z1) /距离)
方位角=弧形((x2-x1)/(y2-y1))(总是在二维中)
返回的θ值将在±90°范围内,必须进行校正才能得到0到360°范围内的真实方位。
import math
x1,y1,z1 = 5.0,6.7,1.5
x2,y2,z2 = 4.0,1.2,1.6
distance = math.sqrt((x2-x1)**2+(y2-y1)**2+(z2 -z1)**2)
print(distance)
# 5.5910642993977451
plunge = math.degrees(math.asin((z2-z1)/distance))
print(plunge)
# 1.0248287567800018 # the resulting dip_plunge is positive downward if z2 > z1
azimuth = math.degrees(math.atan2((x2-x1),(y2-y1)))
print(azimuth)
# -169.69515353123398 # = 360 + azimuth = 190.30484646876602 or 180+ azimuth = 10.304846468766016 over the range of 0 to 360°https://stackoverflow.com/questions/69506057
复制相似问题