June 4th, 2018, 08:36 AM  #1 
Newbie Joined: Jun 2018 From: Milwaukee Posts: 5 Thanks: 1  Haversine Formula
Hey guys, I'm programming an Arduino to do some fun tasks for me; one is to calculate a heading/bearing based on current position (current being point A) and a destination (destination being point B). Now I'm using (trying) haversign to do this, and I'm sure I'm not doing it correctly. Any instance I manage to expect a negative value, it kicks me a positive value of the exact amount. So I feel like a) my math is flat out wrong b) my understanding is wrong and this formula never yields a positive value and it is procedurally added by a method I'm not aware of. I will list a specific set of parameters below should anyone want to help me out. Below also I will list a website where you can set two points and it will autocalculate. The example of points listed below should yield roughly 17.9*** https://www.igismap.com/maptool/bearingangle Here are the points LatA: 49.077478 LonA: 67.162589 LatB: 42.799419 LonB: 88.140146 Haversign is as follows: X = cos Î¸b * sin âˆ†L Y = cos Î¸a * sin Î¸b â€“ sin Î¸a * cos Î¸b * cos âˆ†L Î² = atan2(X,Y) Last edited by skipjack; June 5th, 2018 at 07:58 AM. 
June 5th, 2018, 07:59 AM  #2 
Global Moderator Joined: Dec 2006 Posts: 20,302 Thanks: 1974 
It's spelt haversine, which may be abbreviated to hav in equations.

June 5th, 2018, 08:50 AM  #3 
Newbie Joined: Jun 2018 From: Milwaukee Posts: 5 Thanks: 1  
June 5th, 2018, 12:19 PM  #4 
Global Moderator Joined: Dec 2006 Posts: 20,302 Thanks: 1974 
Not necessarily. I was pushed for time, so my reply was limited. Why did you mention haversine when the equations you gave don't use it? I did the calculations (using your equations) and got 17.9$^\circ\!$ approximately, as expected. What programming language were you using? 
June 5th, 2018, 01:29 PM  #5 
Senior Member Joined: Aug 2012 Posts: 2,157 Thanks: 631 
The versine is twice the haversine. Today I learned!! https://en.wikipedia.org/wiki/Haversine_formula 
June 6th, 2018, 12:33 PM  #6 
Global Moderator Joined: Dec 2006 Posts: 20,302 Thanks: 1974  
June 12th, 2018, 12:15 PM  #7 
Newbie Joined: Jun 2018 From: Milwaukee Posts: 5 Thanks: 1 
My apologies. I'm checking my math again. Perhaps i'm not understanding Delta L correctly. I will try again and get back! Oh also i'm using python, but i got the exact same numbers in excel, which leads me to believe its my math. My basic understanding of delta was more or less absolute difference. How exactly do you calculate Delta L? Last edited by hanslanda; June 12th, 2018 at 12:19 PM. 
June 12th, 2018, 02:17 PM  #8  
Newbie Joined: Jun 2018 From: Milwaukee Posts: 5 Thanks: 1  Quote:
Still doesn't make a whole lot of sense to call out a Delta if you're expecting a negative value, in my opinion. To me 'sin deltaL' = sin(abs(AB)) In reality it expects = sin(ba) Is this your understanding as well Skipjack? PS. Is skipjack in reference to the sub?  

Tags 
formula, haversign, haversine 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Solving Haversine Formula For Longitude And Latitude  oang  Trigonometry  0  September 3rd, 2015 12:51 AM 
My new formula for pi(x)  nsrmsm  Number Theory  7  October 15th, 2012 06:36 AM 
what is the formula for Tan (A)Tan (B) ?  silvercats  Calculus  4  June 7th, 2011 02:10 AM 
De Moivre's formula and Newton's binomial formula  agro  Probability and Statistics  3  August 27th, 2009 07:17 AM 
find longitude, latitude using haversine  nicromonicon  Algebra  0  June 25th, 2009 03:18 PM 