Skip to content

Instantly share code, notes, and snippets.

@doxas
Created December 10, 2018 04:55
Show Gist options
  • Save doxas/3a00fa73157db82af7e2798dad9a11d0 to your computer and use it in GitHub Desktop.
Save doxas/3a00fa73157db82af7e2798dad9a11d0 to your computer and use it in GitHub Desktop.
let radius = 100.0;
let cb = Math.cbrt(Math.random()); // 一様乱数の立方根
let yc = Math.random() * 2.0 - 1.0; // Y 方向のコサイン相当を単に乱数から得る
let yr = Math.sqrt(1.0 - yc * yc); // 逆数
let th = Math.random() * Math.PI * 2.0; // XZ 平面に対するシータ
let point = [
radius * cb * yr * Math.cos(th),
radius * cb * yc,
radius * cb * yr * Math.sin(th)
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment