<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calculating The Bearing And Compass Rose Direction Between Two Latitude / Longitude Coordinates In PHP</title>
	<atom:link href="http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/</link>
	<description>ASP.NET, PHP, XML, JavaScript, DOM, Web geekery</description>
	<lastBuildDate>Mon, 02 Jan 2012 21:22:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Jonathan</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-317</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Mon, 24 Jan 2011 20:39:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-317</guid>
		<description>@Dan.  Agreed about tendency to cast clockwise but your fix is going the wrong &#039;direction&#039;  ?

On a 8 point compass, I want each of the 8 directions to cover a 360/8=45deg sector but I MAY want the 45deg sector for North, as a good example, starting at -22.5deg to +22.5deg, rather than 0 to 45deg? For a 16 point compass the sectors are 22.5 degs so the offset is -11.25 to +11.25deg.

so

$tmp = floor(($bearing - 11.25) / 22.5);</description>
		<content:encoded><![CDATA[<p>@Dan.  Agreed about tendency to cast clockwise but your fix is going the wrong &#8216;direction&#8217;  ?</p>
<p>On a 8 point compass, I want each of the 8 directions to cover a 360/8=45deg sector but I MAY want the 45deg sector for North, as a good example, starting at -22.5deg to +22.5deg, rather than 0 to 45deg? For a 16 point compass the sectors are 22.5 degs so the offset is -11.25 to +11.25deg.</p>
<p>so</p>
<p>$tmp = floor(($bearing &#8211; 11.25) / 22.5);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-316</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Fri, 19 Feb 2010 16:31:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-316</guid>
		<description>AMAZING! I&#039;ve modified one of your queries to add a calculated bearing field to query results. So I pass the lat/lon of an origin point into the query and all of the locations in the db come back with an extra bearing field (holding the calculated bearing between the origin point and each record&#039;s lat/lon).

Thank you Thank you!</description>
		<content:encoded><![CDATA[<p>AMAZING! I&#8217;ve modified one of your queries to add a calculated bearing field to query results. So I pass the lat/lon of an origin point into the query and all of the locations in the db come back with an extra bearing field (holding the calculated bearing between the origin point and each record&#8217;s lat/lon).</p>
<p>Thank you Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Richards</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-315</link>
		<dc:creator>Dan Richards</dc:creator>
		<pubDate>Mon, 15 Feb 2010 17:09:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-315</guid>
		<description>The following mod to the getCompassDirection function will correct the problem &quot;this function will tend to cast directions clockwise around the compass rose&quot;:

[php htmlscript=&quot;true&quot;]$tmp = floor(($bearing + 12.25) / 22.5);[/php]</description>
		<content:encoded><![CDATA[<p>The following mod to the getCompassDirection function will correct the problem &#8220;this function will tend to cast directions clockwise around the compass rose&#8221;:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">$tmp = floor(($bearing + 12.25) / 22.5);</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garth Powell</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-314</link>
		<dc:creator>Garth Powell</dc:creator>
		<pubDate>Mon, 04 Jan 2010 16:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-314</guid>
		<description>Okay, when I get to that point (which will be soon, I&#039;ll (most likely) send something from your wish list...in looking at the books and media, you&#039;re nicely diverse in what interests you...some of them I may want to get to read!

GAP</description>
		<content:encoded><![CDATA[<p>Okay, when I get to that point (which will be soon, I&#8217;ll (most likely) send something from your wish list&#8230;in looking at the books and media, you&#8217;re nicely diverse in what interests you&#8230;some of them I may want to get to read!</p>
<p>GAP</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-313</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Thu, 24 Dec 2009 15:39:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-313</guid>
		<description>@Garth: I am happy to assist you with your specific implementation in return for a purchase from my Amazon wish list. Click the &quot;&lt;a href=&quot;http://www.dougv.com/blog/need-more-help/&quot; rel=&quot;nofollow&quot;&gt;Need More Help Or Want To Say Thanks?&lt;/a&gt;&quot; link at the top of the page for more info.</description>
		<content:encoded><![CDATA[<p>@Garth: I am happy to assist you with your specific implementation in return for a purchase from my Amazon wish list. Click the &#8220;<a href="http://www.dougv.com/blog/need-more-help/" rel="nofollow">Need More Help Or Want To Say Thanks?</a>&#8221; link at the top of the page for more info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garth Powell</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-312</link>
		<dc:creator>Garth Powell</dc:creator>
		<pubDate>Thu, 24 Dec 2009 14:32:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-312</guid>
		<description>Did a &quot;cut and paste&quot; on the bearings formula above (thank you)...took out the &quot;$bearing&quot; part, left the &quot;=&quot;.  In place of &quot;$lat2&quot; and so on, I put the specific cell for the specific information.  Pressed &quot;enter&quot; and my 2003 version of Excel didn&#039;t like or know what to do with &quot;% 360;&quot;.  What am I missing here?  Do I need to leave the &quot;$&quot; in all the time?  Will do so when I run a number of these as the starting point will be a constant for a given set and I also took out spaces in the formula...mistake on my part?  Thanks, Garth</description>
		<content:encoded><![CDATA[<p>Did a &#8220;cut and paste&#8221; on the bearings formula above (thank you)&#8230;took out the &#8220;$bearing&#8221; part, left the &#8220;=&#8221;.  In place of &#8220;$lat2&#8243; and so on, I put the specific cell for the specific information.  Pressed &#8220;enter&#8221; and my 2003 version of Excel didn&#8217;t like or know what to do with &#8220;% 360;&#8221;.  What am I missing here?  Do I need to leave the &#8220;$&#8221; in all the time?  Will do so when I run a number of these as the starting point will be a constant for a given set and I also took out spaces in the formula&#8230;mistake on my part?  Thanks, Garth</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-311</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Fri, 11 Dec 2009 03:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-311</guid>
		<description>Thanks for the catch, Chris. I&#039;ve corrected the post, demo and code. (PS: Love your Web site. British idioms amuse me to no end.)</description>
		<content:encoded><![CDATA[<p>Thanks for the catch, Chris. I&#8217;ve corrected the post, demo and code. (PS: Love your Web site. British idioms amuse me to no end.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Rae</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-310</link>
		<dc:creator>Chris Rae</dc:creator>
		<pubDate>Fri, 11 Dec 2009 02:32:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-310</guid>
		<description>This is amazingly handy - I converted your code into C# and integrated it into my app. Worked first time, after some considerable time I&#039;d already spent trying to hack around myself (I remember trigonometry even worse than you claim to!).

I think there&#039;s actually a mistake in your rhumb line bearing calculation. You write:
&lt;pre lang=&quot;php&quot;&gt;
		if($dLon &gt; 0) {
			$dLon = (2 * pi() - $dLon) * -1;
		}
		else {
			$dLon = 2 * pi() * $dLon;
		}&lt;/pre&gt;

but the equivalent piece of code on movable type says:

&lt;pre lang=&quot;php&quot;&gt; dLon = dLon&gt;0 ? -(2*Math.PI-dLon) : (2*Math.PI+dLon);&lt;/pre&gt;

The first option is equivalent, but in the second you are multiplying by dLon and the code at movable type is adding. I have to admit to not having the faintest idea which is correct, but I *think* it&#039;s the addition one.</description>
		<content:encoded><![CDATA[<p>This is amazingly handy &#8211; I converted your code into C# and integrated it into my app. Worked first time, after some considerable time I&#8217;d already spent trying to hack around myself (I remember trigonometry even worse than you claim to!).</p>
<p>I think there&#8217;s actually a mistake in your rhumb line bearing calculation. You write:</p>
<pre lang="php">
		if($dLon > 0) {
			$dLon = (2 * pi() - $dLon) * -1;
		}
		else {
			$dLon = 2 * pi() * $dLon;
		}</pre>
<p>but the equivalent piece of code on movable type says:</p>
<pre lang="php"> dLon = dLon>0 ? -(2*Math.PI-dLon) : (2*Math.PI+dLon);</pre>
<p>The first option is equivalent, but in the second you are multiplying by dLon and the code at movable type is adding. I have to admit to not having the faintest idea which is correct, but I *think* it&#8217;s the addition one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Vanderweide</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-309</link>
		<dc:creator>Doug Vanderweide</dc:creator>
		<pubDate>Wed, 28 Oct 2009 14:45:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-309</guid>
		<description>@mustak: East is 90 degrees.</description>
		<content:encoded><![CDATA[<p>@mustak: East is 90 degrees.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mustak</title>
		<link>http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/#comment-308</link>
		<dc:creator>mustak</dc:creator>
		<pubDate>Wed, 28 Oct 2009 14:19:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.dougv.com/blog/?p=2474#comment-308</guid>
		<description>please tell me how to calculate east bearing from available co ordinates...</description>
		<content:encoded><![CDATA[<p>please tell me how to calculate east bearing from available co ordinates&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

