7

以下のアルゴリズムでは、投影面が赤道 (正距円筒図法の中心線) に接している場合、投影された画像は直線的に見えます。

直線的なイメージ

しかし、投影面が傾いていると (py0 != panorama.height/2)、線が歪んでしまいます。

ゆがんだ画像

以下のアルゴリズムの最後の 2 つの「線」は、宛先平面の中心線が正距円筒イメージの中心線と同じレベルにない場合に px および/または py を調整するために、「修正」する必要があります。

  // u,v,w :
  //     Normalized 3D coordinates of the destination pixel

  // elevation, azimuth:
  //     Angles between the origin (sphere center) and the destination pixel

  // px0, py0 :
  //     2D coordinates in the equirectangular image for the
  //     the destination plane center (long*scale,lat*scale)

  // px, py:
  //     2D coordinates of the source pixel in the equirectangular image
  //     (long*scale,lat*scale)

  angularStep=2*PI/panorama.width;
  elevation=asin(v/sqrt(u*u+v*v+w*w));
  azimuth=-PI/2+atan2(w,u);
  px=px0+azimuth/angularStep;
  py=py0+elevation/angularStep;

各デスティネーション ピクセルの法線と球の間の交点 p を計算し、利用可能な C コードを使用してデカルト座標を経度/緯度に変換できます。

投影

しかし、投影面の中心が「球」と交差する経度/緯度 (px0,py0) を知っている正距円筒図法画像 (px,py) のソース ピクセル座標を調整することを含む、より簡単で時間がかからない方法があることを私は知っています。

助けていただけますか?

4

1 に答える 1

2

Webgl シェーダーhttp://mathworld.wolfram.com/GnomonicProjection.htmlのノモニック射影の式を使用して、これを機能させることができました。

            float angleOfView   

            float phi1          
            float lambda0     //centre of output projection

            float x = PI2*(vTextureCoord.s - 0.5) ;  //input texture coordinates, 
            float y = PI2*(vTextureCoord.t - 0.5 ); 

            float p = sqrt(x*x + y*y);

            float c = atan(p, angleOfView); 

            float phi = asin( cos(c)*sin(phi1) + y*sin(c)*cos(phi1)/p );

            float lambda = lambda0 + atan( x*sin(c), (p*cos(phi1)*cos(c) - y*sin(phi1)*sin(c)));

            vec2 tc = vec2((lambda /(PI*2.0) + 0.5, (phi/PI) + 0.5); //reprojected texture coordinates 

            vec4 texSample  =  texture2D(tEqui, tc); //sample using new coordinates
于 2016-08-18T12:35:28.707 に答える