将球体从coord1旋转到coord2,coord3将在哪里?

时间:2012-03-28 14:45:11

标签: geometry distance azimuth great-circle

我在球体上有三个坐标(lat,lon)。如果你将整个球体从coord1旋转到coord2,那么coord3现在将在哪里?

我一直在使用Great Circle(http://www.koders.com/python/fid0A930D7924AE856342437CA1F5A9A3EC0CAEACE2.aspx?s=coastline)在Python中尝试这一点,但我创建了奇怪的结果,因为新计算的所有点组合在一起赤道。那必须与我假设的方位角计算有关吗?

有没有人知道如何正确计算?

提前致谢!

修改

我找到了以下内容:http://www.uwgb.edu/dutchs/mathalgo/sphere0.htm

我想我现在需要从笛卡尔坐标(和0,0,0)中的两个点计算旋转轴和旋转角度?我想这一定非常简单,与定义平面和确定法线有关吗?有人可能知道我在哪里可以找到所需的方程吗?

编辑2

Coord1和coord2成了一个很棒的圈子。有没有一种简单的方法可以找到球体上大圆法线轴的位置?

编辑3

看起来我能够解决它;) http://articles.adsabs.harvard.edu//full/1953Metic...1...39L/0000039.000.html成功了。

2 个答案:

答案 0 :(得分:0)

好的,我不知道确切的公式,我相信这将是一个简单的矩阵乘法,但是如果没有它,你就可以弄明白。

  1. 变换坐标,使旋转的极点分别为90,0和-90,0,这样从coord1到coord2的旋转线就会在“赤道”上(这应该是简单的) delta lat,delta long)

  2. 然后旋转只是经度变化,您可以将相同的delta长度应用于任何coord3,然后简单地转换回原始坐标(通过负delta lat和负delta delta)

  3. 1& 2几乎就是你的矩阵会做的 - 如果你能找出每一步的矩阵,你可以将它们相乘并得到最终的矩阵

答案 1 :(得分:0)

使用Visual Python我想我现在已经解决了它:

# Rotation first described for geo purposes: http://www.uwgb.edu/dutchs/mathalgo/sphere0.htm
# http://stackoverflow.com/questions/6802577/python-rotation-of-3d-vector
# http://vpython.org/
from visual import *
from math import *
import sys

def ll2cart(lon,lat):
    # http://rbrundritt.wordpress.com/2008/10/14/conversion-between-spherical-and-cartesian-coordinates-systems/
    x = cos(lat) * cos(lon)
    y = cos(lat) * sin(lon)
    z = sin(lat)
    return x,y,z

def cart2ll(x,y,z):
    # http://rbrundritt.wordpress.com/2008/10/14/conversion-between-spherical-and-cartesian-coordinates-systems/
    r = sqrt((x**2) + (y**2) + (z**2))
    lat = asin(z/r)
    lon = atan2(y, x)
    return lon, lat

def distance(lon1, lat1, lon2, lat2):
    # http://code.activestate.com/recipes/576779-calculating-distance-between-two-geographic-points/
    # http://en.wikipedia.org/wiki/Haversine_formula
    dlat = lat2 - lat1
    dlon = lon2 - lon1
    q = sin(dlat/2)**2 + (cos(lat1) * cos(lat2) * (sin(dlon/2)**2))
    return 2 * atan2(sqrt(q), sqrt(1-q))

if len(sys.argv) == 1:
    sys.exit()
else:
    csv = sys.argv[1]

    # Points A and B defining the rotation:
    LonA = radians(float(sys.argv[2]))
    LatA = radians(float(sys.argv[3]))
    LonB = radians(float(sys.argv[4]))
    LatB = radians(float(sys.argv[5]))

# A and B are both vectors
# The crossproduct AxB is the rotation pole vector P:
Ax, Ay, Az = ll2cart(LonA, LatA)
Bx, By, Bz = ll2cart(LonB, LatB)
A = vector(Ax,Ay,Az)
B = vector(Bx,By,Bz)
P = cross(A,B)
Px,Py,Pz = P
LonP, LatP = cart2ll(Px,Py,Pz)

# The Rotation Angle in radians:
# http://code.activestate.com/recipes/576779-calculating-distance-between-two-geographic-points/
# http://en.wikipedia.org/wiki/Haversine_formula
RotAngle = distance(LonA,LatA,LonB,LatB)

f = open(csv,"r")
o = open(csv[:-4] + "_translated.csv","w")
o.write(f.readline())
for line in f:
    (lon, lat) = line.strip().split(",")

    # Point C which will be translated:
    LonC = radians(float(lon))
    LatC = radians(float(lat))

    # Point C in Cartesian coordinates:
    Cx,Cy,Cz = ll2cart(LonC,LatC)
    C = vector(Cx,Cy,Cz)

    # C rotated to D:
    D = rotate(C,RotAngle,P)
    Dx,Dy,Dz = D
    LonD,LatD = cart2ll(Dx,Dy,Dz)

    o.write(str(degrees(LonD)) + "," + str(degrees(LatD)) + "\n")