import { assert } from "../../assert.js";
import { halton_sequence } from "../statistics/halton_sequence.js";

/**
 * Generates a number of 2d jitter offsets in range -1...1
 * @param {number} point_count
 * @return {Float32Array}
 */
export function generate_halton_jitter(point_count) {
    assert.isNonNegativeInteger(point_count, 'point_count');

    const result = new Float32Array(point_count * 2);

    for (let i = 0; i < point_count; i++) {
        const i2 = i * 2;
        result[i2] = halton_sequence(2, i) * 2 - 1;
        result[i2 + 1] = halton_sequence(3, i) * 2 - 1;
    }

    return result;
}