<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculate destination point given distance and bearing from start point in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/calculate-destination-point-given-distance-and/m-p/1258752#M11684</link>
    <description>&lt;P&gt;Hello there. I would recommend utilizing the&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/api-reference/api/netwin/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Geometry.GeometryEngine.MoveGeodetic.html" target="_self"&gt;MoveGeodetic&lt;/A&gt;&amp;nbsp;method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static MapPoint CalculateCoord(MapPoint mapPoint, double distance, GeodeticCurveType curveType, double bearing = 0)
        {
            return GeometryEngine.MoveGeodetic(new List&amp;lt;MapPoint&amp;gt;() { mapPoint }, distance, LinearUnits.Meters, bearing, AngularUnits.Degrees, curveType)[0];
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The mapPoint parameter would need a spatial reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In terms of precision - your bearing changes over long distance. So it isn't as simple as bearing + 180 to go from end point to start point.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2023 19:14:24 GMT</pubDate>
    <dc:creator>williambohrmann3</dc:creator>
    <dc:date>2023-02-16T19:14:24Z</dc:date>
    <item>
      <title>Calculate destination point given distance and bearing from start point</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/calculate-destination-point-given-distance-and/m-p/1258442#M11682</link>
      <description>&lt;P&gt;I'm using .Net Maps SDK for a WPF application.&lt;BR /&gt;I need to calculate a destination point given a distance and bearing from another start point.&lt;/P&gt;&lt;P&gt;Now I'm using the following method to calculate the destination point.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void demo()
        {
            MapPoint startPoint = new MapPoint(-7.123456789, 33.123456789);
            double bearingDegreesFromNorth = 33;
            double distanceMeters = 54321;
            // Firts calculate endPoint using startPoint, distance, and bearing.
            MapPoint endPoint = CalculateCoordinatesWithOffset(startPoint, distanceMeters, 0, bearingDegreesFromNorth);
            // Now with endPoint I calculate again startPoint using the same distance but reverse bearing.
            MapPoint startPointAgain = CalculateCoordinatesWithOffset(endPoint, distanceMeters, 0, bearingDegreesFromNorth + 180);

            // Result endPoint:{MapPoint[X=-6.80405266951967, Y=33.5330337977028]}
            // Result startPointAgain: {MapPoint[X=-7.12195591588525, Y=33.1226432181444]}

        }
public static MapPoint CalculateCoordinatesWithOffset(MapPoint mapPoint, double xOffset, double yOffset, double bearing = 0)
        {
            double distance = Math.Sqrt(Math.Pow(xOffset, 2) + Math.Pow(yOffset, 2));
            // Convert to radians
            double latRad = mapPoint.Y * Math.PI / 180.0;
            double lonRad = mapPoint.X * Math.PI / 180.0;
            double bearingRad = Math.Atan2(yOffset, xOffset) + Conversion.DegToRadians(bearing);
            double s = distance * Math.PI / (180.0 * 60 * 1852);
            // Find the new latitude
            double endLat = Math.Asin(Math.Sin(latRad) * Math.Cos(s) + Math.Cos(latRad) * Math.Sin(s) * Math.Cos(bearingRad));
            // Then the new longitude
            double w = Math.Atan2(Math.Sin(bearingRad) * Math.Sin(s) * Math.Cos(latRad), Math.Cos(s) - Math.Sin(latRad) * Math.Sin(endLat));
            double endLon = lonRad + w;
            endLat = endLat * 180.0 / Math.PI;
            endLon = endLon * 180.0 / Math.PI;
            var result = new MapPoint(endLon, endLat);
            return result;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I try to calculate the start point using the same distance and the reverse bearing from the destination point, the start point does not coincide.&lt;/P&gt;&lt;P&gt;In the beginning, startPoint value is (-7.123456789, 33.123456789), but when I recalculated the value is [X=-7.12195591588525, Y=33.1226432181444]&lt;BR /&gt;Both points are similar, but the last decimals do not coincide.&lt;/P&gt;&lt;P&gt;What is the best way to do that? Is there any way to calculate a point given distance and bearing from the start point and then use the destination point, with the distance and the reverse bearing (bearing +-180º), to calculate the initial point?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 13:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/calculate-destination-point-given-distance-and/m-p/1258442#M11682</guid>
      <dc:creator>Jcontreras01</dc:creator>
      <dc:date>2023-02-15T13:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate destination point given distance and bearing from start point</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/calculate-destination-point-given-distance-and/m-p/1258752#M11684</link>
      <description>&lt;P&gt;Hello there. I would recommend utilizing the&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/api-reference/api/netwin/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Geometry.GeometryEngine.MoveGeodetic.html" target="_self"&gt;MoveGeodetic&lt;/A&gt;&amp;nbsp;method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static MapPoint CalculateCoord(MapPoint mapPoint, double distance, GeodeticCurveType curveType, double bearing = 0)
        {
            return GeometryEngine.MoveGeodetic(new List&amp;lt;MapPoint&amp;gt;() { mapPoint }, distance, LinearUnits.Meters, bearing, AngularUnits.Degrees, curveType)[0];
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The mapPoint parameter would need a spatial reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In terms of precision - your bearing changes over long distance. So it isn't as simple as bearing + 180 to go from end point to start point.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 19:14:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/calculate-destination-point-given-distance-and/m-p/1258752#M11684</guid>
      <dc:creator>williambohrmann3</dc:creator>
      <dc:date>2023-02-16T19:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate destination point given distance and bearing from start point</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/calculate-destination-point-given-distance-and/m-p/1259766#M11704</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/655350"&gt;@williambohrmann3&lt;/a&gt;, that work to me using&amp;nbsp; GeodeticCurveType.Loxodrome.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 06:21:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/calculate-destination-point-given-distance-and/m-p/1259766#M11704</guid>
      <dc:creator>Jcontreras01</dc:creator>
      <dc:date>2023-02-20T06:21:03Z</dc:date>
    </item>
  </channel>
</rss>

