从圆心中找出一个点的角度
如果我有一个720,720看起来像这样的图像..
如果中心x和y是360,360,我如何计算出被触摸的x,y的角度我看到的很多计算假设原点是0,0(左上角),所以得到的结果不正确。 我假设0总是在顶部而不是旋转。
这样可能更清楚:
(Math.toDegrees( Math.atan2(fromLeft - 360.0, 360.0 - fromTop) ) + 360.0) % 360.0
添加一个360度转弯并应用模数运算符可以得到正角度,而atan2则没有。
这是通用公式:
angle = atan2(mouseY - cirleCenterY, mouseX - circleCenterX);
java.lang.Math.atan2(y-360,x-360);
屏幕坐标不会像三角测量那样。
使用java.lang.Math.atan2(-(y-360),x-360);