<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Flight Distance between points]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=944&amp;type=atom" />
	<updated>2018-11-12T21:41:44Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=944</id>
		<entry>
			<title type="html"><![CDATA[Re: Flight Distance between points]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4217#p4217" />
			<content type="html"><![CDATA[<p>Thanks a lot <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Thibault]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=821</uri>
			</author>
			<updated>2018-11-12T21:41:44Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4217#p4217</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Flight Distance between points]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4210#p4210" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Something like that:<br /></p><div class="codebox"><pre><code>/// &lt;summary&gt;
/// The distance between two geographical coordinates with altitude.
/// &lt;/summary&gt;
/// &lt;param name=&quot;x1&quot;&gt;Longitude 1&lt;/param&gt;
/// &lt;param name=&quot;y1&quot;&gt;Latitude 1&lt;/param&gt;
/// &lt;param name=&quot;a1&quot;&gt;Altutude 1 (km)&lt;/param&gt;
/// &lt;param name=&quot;x2&quot;&gt;Longitude 2&lt;/param&gt;
/// &lt;param name=&quot;y2&quot;&gt;Latitude 2&lt;/param&gt;
/// &lt;param name=&quot;a2&quot;&gt;Altitude 2 (km)&lt;/param&gt;
/// &lt;param name=&quot;dx&quot;&gt;Distance longitude (km)&lt;/param&gt;
/// &lt;param name=&quot;dy&quot;&gt;Distance latitude (km)&lt;/param&gt;
public static void DistanceBetweenPoints(double x1, double y1, float a1, double x2, double y2, float a2, out double dx, out double dy)
{
    double r = 6371 + (a1 + a2) / 2;
    double Deg2Rad = Math.PI / 180;
    double scfY = Math.Sin(y1 * Deg2Rad);
    double sctY = Math.Sin(y2 * Deg2Rad);
    double ccfY = Math.Cos(y1 * Deg2Rad);
    double cctY = Math.Cos(y2 * Deg2Rad);
    double cX = Math.Cos((x1 - x2) * Deg2Rad);
    double sizeX1 = Math.Abs(r * Math.Acos(scfY * scfY + ccfY * ccfY * cX));
    double sizeX2 = Math.Abs(r * Math.Acos(sctY * sctY + cctY * cctY * cX));
    dx = (sizeX1 + sizeX2) / 2.0;
    dy = r * Math.Acos(scfY * sctY + ccfY * cctY);
    if (double.IsNaN(dy)) dy = 0;
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-11-12T18:02:31Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4210#p4210</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Flight Distance between points]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4209#p4209" />
			<content type="html"><![CDATA[<p>Hi</p><p>When using OnlineMapsUtils.DistanceBetweenPoint (<a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsUtils.html#a03c68a7ad2512d685e0383dd617a6d18">http://infinity-code.com/doxygen/online … dd617a6d18</a>)</p><p>To get the actual distance between the two point, sqrt(dx*dx+dy*dy) should give the correct value in km ?</p><br /><p>Now if i want the distance between two points, which are at different altitude:</p><p>OnlineMapsUtils.DistanceBetweenPoint give me the distance between those two point at ground 0, so i was planning to use a simple Pythagore formula to get the &quot;real&quot; distance.</p><p>But, if i&#039;m not mistaken, OnlineMapsUtils.DistanceBetweenPoint doesn&#039;t calculate a straight line lentgh but an arc (since the earth is not flat and we are using lat/lng )<br />So Pythagore doesn&#039;t seems like a correct way to go ? <br />How should i proceed to get a correct flight distance between two waypoints at different altitude ?</p>]]></content>
			<author>
				<name><![CDATA[Thibault]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=821</uri>
			</author>
			<updated>2018-11-12T15:28:40Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4209#p4209</id>
		</entry>
</feed>
