メルカトル図法を使用して、次の画像を球に投影しようとしています:
私はここから式を使用してここまで来ました:2Dグリッドポイント(x、y)を3Dポイント(x、y、z)として球にマッピングする方法
私のコードは、(X、Y) から座標を生成する次のとおりです。
public void generateSphericalCoords(){
int R = 400; // Image Radius
int S = 400; // Sphere Radius
float longitude = (float)(this.x)/R;
float latitude = (float) (2*Math.atan(Math.exp((double)(this.y)/R)) - Math.PI/2);
sphericalX = (int) (S*Math.cos(latitude) * Math.cos(longitude)) + 300;
sphericalY = (int) (S*Math.cos(latitude) * Math.sin(longitude)) + 300;
sphericalZ = (int) (S*Math.sin(longitude));
//System.out.println(sphericalX + " " + sphericalY + " " + sphericalZ);
}
ただし、完全な球を取得する代わりに、次のようになります。
私は何を間違っていますか?どんな助けでも大歓迎です。
編集:
次の式にたどり着きました。
float longitude = (float) ((float)(Math.PI*this.x)/R - Math.PI/2);
float latitude = (float) (Math.PI*2*Math.atan(Math.exp((float)(this.y)/R)));
sphericalX = (int) (S*Math.cos(latitude) * Math.cos(longitude)) + 300;
sphericalY = (int) (S*Math.cos(latitude) * Math.sin(longitude)) + 300;
sphericalZ = (int) (S*Math.sin(longitude));
ただし、次のように、外側の端に沿って奇妙なリングができました。