座標変換1

右を経度0度, 正面を90度, 左を180度, 背後を270度とし, 真上を緯度+90度, 下を-90度とする.

1.ヨー

 OldPhiは, 変換前の緯度.

 OldThetaは, 変換前の経度.

 Yawは, 変化量. プラスで右を向く.(視界が左に行く)

 Pitchは, 見下ろす角度. プラスで下を向く(視界が上に行く.)

 NewThetaは, 変換後の経度.

 NewPhiは, 天体の, 座標変換後の緯度.

 NewTheta=OldTheta+Yaw

2.ピッチ

 OldPhi==90の場合, NewPhi=90-Pitch and NewTheta=270

 OldPhi==-90の場合, NewPhi=-90+Pitch and NewTheta=90

OldTheta==90の場合,

  OldPhi+Pitch<90ならNewTheta=90

OldPhi+Pitch==90ならNewTheta=null

OldPhi+Pitch>90NewTheta=270

 OldTheta==270の場合,

  OldPhi-Pitch<-90ならNewTheta=90

OldPhi-Pitch==-90ならNewTheta=null

OldPhi-Pitch>-90ならNewTheta=270

それ以外の場合,

A=cos(OldPhi)*cos(OldTheta)

B=cos(OldPhi)*sin(OldTheta)*cos(Pitch)-sin(OldPhi)*sin(Pitch)

C=cos(OldPhi)*sin(OldTheta)*sin(Pitch)+sin(OldPhi)*cos(Pitch)

NewPhi=asin(C)

 A>0の場合, NewTheta=atan(B/A)

  A<0の場合, NewTheta=atan(B/A)+180

3.ロール

 まず90度ヨーしてピッチしてから逆方向に90度ヨーします.

4.ワープ

Javaプログラム

import java.io.*;
class GeocentricToHeliocentric
{
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("地球から見た惑星の位置を、太陽から見た位置に変換します。");

System.out.println("地球から見た惑星の黄経は? (度)");
String str1 = br.readLine();
double OldThetadeg = Double.parseDouble(str1);

System.out.println("地球から見た惑星の黄経は? (分)");
String str2 = br.readLine();
double OldThetamin = Double.parseDouble(str2);

System.out.println("地球から見た惑星の黄経は? (秒)");
String str3 = br.readLine();
double OldThetasec = Double.parseDouble(str3);

double OldTheta=OldThetadeg+OldThetamin/60+OldThetasec/3600;

System.out.println("地球から見た惑星の黄緯は? (度)");
String str4 = br.readLine();
double OldBdeg = Double.parseDouble(str4);

System.out.println("地球から見た惑星の黄緯は? (分)");
String str5 = br.readLine();
double OldBmin = Double.parseDouble(str5);

System.out.println("地球から見た惑星の黄緯は? (秒)");
String str6 = br.readLine();
double OldBsec = Double.parseDouble(str6);

if (OldBdeg<0){OldBmin=OldBmin*-1;}
if (OldBdeg<0){OldBsec=OldBsec*-1;}

double OldB=OldBdeg+OldBmin/60+OldBsec/3600;
double OldPhi=(OldB-90)*-1;

System.out.println("地球から見た惑星の距離は? (天文)");
String str7 = br.readLine();
double OldR = Double.parseDouble(str7);

OldTheta=Math.toRadians(OldTheta);
OldPhi=Math.toRadians(OldPhi);

System.out.println("地球から見た太陽の黄経は? (度)");
String str8 = br.readLine();
double GoalThetadeg = Double.parseDouble(str8);

System.out.println("地球から見た太陽の黄経は? (分)");
String str9 = br.readLine();
double GoalThetamin = Double.parseDouble(str9);

System.out.println("地球から見た太陽の黄経は? (秒)");
String str10 = br.readLine();
double GoalThetasec = Double.parseDouble(str10);

double GoalTheta=GoalThetadeg+GoalThetamin/60+GoalThetasec/3600;

System.out.println("地球から見た太陽の黄緯は? (度)");
String str11 = br.readLine();
double GoalBdeg = Double.parseDouble(str11);

System.out.println("地球から見た太陽の黄緯は? (分)");
String str12 = br.readLine();
double GoalBmin = Double.parseDouble(str12);

System.out.println("地球から見た太陽の黄緯は? (秒)");
String str13 = br.readLine();
double GoalBsec = Double.parseDouble(str13);

if (GoalBdeg<0){GoalBmin=GoalBmin*-1;}
if (GoalBdeg<0){GoalBsec=GoalBsec*-1;}

double GoalB=GoalBdeg+GoalBmin/60+GoalBsec/3600;
double GoalPhi=(GoalB-90)*-1;

System.out.println("地球から見た太陽の距離は? (天文)");
String str14 = br.readLine();
double GoalR = Double.parseDouble(str14);

GoalTheta=Math.toRadians(GoalTheta);
GoalPhi=Math.toRadians(GoalPhi);

double OldX=OldR*Math.sin(OldPhi)*Math.cos(OldTheta);
double GoalX=GoalR*Math.sin(GoalPhi)*Math.cos(GoalTheta);

double OldY=OldR*Math.sin(OldPhi)*Math.sin(OldTheta);
double GoalY=GoalR*Math.sin(GoalPhi)*Math.sin(GoalTheta);

double OldZ=OldR*Math.cos(OldPhi);
double GoalZ=GoalR*Math.cos(GoalPhi);

double NewX=OldX-GoalX;
double NewY=OldY-GoalY;
double NewZ=OldZ-GoalZ;

double NewR=Math.sqrt(Math.pow(NewX,2)+Math.pow(NewY,2)+Math.pow(NewZ,2));
double NewTheta=Math.atan2(NewY,NewX);
double NewPhi=Math.atan2(Math.hypot(NewX,NewY),NewZ);

NewPhi=Math.toDegrees(NewPhi);
double NewB=90-NewPhi;
NewTheta=Math.toDegrees(NewTheta);
if(NewTheta<0){NewTheta=NewTheta+360;}

double NewThetamin = (NewTheta * 60) % 60;
double NewThetasec = (NewThetamin * 60) % 60;

double NewBmin = (NewB * 60) % 60;
double NewBsec = (NewBmin * 60) % 60;

System.out.println("太陽から見た惑星の黄経は");
System.out.print(NewTheta);
System.out.println("度");
int NewThetadeg = (int)NewTheta;
System.out.print(NewThetadeg);
System.out.print("度");
System.out.print(NewThetamin);
System.out.println("分");
System.out.print(NewThetadeg);
System.out.print("度");
int NewThetamini= (int)NewThetamin;
System.out.print(NewThetamini);
System.out.print("分");
System.out.print(NewThetasec);
System.out.println("秒");

System.out.println("太陽から見た惑星の黄緯は");
System.out.print(NewB);
System.out.println("度");
int NewBdeg = (int)NewB;
System.out.print(NewBdeg);
System.out.print("度");
System.out.print(NewBmin);
System.out.println("分");
System.out.print(NewBdeg);
System.out.print("度");
int NewBmini= (int)NewBmin;
System.out.print(NewBmini);
System.out.print("分");
System.out.print(NewBsec);
System.out.println("秒");

System.out.println("太陽から見た惑星の距離は");
System.out.print(NewR);
System.out.println("天文");
System.out.println("です。");
}
}

Cプログラム

#include<iostream.h>
void main(void)
{
long double OldBdeg, OldBmin, OldBsec;
long double OldThetadeg, OldThetamin, OldThetasec;
long double OldR;

cout<<"地球から見た惑星の位置を、太陽から見た位置に変換します。\n";
cout<<"地球から見た惑星の黄経は? (度)\n";
cin>>OldThetadeg;
cout<<"地球から見た惑星の黄経は? (分)\n";
cin>>OldThetamin;
cout<<"地球から見た惑星の黄経は? (秒)\n";
cin>>OldThetasec;
long double OldTheta=OldThetadeg+OldThetamin/60+OldThetasec/3600;

cout<<"地球から見た惑星の黄緯は? (度)\n";
cin>>OldBdeg;
cout<<"地球から見た惑星の黄緯は? (分)\n";
cin>>OldBmin;
cout<<"地球から見た惑星の黄緯は? (秒)\n";
cin>>OldBsec;
if (OldBdeg<0){OldBmin=OldBmin*-1;}
if (OldBdeg<0){OldBsec=OldBsec*-1;}
long double OldB=OldBdeg+OldBmin/60+OldBsec/3600;
long double OldPhi=(OldB-90)*-1;

cout<<"地球から見た惑星の距離は? (天文)\n";
cin>>OldR;

OldTheta=OldTheta*3.141592653589793238462643383279502884197169399375105820974944/180;
OldPhi=OldPhi*3.141592653589793238462643383279502884197169399375105820974944/180;

long double GoalBdeg, GoalBmin, GoalBsec;
long double GoalThetadeg, GoalThetamin, GoalThetasec;
long double GoalR;

cout<<"地球から見た太陽の黄経は? (度)\n";
cin>>GoalThetadeg;
cout<<"地球から見た太陽の黄経は? (分)\n";
cin>>GoalThetamin;
cout<<"地球から見た太陽の黄経は? (秒)\n";
cin>>GoalThetasec;
long double GoalTheta=GoalThetadeg+GoalThetamin/60+GoalThetasec/3600;

cout<<"地球から見た太陽の黄緯は? (度)\n";
cin>>GoalBdeg;
cout<<"地球から見た太陽の黄緯は? (分)\n";
cin>>GoalBmin;
cout<<"地球から見た太陽の黄緯は? (秒)\n";
cin>>GoalBsec;
if (GoalBdeg<0){GoalBmin=GoalBmin*-1;}
if (GoalBdeg<0){GoalBsec=GoalBsec*-1;}
long double GoalB=GoalBdeg+GoalBmin/60+GoalBsec/3600;
long double GoalPhi=(GoalB-90)*-1;

cout<<"地球から見た太陽の距離は? (天文)\n";
cin>>GoalR;

GoalTheta=GoalTheta*3.141592653589793238462643383279502884197169399375105820974944/180;
GoalPhi=GoalPhi*3.141592653589793238462643383279502884197169399375105820974944/180;

long double OldX=OldR*sin(OldPhi)*cos(OldTheta);
long double GoalX=GoalR*sin(GoalPhi)*cos(GoalTheta);

long double OldY=OldR*sin(OldPhi)*sin(OldTheta);
long double GoalY=GoalR*sin(GoalPhi)*sin(GoalTheta);

long double OldZ=OldR*cos(OldPhi);
long double GoalZ=GoalR*cos(GoalPhi);

long double NewX=OldX-GoalX;
long double NewY=OldY-GoalY;
long double NewZ=OldZ-GoalZ;

long double NewR=sqrt(pow(NewX,2)+pow(NewY,2)+pow(NewZ,2));
long double NewTheta=atan2(NewY,NewX);
long double NewPhi=atan2(hypot(NewX,NewY),NewZ);

NewPhi=NewPhi*180/3.141592653589793238462643383279502884197169399375105820974944;
long double NewB=90-NewPhi;
NewTheta=NewTheta*180/3.141592653589793238462643383279502884197169399375105820974944;
if(NewTheta<0){NewTheta=NewTheta+360;}

cout.precision(100);
cout<<"太陽から見た惑星の黄経は\n";
cout<<NewTheta;
cout<<"度\n";
long NewThetadeg=int(NewTheta);
long double NewThetamin=(NewTheta-NewThetadeg)*60;
long NewThetamini=int(NewThetamin);
long double NewThetasec=(NewThetamin-NewThetamini)*60;
cout<<NewThetadeg;
cout<<"度";
cout<<NewThetamin;
cout<<"分\n";
cout<<NewThetadeg;
cout<<"度";
cout<<NewThetamini;
cout<<"分";
cout<<NewThetasec;
cout<<"秒\n";
cout<<"\n";

cout<<"太陽から見た惑星の黄緯は\n";
cout<<NewB;
cout<<"度\n";
long NewBdeg=int(NewB);
long double NewBmin=(NewB-NewBdeg)*60;
NewBmin=abs(NewBmin);
long NewBmini=int(NewBmin);
long double NewBsec=(NewBmin-NewBmini)*60;
cout<<NewBdeg;
cout<<"度";
cout<<NewBmin;
cout<<"分\n";
cout<<NewBdeg;
cout<<"度";
cout<<NewBmini;
cout<<"分";
cout<<NewBsec;
cout<<"秒\n";
cout<<"\n";

cout<<"太陽から見た惑星の距離は\n";
cout<<NewR;
cout<<"天文\n";
cout<<"です。";
}

座標変換2

5.平面,

 OldTheta=protoOldTheta+moveTheta

 OldX=sin(OldTheta)*OldR

 OldY=cos(OldTheta)*OldR

GoalX=sin(GoalTheta)*GoalR

GoalY=cos(GoalTheta)*GoalR

 NewX=OldX-GoalX

 NewY=OldY-GoalY

 NewThetaは,

  NewX>0の場合

NewY>=0ならNewTheta=atan(NewY/NewX)

NewY<0ならNewTheta=180+atan(NewY/NewX)

  NewX==0の場合

NewY>0ならNewTheta=90

NewY==0ならNewTheta=null

NewY<0ならNewTheta=270

  NewX<0の場合

NewY>0ならNewTheta=360+atan(NewY/NewX)

NewY<=0ならNewThta=180+atan(NewY/NewX)

 NewR=(NewX^2+NewY^2)^0.5

よその星の空の再現の仕方. まず, 見たい天体と移動先の位置を極座標から平行座標に変換する. そして天体の平行座標から移動先の平行座標を引く. そしてその答えを極座標に変換する. すると移動先から見た天体の位置になります. C/C++やJavaにはatan2やhypotのような便利な関数があります. 経度を求める時はatan2(y,x)=theta, 緯度を求める時はatan2(z,hypot(y,x))=phi, そして距離を求める時はhypot(z,hypot(y,x))=rという関数を使います. hypot(x,y)はBASICの(X^2+Y^2)^0.5と同じ意味で, 中の二つの変数はどちらが先でもかまいません.

イスカンダル星の空[テレザート星の空]

           銀経(度) 銀緯(度) 距離(光年)

アンドロメダ銀河 359[001] -20[-22] 2,082,481[2,180,000]

大マゼラン雲   040[046] -32[-33]  12,000[ 144,355]

小マゼラン雲   231[234] -08[-40]  235,903[ 162,482]

銀河中心     231[358] +38[+33]  130,744[ 13,572]

太陽系       220[181] +33[+22]  148,000[ 20,000]

イスカンダル星は, 大マゼラン運にあると思ってましたが大マゼラン運が16万光年で, イスカンダル星が14万8千光年だとしたら, 自転軸の向きによっては天の海(大マゼラン雲)は1恒星日, 地の海は半ガミラス日周期で満ち引きするように見えるでしょう. 銀経がマイナスの星から見た銀河系の渦は, ナチスのマークと同じ向きです.

目次