POV-Ray : Newsgroups : povray.unofficial.patches : crackle: suggested extensions : Re: crackle: suggested extensions Server Time
1 Sep 2024 12:20:46 EDT (-0400)
  Re: crackle: suggested extensions  
From: Anton Sherwood
Date: 16 May 2001 01:21:00
Message: <3B020E76.8456E686@pobox.com>
> 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] p0b0xcom  --  http://ogre.nu/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.