random method
Implementation
Quaternion random() {
// Derived from http://planning.cs.uiuc.edu/node198.html
// Note, this source uses w, x, y, z ordering,
// so we swap the order below.
var u1 = Math.random();
var sqrt1u1 = Math.sqrt(1 - u1);
var sqrtu1 = Math.sqrt(u1);
var u2 = 2 * Math.PI * Math.random();
var u3 = 2 * Math.PI * Math.random();
return set(
sqrt1u1 * Math.cos(u2),
sqrtu1 * Math.sin(u3),
sqrtu1 * Math.cos(u3),
sqrt1u1 * Math.sin(u2),
);
}