我必须修改一些人的项目。 getTheta
是该项目中的一种方法,我不明白但help to rotate view rotate like a knob (not fully 360 but less on b/s)
private float getTheta(float x, float y)
{
float sx = x - (float)getWidth() / 2.0F;
float sy = y - (float)getHeight() / 2.0F;
float length = (float)Math.sqrt(sx * sx + sy * sy);
float nx = sx / length;
float theta = 57.29578F * (float)Math.atan2(sy / length, nx);
if (theta < 0.0F)
{
theta += 360F;
}
return theta;
}
我发现获取theta的方法是
private float getMyTheta(float x, float y) {
float sx = x - (getWidth() / 2.0f);
float sy = y - (getHeight() / 2.0f);
float length = (float) Math.sqrt(sx * sx + sy * sy);
float nx = sx / length;
float ny = sy / length;
float theta = (float) Math.atan2(ny, nx);
final float rad2deg = (float) (180.0 / Math.PI);
float theta2 = theta * rad2deg;
return (theta2 < 0) ? theta2 + 360.0f : theta2;
}
有人可以解释我在getTheta(float x,float y);
提前致谢...