生成球面弧坐标

时间:2014-04-03 02:54:08

标签: c++ math coordinates computational-geometry

我想生成一个球形(地球)坐标矢量,该矢量将绘制给定中心位置(经度纬度),半径(以米为单位),方位角和角度宽度(以弧度表示)的弧。

我的代码:

double left = azimuth - width * .5;
double right = azimuth + width * .5;
double angleStep = 0.05;
std::vector<double> arcPointsX, arcPointsY;

for (double f = left; f <= right; f += angleStep) {   
    arcPointsX.push_back(x + radius * (double)cos(f));
    arcPointsY.push_back(y + radius * (double)sin(f));
}

这会产生弧线,但是当我绘制弧线时,这些弧线并没有朝向正确的方向。

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

原来问题是我犯了罪/反过来。使用它可以得到正确的弧度:

arcPointsX.push_back(x + radius * (double)sin(f));
arcPointsY.push_back(y + radius * (double)cos(f));
相关问题