ShapeUtils { public static float calculateRotationDegree(PointF center, PointF p1, PointF p2) { double angle1 = Math.atan2(p1.y - center.y, p1.x - center.x); double angle2 = Math.atan2(p2.y - center.y, p2.x - center.x); float angle = (float) Math.toDegrees(angle2 - angle1); if (angle > 180) { angle -= 360; } else if (angle < -180) { angle += 360; } return angle; } private  ShapeUtils(); static RectF createSquare(float centerX, float centerY, float radius); static float calculateRotationDegree(PointF center, PointF p1, PointF p2); static Region createRegionFromPath(Path path);  }
@Test public void testCalculateRotationDegree() { testCalculateRotationDegree(0, 0, 1, 1, 2, 2, 0); testCalculateRotationDegree(0, 0, 0, 1, 1, 1, -45); testCalculateRotationDegree(0, 0, 1, 0, 1, 1, 45); testCalculateRotationDegree(0, 0, 0, 1, 1, 0, -90); testCalculateRotationDegree(0, 0, 1, 0, 0, 1, 90); testCalculateRotationDegree(1, 1, 0, 2, 2, 1, -135); testCalculateRotationDegree(1, 1, 0, 2, 2, 0, -180); testCalculateRotationDegree(1, 1, 2, 1, 0, 1, 180); testCalculateRotationDegree(1, 1, 1, 0, 0, 1, -90); }