我在Android中有圆,我想计算圆心和两个点之间的角度:
第一个点是圆圈中的上中心,如时钟上的12,第二个点是事件点。
我该怎么做?
public boolean onDrag(View v, DragEvent event) {
float radius = v.getWidth()/2;
float center_circleX = v.getX()+radius;
float center_circleY = v.getY()+radius;
float x = event.getX();
float y = event.getY();
float x1 = radius;
float y1 = radius
//int angleDegrees = ? from 0 to 360
}
答案 0 :(得分:0)
尝试这样的事情:
float angle = Math.toDegrees(
Math.atan2(y1 - center_circleY, x1 - center_circleX) -
Math.atan2(y - center_circleY, x - center_circleX)
);