|
 |
> Ron Parker wrote:
> > Do you happen to have a formula that will translate a random vector
> > in the unit cube between <0,0,0> and <1,1,1> into a set of basis
> > vectors and give uniform coverage of the space of all possible
> > basis vectors? I seem to have left mine in my other coat.
Anton Sherwood wrote:
> I'll think about it some more, and come up with a dumb idea.
> Then I'll ask sci.math.
Got it. (I'll call your random vector <rx,ry,rz>)
theta = rx*2*pi;
phi = acos(2*ry-1);
v0 = sphere_to_xyz(theta,phi); /* uniform by Archimedean theorem */
vtemp = one of the axis vectors,
corresponding to the smallest component of v0;
v1 = vaxis_rotate(vtemp,v0,rz*360);
v2 = vcross(v0,v1);
v0 = vcross(v1,v2);
v0,v1,v2 are the new basis.
(The rigmarole with vtemp is to get it down to three rands;
it's more obvious with four.)
--
Anton Sherwood -- br0### [at] p0b0x com -- http://ogre.nu/
Post a reply to this message
|
 |