import { PI2 } from "../../math/PI2.js";

/**
 * Pick a random point within a unit circle
 * Based on: https://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly
 * @param {function} random
 * @param {number[]|Float32Array} result
 * @param {number} result_offset
 */
export function randomPointInCircle(random, result, result_offset) {
    const r = Math.sqrt(random());

    const theta = random() * PI2;

    const x = r * Math.cos(theta);
    const y = r * Math.sin(theta);

    result[result_offset] = x;
    result[result_offset + 1] = y;

}
