2014-11-09 58 views
0

我怎樣才能使用atan2來確定一個線段結束的座標,知道它開始的座標(x, y),線段的角度和線段的長度?確定一個線段的座標

你能告訴我一個解決方案並不必須只能用ATAN2 ...

回答

0

你有一個直角三角形,你可以假設A點爲(X,Y),這更容易與使用的一些圖表來解釋:

right angled triangle

現在我們知道什麼是對C值已經因爲這是段的長度,我們要知道a和b的值因爲最後一點是(x+b, y+a)

從三角,我們所知道的和側面的比例的角度之間的關係是 tight angle triangle angles

sin(theta) = opposite/hypotenusecos(theta) = adjacent/hypotenuse

代中的值,我們知道我們得到:

sin(theta) = opposite/c 
c = opposite * sin(theta) 

cos(theta) = adjacent/b 
b = adjacent * cos(theta) 

我們知道en d點在(x+b, y+a),給定我們找到的邊的值是(x+adjacent * cos(theta), y+opposite * sin(theta))

相關問題