Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在地图上逐点计算角度和距离_C#_Math - Fatal编程技术网

C# 在地图上逐点计算角度和距离

C# 在地图上逐点计算角度和距离,c#,math,C#,Math,我的任务是计算地图上的点。我有起点,角度和距离。我怎么做?我搜索了很多东西,发现了一些东西,但效果不好——我的意思是它没有计算出正确的点。谢谢,就这些 我的尝试: public Point MesPoint(double x1, double x2, double y1, double y2, double distance, double x) // X is the angle { double xEndP, yEndP; var angularDistance = dist

我的任务是计算地图上的点。我有起点,角度和距离。我怎么做?我搜索了很多东西,发现了一些东西,但效果不好——我的意思是它没有计算出正确的点。谢谢,就这些

我的尝试:

public Point MesPoint(double x1, double x2, double y1, double y2, double distance, double x) // X is the angle
{
    double xEndP, yEndP;
    var angularDistance = distance / c_EarthRadiusInKilometers; // angular distance in radians
    var lat = ToRadian(y2);
    var lon = ToRadian(x2);
    var angel = ToRadian(x);

    double latRadians = Math.Asin((Math.Sin(lat) * Math.Cos(angularDistance)) + (Math.Cos(lat) * Math.Sin(angularDistance) * Math.Cos(angel)));
    double lngRadians = Math.Atan2(
                            Math.Sin(angel) * Math.Sin(angularDistance) * Math.Cos(lat),
                            Math.Cos(angularDistance) - (Math.Sin(lat) * Math.Sin(latRadians)));


    double lon1 = (lon + lngRadians + Math.PI) % (2 * Math.PI) - Math.PI; // normalise to -180..+180º

    yEndP = ToDegrees(latRadians);
    xEndP = ToDegrees(lon1);
    return (new Point(xEndP, yEndP));
}

你只是想计算最后一点?这似乎更像是一个数学问题,而不是一个编程问题。我的意思是它没有计算正确的点。一些输出示例,预期的和实际的,可能有助于诊断问题。“我有起点、角度和到点的距离”。好的,这些参数中的哪一个对应于函数中的哪一个参数?x1,y1是什么,x2,y2是什么?另外,你是在平面上计算距离,还是需要在球体上进行计算?我的理解是,你试图计算一个点的纬度和经度,该点位于距离(x2,y2)的
处。但是你从来不使用(x1,y1),我也不知道你的角度
x
应该用来做什么。你能澄清一下吗?如果
x
是一个轴承,这可能就是你要找的: