Skip to content

Instantly share code, notes, and snippets.

@syoyo
Created December 17, 2018 13:12
Show Gist options
  • Save syoyo/831c4b1926aa88c0da9221211723da2d to your computer and use it in GitHub Desktop.
Save syoyo/831c4b1926aa88c0da9221211723da2d to your computer and use it in GitHub Desktop.
C++ implementaion of "A simple method to construct isotropic quasirandom blue noise point sequences"
//
// C++ implementaion of "A simple method to construct isotropic quasirandom blue
// noise point sequences"
//
// http://extremelearning.com.au/a-simple-method-to-construct-isotropic-quasirandom-blue-noise-point-sequences/
//
// Assume 0 <= x
static double myfmod(double x) { return x - std::floor(x); }
// i = 1, 2, 3, ...
// lambda = jitter parameter( > 0)
// u0, u1 = random number. [0.0, 1.0)
static void sample_point_2d(int i, double lambda, double u0, double u1,
double p[2]) {
const double kPI = 3.14159265358979323846;
const double varphi = 1.324717957244746;
double alpha[2];
alpha[0] = 1.0 / varphi;
alpha[1] = 1.0 / (varphi * varphi);
const double delta0 = 0.76;
const double i0 = 0.700;
p[0] = myfmod(alpha[0] * double(i) + (lambda * delta0 * std::sqrt(kPI) /
(4.0 * std::sqrt(double(i) - i0))) *
u0);
p[1] = myfmod(alpha[1] * double(i) + (lambda * delta0 * std::sqrt(kPI) /
(4.0 * std::sqrt(double(i) - i0))) *
u1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment