给定圆的半径和圆心的位置,实现函数 randPoint ,在圆中产生均匀随机点。
randPoint
实现 Solution 类:
Solution
Solution(double radius, double x_center, double y_center)
radius
(x_center, y_center)
randPoint()
[x, y]
示例 1:
输入: ["Solution","randPoint","randPoint","randPoint"] [[1.0, 0.0, 0.0], [], [], []] 输出: [null, [-0.02493, -0.38077], [0.82314, 0.38945], [0.36572, 0.17248]] 解释: Solution solution = new Solution(1.0, 0.0, 0.0); solution.randPoint ();//返回[-0.02493,-0.38077] solution.randPoint ();//返回[0.82314,0.38945] solution.randPoint ();//返回[0.36572,0.17248]
提示:
0 < radius <= 108
-107 <= x_center, y_center <= 107
3 * 104