My Math Forum  

Go Back   My Math Forum > High School Math Forum > Trigonometry

Trigonometry Trigonometry Math Forum


Reply
 
LinkBack Thread Tools Display Modes
June 4th, 2018, 07: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 auto-calculate. The example of points listed below should yield roughly -17.9***

https://www.igismap.com/map-tool/bearing-angle

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 06:58 AM.
hanslanda is offline  
 
June 5th, 2018, 06:59 AM   #2
Global Moderator
 
Joined: Dec 2006

Posts: 19,042
Thanks: 1618

It's spelt haversine, which may be abbreviated to hav in equations.
skipjack is offline  
June 5th, 2018, 07:50 AM   #3
Newbie
 
Joined: Jun 2018
From: Milwaukee

Posts: 5
Thanks: 1

Quote:
Originally Posted by skipjack View Post
It's spelt haversine, which may be abbreviated to hav in equations.
I see this was a waste of my time
hanslanda is offline  
June 5th, 2018, 11:19 AM   #4
Global Moderator
 
Joined: Dec 2006

Posts: 19,042
Thanks: 1618

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?
skipjack is offline  
June 5th, 2018, 12:29 PM   #5
Senior Member
 
Joined: Aug 2012

Posts: 1,919
Thanks: 533

The versine is twice the haversine. Today I learned!!

https://en.wikipedia.org/wiki/Haversine_formula
Maschke is offline  
June 6th, 2018, 11:33 AM   #6
Global Moderator
 
Joined: Dec 2006

Posts: 19,042
Thanks: 1618

Quote:
Originally Posted by hanslanda View Post
. . . a positive value of the exact amount.
If you gave ∆L a positive sign (it should be negative for your data), that would explain the sign error in your calculated result.
skipjack is offline  
June 12th, 2018, 11:15 AM   #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 11:19 AM.
hanslanda is offline  
June 12th, 2018, 01:17 PM   #8
Newbie
 
Joined: Jun 2018
From: Milwaukee

Posts: 5
Thanks: 1

Quote:
Originally Posted by skipjack View Post
If you gave ∆L a positive sign (it should be negative for your data), that would explain the sign error in your calculated result.
It appears I was able to get the correct answer by subtracting LongB by LongA with no absolute positive. This was vague in the formula description I read.

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(A-B))

In reality it expects = sin(b-a)


Is this your understanding as well Skipjack?



PS. Is skipjack in reference to the sub?
hanslanda is offline  
Reply

  My Math Forum > High School Math Forum > Trigonometry

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 2nd, 2015 11:51 PM
My new formula for pi(x) nsrmsm Number Theory 7 October 15th, 2012 05:36 AM
what is the formula for Tan (A)-Tan (B) ? silvercats Calculus 4 June 7th, 2011 01:10 AM
De Moivre's formula and Newton's binomial formula agro Probability and Statistics 3 August 27th, 2009 06:17 AM
find longitude, latitude using haversine nicromonicon Algebra 0 June 25th, 2009 02:18 PM





Copyright © 2018 My Math Forum. All rights reserved.