[英]How to rotate coordinates on a sphere by 90 degrees?
我在球體上有許多坐標(代表 EEG 帽上的電極)。 我在笛卡爾坐標和球坐標中都有它們的位置。
chan X Y Z long lat sph_radius
1 Fp1 8.08e+01 2.61e+01 -4.00 17.9 -2.70 85
2 Fp2 8.08e+01 -2.61e+01 -4.00 -17.9 -2.70 85
3 F3 5.76e+01 4.82e+01 39.90 39.9 28.00 85
4 F4 5.76e+01 -4.81e+01 39.90 -39.9 28.00 85
5 C3 3.87e-15 6.32e+01 56.90 90.0 42.00 85
6 C4 3.87e-15 -6.32e+01 56.90 -90.0 42.00 85
7 P3 -5.76e+01 4.82e+01 39.90 140.0 28.00 85
8 P4 -5.76e+01 -4.81e+01 39.90 -140.0 28.00 85
9 O1 -8.08e+01 2.61e+01 -4.00 162.0 -2.70 85
10 O2 -8.08e+01 -2.61e+01 -4.00 -162.0 -2.70 85
11 F7 4.99e+01 6.84e+01 -7.49 53.9 -5.06 85
12 F8 4.99e+01 -6.84e+01 -7.49 -53.9 -5.05 85
13 T3 5.18e-15 8.45e+01 -8.85 90.0 -5.97 85
14 T4 5.18e-15 -8.45e+01 -8.85 -90.0 -5.97 85
15 T5 -4.99e+01 6.84e+01 -7.49 126.0 -5.06 85
16 T6 -4.99e+01 -6.84e+01 -7.49 -126.0 -5.05 85
17 Fz 6.07e+01 0.00e+00 59.50 0.0 44.40 85
18 Cz 5.20e-15 0.00e+00 85.00 0.0 90.00 85
19 Pz -6.07e+01 -7.44e-15 59.50 -180.0 44.40 85
我想將所有電極在 z 軸上逆時針/向下旋轉 90 度,以便現在 (long = 0, lat = 90) 的電極 Cz 變為 (long = 0, lat = 0)。 我不在乎旋轉是在笛卡爾坐標還是球坐標上執行的,因為我可以輕松地將一個轉換為另一個。
我試圖在這個網站上找到這個問題的解決方案,但他們都不知所措。 如果有人能提供一個簡單的 R 公式來完成此輪換,我將不勝感激。
使用您的緯度/經度坐標(以 data.table 表示法)
# 1st we deal with cases where lat>0,
# i.e. rotation does not entail passing through the south pole
dt[, long.rot := long] # longitude stay in the same plane as we rotate
dt[, lat.rot := lat-90] # latitude moves south 90 degrees
# now we deal with case that were already in the southern hemisphere,
# which will rotate through the south pole and northwards on the opposite longitude
dt[lat < 0, long.rot := -sign(long)*(180-abs(long)) ]
dt[lat < 0, lat.rot := 180+lat.rot ]
但是,警告一句:指向或靠近北極的行為可能會出乎意料。 嚴格來說,極點的經度是未定義的,應指定為 NA。 在這種情況下,旋轉的經度將為 NA,因為“旋轉”點可能位於赤道上的任何未指定位置。
對於靠近極點的點,雖然經度在數學上有很好的定義,但位置的小不確定性將被放大為繞赤道旋轉點位置的大不確定性
您必須考慮到 1 度 N/S 與 1 度 W/E 不同,這取決於緯度。
考慮赤道的 1 度 W/E 等於 X,而在極點,它是 0。因此,1 度經度等於 X * Cos(緯度)。
所以這是您正在尋找的轉換:
double x = pivot.lng; // Pivot coordinate
double y = pivot.lat; // Pivot coordinate
double cx = ((location.lng - pivot.lng) * 1852 * 60); // Horizontal distance in metres to pivot
double cy = ((location.lat - pivot.lat) * 1852 * 60 * Math.Cos(location.lat * Math.PI / 180); // Vertical distance in metres to pivot
double theta = -rotation * Math.PI / 180; // Angle, in radians
double x1 = cx * Math.Cos(theta) - cy * Math.Sin(theta); // Rotated cx
double y1 = cx * Math.Sin(theta) + cy * Math.Cos(theta); // Rotated cy
location.lat = y + (y1 / 1852 / 60); // Rotated latitude, from metres to degrees
location.lng = x + (x1 / 1852 / 60 / Math.Cos(y * Math.PI / 180)); // Rotated longitude, from metres to degrees
請注意,這仍然是近似值,因為如果從樞軸點到您要旋轉的點的緯度距離太大,則會出現一些偽影。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.