Stumped with a bit of geographical maths

Soldato
Joined
9 Jun 2006
Posts
2,642
Hi all,

I'm having a bit of trouble with trying to code up something for a personal project.

I want to work out the angle between true north and some arbitrary point, with my current location being the origin. See picture below. My issue is, I'm working with latitude and longtitude units, which aren't linear 2D coordinates. If I was working on a 2D linear plane, I could just do a dot product of two vectors and it would be easy! Also I don't know what north is, in terms of longtitude and latitude.

My maths is fairly weak, I don't want to code up something that is unnecessarily complex. I'd appreciate it if someone could help!

 
Cn't remember how to do this anymore, however, I would recommend looking into getting some CGP books as they took me through my GCSE's
 
Cn't remember how to do this anymore, however, I would recommend looking into getting some CGP books as they took me through my GCSE's

I don't think GCSEs covered working out angles with a coordinate system where the units are not linear. I think you are referring to dot product of two vectors in cartesian space, which I am familiar with, but not applicable to this as far as I am aware.
 
I would suggest you look into projections, turning lat long into x,y. It all depends on how far your points are apart and where you are as to what sort projection to use. I suggest looking at WGS84 as a good example.
 
EDIT: I don't know how to work in latitude etc. etc., I just did it in 2D as I didn't rly understand what you needed.


You need to know the lengths from the starting point to the other 2 points. You also need 1 angle (which obv aint the one you need to find)

After that, join the 2 places you end, and you have a triangle.

Use cosine rule

a^2=b^2+c^2-2bccosA
where a b and c are the lengths of the 3 sides and A is the angle. (P.S. A should be the angle opposite side A, angle B opposite side B etc.)

then use any 2 parts of the sine rule.

a/sinA = b/sinB = c/sinC

If you know the required stuff (the 2 lengths of the blue lines and 1 angle, you should do it)
 
OP, unfortunately anything like this is going to be VERY difficult almost certainly... :p

Good luck with it, you'll probably need it unfortunately.

I've had the displeasure of having to do things like this before but can't help you except to say see if there are any scripts on the web that will allow you to do this, then work out how they do it.
 
Compass F.T.W!

However manually working a formula out for a computer program (I'm assuming) to use requires the Great Circle maths in the wiki link above.
 
Back
Top Bottom