# Leetcode 478 - Generate Random Point in a Circle

Note:

• Why would radius * random() gave wrong answers?
• Because the relation between $\frac{randRadius^2}{radius^2}$ is not linear. We get randRadius from random * radius, and then they become squared relations.
• I don’t want to involve too much math so choose another way to solve this.
• From origin [x - radius, y - radius], use random * 2 * radius to get randomized points.
• If they are in the circle not outside, we return them.

Question:

Given the radius and the position of the center of a circle, implement the function randPoint which generates a uniform random point inside the circle.

Implement the Solution class:

• Solution(double radius, double x_center, double y_center) initializes the object with the radius of the circle radius and the position of the center (x_center, y_center).
• randPoint() returns a random point inside the circle. A point on the circumference of the circle is considered to be in the circle. The answer is returned as an array [x, y].

Example:

Code: