Android_Learner - 1 year ago 51

Android Question

i want to find radius for a circle to be drawn in future. the data i have is the centre point haveing a X and a Y.

CentrePoint(X,Y)

CentrePoint(1052.9414978027344,1434.042869567871)

Answer

I am going to assume that the question is:

How can I get the

`radius`

of a circle that I know the center of, based on a point related to that center. In Java or Dalvik (Android)

From a Math point of view, the distance between two points in the same plane is the square root of the sum from the power of two from each side in a triangle:

So:

```
private double getRadius(Point a, Point circleCenter){
return Math.sqrt(Math.pow(Math.abs(a.x)-Math.abs(circleCenter.x),2)+Math.pow(Math.abs(a.y)-Math.abs(circleCenter.y),2));
}
```

Source (Stackoverflow)