Calculate angle of touched point and rotate it in Android
first of all, the rotate angle should be determined by the origin of CenterX, and CenterY. So your (touchedY - centerY, touchedX - centerX) should be (centerY - touchedY, centerX - touchedX).
And the correct answer may be:
(int) (Math.toDegrees(Math.atan2(centerY - touchedY, centerX - touchedX)));
Hope it helps
Let's reformulate the problem: You want to find the angle between two vectors. The first vector is the upvector going straigt up from your center-point (u), and the second vector is the vector from the center point to the touch point (v).
Now we can recall (or google) that
cos a = uv / (|u|*|v|)
Where a is the angle between the vectors and |u| is the length of a vector. The upvector, u, is (0, 1) and has length 1.
Multiplying the vectors by hand cancels the x-term and gives us something like this.
double tx = touch_x - center_x, ty = touch_y - center_y;
double t_length = Math.sqrt(tx*tx + ty*ty);
double a = Math.acos(ty / t_length);
Note how the v vector is obtained by subtracting the center point from the touch point. Remember to convert to degrees if needed.