2015-04-20 33 views
-2

There are three location on map. Location A , Location B and Location C. 我想找到兩個位置之間的各自角度的第三位置

上有地圖Three位置。位置A,位置B和位置C.

我只有三個位置的經度和緯度。

現在我想找到角 「」 相對於「A」「C」機器人地圖

請幫幫我。

+1

的http:// EN。 wikipedia.org/wiki/Trigonometry –

+0

如何在android中使用三角函數? –

+0

這是基本的[數學](http://developer.android.com/reference/java/lang/Math.html)。 –

回答

1

參見例如link

在僞代碼的步驟是或多或少像這樣:

假設A,B和C是2D矢量用x和y分量。

//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) 

注: 當你減去兩個向量,減去各個座標:

ba.x = A.x - B.x 
ba.y = A.y - B.y 

司由標量向量是相似的:

ban.x = ba.x/length 
ban.y = ba.y/length 
+0

如何在android地圖上找到矢量(ba和bc)? –

+0

我不知道android地圖。但我想有一些方法可以得到這個點的兩個座標。一旦你有了座標,你可以按照上面的概述來計算它。既可以使用現有的矢量庫,編寫自己的矢量庫,也可以將x和y座標維護在單獨的變量中。 – azt

+0

這就是問題所在。 我只有三個位置的經度和緯度。沒有其他的。 –

相關問題