There are three location on map. Location A , Location B and Location C.
I have only latitude and longitude of all three location.
Now i want to find angle "B" with respect to "A" and "C" in android map.
Please help me.
There are three location on map. Location A , Location B and Location C.
I have only latitude and longitude of all three location.
Now i want to find angle "B" with respect to "A" and "C" in android map.
Please help me.
see for example this link.
In pseudo-code the procedure is more or less like this:
Assuming A, B and C are 2D-vectors with an x and y component.
//compute vectors ba and bc
ba = A-B
bc = C-B
//normalize the vectors (divide by the length)
ban = ba / sqrt(ba.x*ba.x + ba.y*ba.y)
bcn = bc / sqrt(bc.x*bc.x + bc.y*bc.y)
//compute the cosinus of the angle using the dot-product
cosAngle = ban.x * bcn.x + ban.y * bcn.y
//compute the angle
angle = acos(cosAngle)
Note: when you subtract two vectors, subtract the individual coordinates:
ba.x = A.x - B.x
ba.y = A.y - B.y
Division of a vector by a scalar is similar:
ban.x = ba.x / length
ban.y = ba.y / length