代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoordinateTransform
{
/// <summary>
/// 像素(影像)坐标转换
/// </summary>
public class PixelCoordinateTransform
{
/// <summary>
/// 全景图像像素坐标转为空间直角坐标(半径为1的基础上推算)
/// </summary>
/// <param name="W"></param>
/// <param name="H"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public static Point3D PixelToSpaceRectangularCoordinate_r1(double W, double H, double x, double y)
{
double r = 1;
double fai_h = (Math.PI * (W - 2 * x)) / W;
double fai_gama = (Math.PI * (H - 2 * y)) / (2 * H);
double fai_h_ = fai_h * 180 / Math.PI;
double fai_gama_ = fai_gama * 180 / Math.PI;
double x1 = r * Math.Cos(fai_gama) * Math.Cos(fai_h);
double y1 = r * Math.Cos(fai_gama) * Math.Sin(fai_h);
double z1 = r * Math.Sin(fai_gama);
return new Point3D(x1, y1, z1);
}
}
}