本文介紹了從圓心找到一點的角度的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
如果我有一個像這樣的圖像 720、720..
If I have an image 720, 720 that looks like this..
如果中心 x 和 y 分別為 360、360,我如何計算所觸摸的 x,y 的角度我看到的很多計算都假設原點是 0,0(左上角),所以我得到不正確的結果.我假設 0 總是在頂部而不是旋轉.
How do I work out the angle of the touched x,y given that the center x and y are 360, 360 A lot of calculations I see for this assume the origin is 0,0 (which is top left) so I get incorrect results. I am assuming 0 is always to the top and not rotated.
推薦答案
這樣可能更清楚:
(Math.toDegrees( Math.atan2(fromLeft - 360.0, 360.0 - fromTop) ) + 360.0) % 360.0
添加 360 度轉彎并應用模運算符可以得到正角,而 atan2 沒有.
Adding a 360 degree turn and applying the modulo operator gives you the positive angle, which atan2 does not.
這篇關于從圓心找到一點的角度的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!