Quaternion Random
$ q = \begin{pmatrix} \sqrt{1-u} \ \sin(2 \pi v) \\ \sqrt{1-u} \ \cos(2 \pi v) \\ \sqrt{u} \ \sin(2 \pi w) \\ \sqrt{u} \ \cos(2 \pi w) \end{pmatrix}
w, x, y, zの順番は気にしなくていい気がする
Code
code:js
function quatRandom() {
const u = Math.random();
const v = TAU * Math.random();
const w = TAU * Math.random();
const sqrtU = Math.sqrt( u );
const sqrt1U = Math.sqrt( 1.0 - u );
return [
sqrt1U * Math.sin( v ),
sqrt1U * Math.cos( v ),
sqrtU * Math.sin( w ),
sqrtU * Math.cos( w ),
];
}