将球体从coord1旋转到coord2,coord3会在哪里? [英] Rotate a sphere from coord1 to coord2, where will coord3 be?

查看:193
本文介绍了将球体从coord1旋转到coord2,coord3会在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



有人可能知道如何正确计算这个值吗?

编辑



我发现以下内容: 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 做了诀窍。使用Visual Python我认为我现在已经解决了它:

<$ p $ <$ p

解决方案

p> #为了地理目的而首先描述的旋转: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))

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

#定义旋转的点A和B:
LonA =弧度( (float(sys.argv [4]))
float LatB = r adians(float(sys.argv [5]))

#A和B都是矢量
#交叉积AxB是旋转极点矢量P:
Ax,Ay, Az = ll2cart(LonA,LatA)
Bx,By,Bz = ll2cart(LonB,LatB)
A =矢量(Ax,Ay,Az)
B =矢量(Bx,By, Bz)
P = cross(A,B)
Px,Py,Pz = P
LonP,LatP = cart2ll(Px,Py,Pz)

#以弧度表示的旋转角度:
#http://code.activestate.com/recipes/576779-calculating-distance-between-two-geographic-points/
#http://en.wikipedia。 org / wiki / Haversine_formula
RotAngle =距离(LonA,LatA,LonB,LatB)

f = open(csv,r)
o = open(csv [: - 4 ($)
(lon,lat)= line.strip() .split(,)

#将被转换的点C:
LonC =弧度(float(lon))
LatC =弧度(float(lat))

#笛卡尔坐标点C:
Cx,Cy,Cz = ll2cart(LonC,LatC)
C =矢量(Cx,Cy,Cz)

#C旋转到D:
D =旋转(C,RotAngle,P)
Dx,Dy,Dz = D
LonD,LatD = cart2ll(Dx,Dy,Dz)

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


I have three coordinates (lat,lon) on a sphere. If you would rotate the whole sphere from coord1 to coord2, where will coord3 now be located?

I've been trying this out in Python using Great Circle (http://www.koders.com/python/fid0A930D7924AE856342437CA1F5A9A3EC0CAEACE2.aspx?s=coastline) but I create strange results as the newly calculated points all group together at the equator. That must have something to do with the azimuth calculation I assume?

Does anyone maybe know how to calculate this correctly?

Thanks in advance!

EDIT

I found the following: http://www.uwgb.edu/dutchs/mathalgo/sphere0.htm

I guess I now need to calculate the rotation axis and the rotation angle from the two points in cartesian coords (and 0,0,0)? I guess this must be very simple, something to do with defining a plane and determining the normal line? Does someone maybe know where I can find the needed equations?

EDIT 2

Coord1 and coord2 make a great circle. Is there an easy way to find the location of the great circle normal axis on the sphere?

EDIT 3

Looks like I was able to solve it ;) http://articles.adsabs.harvard.edu//full/1953Metic...1...39L/0000039.000.html did the trick.

解决方案

Using Visual Python I think I now have solved it:

# 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")

这篇关于将球体从coord1旋转到coord2,coord3会在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆