Re: random unit vector
- From: Jack Tomsky <jtomsky@xxxxxxxxxxxxx>
- Date: Sat, 31 Dec 2005 15:43:58 EST
> Given two random numbers R1 and R2 (uniformly
> distributed between -1 and and
> +1) I am looking for a formula to calculate a 3D unit
> vector with a uniform
> distrubution in every direction. Obviously just
> transforming R1 and R2 into
> spherical coordinates (angles) does not satisfy this
> criteria.
>
> Any ideas ?
>
> Michael from Innsbruck
>
> P.S.: This problem arises from the idea of simulating
> an explosion with
> numerous particles emitted from the center of
> explosion. It is important to
> me that the particles are evenly emitted into any
> direction.
Are you looking to generate (x,y,z) which will be uniformly distributed within the sphere: x^2 + y^2 + z^2 <= r^2 ?
Then generate three independent uniforms u,v,w between +/- 1 and transform by
x = u*r/sqrt(u^2 + v^2 + w^2)
y = v*r/sqrt(u^2 + v^2 + w^2)
z = w*r/sqrt(u^2 + v^2 + w^2)
Jack
.
- References:
- random unit vector
- From: Michael Schiestl
- random unit vector
- Prev by Date: Re: Maximum likelihood estimator and multiple maxima
- Previous by thread: random unit vector
- Index(es):