# android 计算点是否在扇形区域

1. 三个点：圆心A，半径r，度数0的点B,任意点C.

```public double calculatorDegree(float x1, float y1, float x2, float y2, float x3, float y3) {

double ab = getDistance(x1, y1, x2, y2);
double ac = getDistance(x1, y1, x3, y3);
double bc = getDistance(x2, y2, x3, y3);

double value = (ab * ab + ac * ac - (bc * bc)) / (2 * ab * ac);

}

public double getDistance(float x1, float y1, float x2, float y2) {
double distance = 0;
distance = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
return distance;
}```

2. 根据弧度计算度数并且计算AC距离。

```float x = event.getX();
float y = event.getY();
double radian = calculatorDegree(width / 2, height / 2, width / 2 + radius, height / 2, x, y);
double degree =  (180 / Math.PI * radian);
double distance = getDistance(width / 2, height / 2, x, y);```

3，根据度数和距离计算。

(float) (center_X + r * Math.cos(startAngle * Math.PI / 180)),(float) (center_Y + r * Math.sin(startAngle * Math.PI / 180))

android 计算点是否在扇形区域

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊