|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> If I don't take only the points inside the sphere I would create more
> points in the "corners" than other places. It would mean that there are
> more stars in the direction of the eight corners of the cube.
So, instead of generating 3 numbers, generate 2, latitude and longitude.
Ie:
#declare c1 = 180 * rand(s1) - 90;
#declare c2 = 360 * rand(s1);
translate <0,0,1000> // Assuming object originally at origin.
rotate <0, c2, c1> // This means y is up direction, but it is really
// irrelevant which rotation is first and which
// of the axes as used as long as the first axis is
// not the direction of translation.
You might want to translate a randomly chosen distance, and/or size the
object as well, but that's pretty easy.
This code seems a *lot* shorter (and therefore faster) than the other code
I've seen. And you only need one loop and no checks for being within a
certain space.
Geoff
Post a reply to this message
|
![](/i/fill.gif) |