<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — distance & altitude]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1226</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1226&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in distance & altitude.]]></description>
		<lastBuildDate>Tue, 11 Jun 2019 20:00:58 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: distance & altitude]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5141#p5141</link>
			<description><![CDATA[<p>Hello.</p><p>This method is completely wrong.<br />Thank you for reporting this.<br />This method is marked as obsolete and incorrect.</p><p>The new version of the method (the next version will contain this):<br /></p><div class="codebox"><pre><code>public static double DistanceBetweenPoints(double x1, double y1, double a1, double x2, double y2, double a2)
{
    double r = R + Math.Min(a1, a2);
    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));
    double dx = (sizeX1 + sizeX2) / 2.0;
    double dy = r * Math.Acos(scfY * sctY + ccfY * cctY);
    if (double.IsNaN(dx)) dx = 0;
    if (double.IsNaN(dy)) dy = 0;
    double d = Math.Sqrt(dx * dx + dy * dy);
    double hd = Math.Abs(a1 - a2);
    return Math.Sqrt(d * d + hd * hd);
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 11 Jun 2019 20:00:58 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5141#p5141</guid>
		</item>
		<item>
			<title><![CDATA[distance & altitude]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5140#p5140</link>
			<description><![CDATA[<p>Hi</p><p>I want to measure the exact distance between to points.</p><p>Those two points are defined by a latitude, longitude, and altitude.</p><p>OnlineMapsUtils provide two functions : one that doesn&#039;t take the altitude into account, and one that does.</p><p>However when i try to compare the result of the two method, i get roughly the same result. See the example below :</p><p><a href="https://gph.is/g/a9pOAOJ">https://gph.is/g/a9pOAOJ</a></p><div class="codebox"><pre><code> //GpsCoordinates is lat, lng, and altitude in meters
        GpsCoordinates A = new GpsCoordinates(48.332300, -70.992836, 0);
        GpsCoordinates B = new GpsCoordinates(48.332200, -70.992836, 0.2); //small difference in latitude, 200 meters difference in altitude

        double dx, dy;
        OnlineMapsUtils.DistanceBetweenPoints(A.Longitude, A.Latitude, B.Longitude, B.Latitude, out dx, out dy);

        Debug.Log(&quot;distance between A and B (no altitude taken into account) : &quot; + Math.Sqrt(dx * dx + dy * dy) * 1000 + &quot; m&quot;);

        OnlineMapsUtils.DistanceBetweenPoints(A.Longitude, A.Latitude,(float)A.Altitude, B.Longitude, B.Latitude,(float)B.Altitude, out dx, out dy);

        Debug.Log(&quot;distance between A and B (altitude should matter in the result): &quot; + Math.Sqrt(dx * dx + dy * dy) * 1000 + &quot; m&quot;);
        
        //representation of the two points on the map :

        string label = &quot;PointA&quot;;
        OnlineMapsMarker3D marker = OnlineMapsMarker3DManager.instance.Create(A.Longitude, A.Latitude, prefab);
        marker.prefab.name = label;
        marker.tags.Add(label);
        marker.altitudeType = OnlineMapsAltitudeType.relative;
        marker.altitude = (float)A.Altitude*1000;

        label = &quot;PointB&quot;;
        OnlineMapsMarker3D marker2 = OnlineMapsMarker3DManager.instance.Create(B.Longitude,B.Latitude, prefab);
        marker2.prefab.name = label;
        marker2.tags.Add(label);
        marker2.altitudeType = OnlineMapsAltitudeType.relative;
        marker2.altitude = (float)B.Altitude*1000;</code></pre></div><p>This is what i get : <br /><span class="postimg"><img src="https://i.ibb.co/r3rV9PT/distance-And-Altitude.jpg" alt="https://i.ibb.co/r3rV9PT/distance-And-Altitude.jpg" /></span></p><p>I was expecting the distance to be 200 meters and more. How can i get the exact distance between my two points ?</p>]]></description>
			<author><![CDATA[null@example.com (Thibault)]]></author>
			<pubDate>Tue, 11 Jun 2019 19:22:06 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5140#p5140</guid>
		</item>
	</channel>
</rss>
