 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hey, i had an idea for something pretty interesting but I am having problems
implementing it. What i did was create a sphere with object media at the
origin with a radius of five. That part was easy enough, but placing the
lights is troubling me. I need the placement to be random, but at the same
time the lights need to be on the inside of the sphere. If they go outside,
they light the sphere itself and that destroys the scene. So can anyone help
me?
Thanks in advance.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Wesley Parker <wes### [at] verizon net> wrote:
> Hey, i had an idea for something pretty interesting but I am having problems
> implementing it. What i did was create a sphere with object media at the
> origin with a radius of five. That part was easy enough, but placing the
> lights is troubling me. I need the placement to be random, but at the same
> time the lights need to be on the inside of the sphere.
#declare Seed = seed(0);
#declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
#while(vlength(LightLocation) > 5)
#declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
#end
After the loop ends you will have a random point inside the sphere
of radius 5 in 'LightLocation'.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Ok, cool. It works great now. Can you explain how that works?
"Warp" <war### [at] tag povray org> wrote in message
news:3fa850c0@news.povray.org...
> Wesley Parker <wes### [at] verizon net> wrote:
> > Hey, i had an idea for something pretty interesting but I am having
problems
> > implementing it. What i did was create a sphere with object media at
the
> > origin with a radius of five. That part was easy enough, but placing the
> > lights is troubling me. I need the placement to be random, but at the
same
> > time the lights need to be on the inside of the sphere.
>
> #declare Seed = seed(0);
>
> #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> #while(vlength(LightLocation) > 5)
> #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> #end
>
> After the loop ends you will have a random point inside the sphere
> of radius 5 in 'LightLocation'.
>
> --
> #macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb
M()}}
> N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
> N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// -
Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3fa850c0@news.povray.org>, Warp <war### [at] tag povray org>
wrote:
> #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> #while(vlength(LightLocation) > 5)
> #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> #end
Or you could just use VRand_In_Sphere() in rand.inc.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3fa85372$1@news.povray.org>,
"Wesley Parker" <wes### [at] verizon net> wrote:
> Ok, cool. It works great now. Can you explain how that works?
Find a random point in a 10x10x10 box. If the point is outside the
radius-5 sphere, find another random point in the box. Repeat until you
have a random point in the sphere.
The method the include file uses is a bit more complex, but is overall a
bit faster...the loop method can require several attempts before it
turns up a useable point.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff <cja### [at] earthlink net> wrote:
> The method the include file uses is a bit more complex, but is overall a
> bit faster...the loop method can require several attempts before it
> turns up a useable point.
This is true, but relevant only if you are going to place hundreds or
thousands of points inside the sphere... :)
Honestly, I didn't remember the macro in the standard include file.
If I had, I would have suggested it.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
this is kinda funny, i changed the amount of lights im going to use from 25
to 250 (and increased the radius to 500) and its been parsing for the last
15 minutes o.O
im just going to go ahead and stop it now and try the function in the
standard include.
"Warp" <war### [at] tag povray org> wrote in message
news:3fa850c0@news.povray.org...
> Wesley Parker <wes### [at] verizon net> wrote:
> > Hey, i had an idea for something pretty interesting but I am having
problems
> > implementing it. What i did was create a sphere with object media at
the
> > origin with a radius of five. That part was easy enough, but placing the
> > lights is troubling me. I need the placement to be random, but at the
same
> > time the lights need to be on the inside of the sphere.
>
> #declare Seed = seed(0);
>
> #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> #while(vlength(LightLocation) > 5)
> #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> #end
>
> After the loop ends you will have a random point inside the sphere
> of radius 5 in 'LightLocation'.
>
> --
> #macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb
M()}}
> N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
> N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// -
Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
nah, i cant resist the urge to see how long it takes.
20 minutes and counting...
"Wesley Parker" <wes### [at] verizon net> wrote in message
news:3fa85b32$1@news.povray.org...
> this is kinda funny, i changed the amount of lights im going to use from
25
> to 250 (and increased the radius to 500) and its been parsing for the last
> 15 minutes o.O
>
> im just going to go ahead and stop it now and try the function in the
> standard include.
> "Warp" <war### [at] tag povray org> wrote in message
> news:3fa850c0@news.povray.org...
> > Wesley Parker <wes### [at] verizon net> wrote:
> > > Hey, i had an idea for something pretty interesting but I am having
> problems
> > > implementing it. What i did was create a sphere with object media at
> the
> > > origin with a radius of five. That part was easy enough, but placing
the
> > > lights is troubling me. I need the placement to be random, but at the
> same
> > > time the lights need to be on the inside of the sphere.
> >
> > #declare Seed = seed(0);
> >
> > #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> > #while(vlength(LightLocation) > 5)
> > #declare LightLocation = 10*<rand(Seed), rand(Seed), rand(Seed)>-5;
> > #end
> >
> > After the loop ends you will have a random point inside the sphere
> > of radius 5 in 'LightLocation'.
> >
> > --
> > #macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb
> M()}}
> > N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
> > N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// -
> Warp -
>
>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3fa85b32$1@news.povray.org>,
"Wesley Parker" <wes### [at] verizon net> wrote:
> this is kinda funny, i changed the amount of lights im going to use from 25
> to 250 (and increased the radius to 500) and its been parsing for the last
> 15 minutes o.O
It shouldn't take *that* long to parse, it may actually be done parsing
and busy working on light buffers. If it takes too long or runs out of
memory, try turning off light buffers. Or maybe you made a mistake in
modifying the code...it will take a very long time to find random points
in a 5-unit sphere when you use random points from a 1000-unit box.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3fa8468e@news.povray.org>, "Wesley Parker" <wes### [at] verizon net>
wrote:
> Hey, i had an idea for something pretty interesting but I am having problems
> implementing it. What i did was create a sphere with object media at the
> origin with a radius of five. That part was easy enough, but placing the
> lights is troubling me. I need the placement to be random, but at the same
> time the lights need to be on the inside of the sphere. If they go outside,
> they light the sphere itself and that destroys the scene. So can anyone help
> me?
>
> Thanks in advance.
>
>
hi,
you can about that :
take a rayon
take a random number from 0 to 360
take an other random number from +90 to -90
then just convert polar coordonates from this 3 number to rectangular <x,y,z>
pretty simply
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Hey, i had an idea for something pretty interesting but I am having
problems
> implementing it. What i did was create a sphere with object media at the
> origin with a radius of five. That part was easy enough, but placing the
> lights is troubling me. I need the placement to be random, but at the same
> time the lights need to be on the inside of the sphere. If they go
outside,
> they light the sphere itself and that destroys the scene. So can anyone
help
> me?
>
> Thanks in advance.
My solution would be as follows:
#declare Seed=seed(1);
#declare
Random_Lightsource=vnormalize(<rand(Seed)*2-1,rand(Seed)*2-1,rand(Seed)*2-1>
)*rand(Seed)*5;
This would generate a random position ON a unit-sphere, but the radius gets
randomized to a value between 0 and 5 (rand(Seed)*5 at the end). If you need
to make sure that the lightsource is a certain distance in the sphere,
reduce the radius, if you want it to range from a certain distance of the
center, multiply with the following:
(rand(Seed)*(Max_Radius-Min_Radius)+Min_Radius)
Don't forget the brackets, cause Value*Value_2+Value_3 is something
different than Value*(Value_2+Value_3)!
This should parse faster than trying to randomly generate a position in a
box and THEN find if its in the sphere, cause it produces a position in the
sphere RIGHT AWAY.
Regards,
Tim
--
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Email: tim.nikias (@) nolights.de
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.536 / Virus Database: 331 - Release Date: 03.11.2003
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Wesley Parker <wes### [at] verizon net> wrote:
> this is kinda funny, i changed the amount of lights im going to use from 25
> to 250 (and increased the radius to 500) and its been parsing for the last
> 15 minutes o.O
With 250 light sources the it will take enormous amounts of parsing
and specially rendering time anyways (but not placing the light sources,
but calculating light buffers).
If you want to test the speed of the code, place small objects instead,
like tiny spheres.
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Kurts <kur### [at] yahoo fr> wrote:
> take a rayon
> take a random number from 0 to 360
> take an other random number from +90 to -90
> then just convert polar coordonates from this 3 number to rectangular <x,y,z>
> pretty simply
You don't get an even distribution that way.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tim Nikias v2.0 <tim.nikias (@) nolights.de> wrote:
> #declare
> Random_Lightsource=vnormalize(<rand(Seed)*2-1,rand(Seed)*2-1,rand(Seed)*2-1>
> )*rand(Seed)*5;
Are you sure this produces an even distribution?-)
By the way, you can do: <rand(Seed),rand(Seed),rand(Seed)>*2-1
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> > #declare
> >
Random_Lightsource=vnormalize(<rand(Seed)*2-1,rand(Seed)*2-1,rand(Seed)*2-1>
> > )*rand(Seed)*5;
>
> Are you sure this produces an even distribution?-)
Nah, not sure if this is even distribution. Would be, sorta, if the
rand-function would be TRULY random, but it suffices in most cases anyway.
Randomizing points in a box and then checking if its in the sphere wouldn't
produce even distribution either. So why not save the parsing time of
sorting out unnecessary points?
> By the way, you can do: <rand(Seed),rand(Seed),rand(Seed)>*2-1
Hm, yeah, right. Can't remember when and how I came to do it this way...
--
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Email: tim.nikias (@) nolights.de
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.536 / Virus Database: 331 - Release Date: 03.11.2003
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Tim Nikias v2.0" <tim.nikias (@) nolights.de> wrote in message
news:3fa8d552@news.povray.org...
> Nah, not sure if this is even distribution. Would be, sorta, if the
> rand-function would be TRULY random, but it suffices in most cases anyway.
> Randomizing points in a box and then checking if its in the sphere wouldn't
> produce even distribution either. So why not save the parsing time of
> sorting out unnecessary points?
Ignoring the issue of rand-function and TRULY random, I suspect you're missing
the point.
Imagine a disk, now take a random distance along the radius, and then a random
rotation. You will get a disproportionate number of points near the center of
the disk. However, finding truly random points within a square that contains the
disk, and then checking whether they are inside the disk will produce a proper
random distrib. within the confines of the rand method.
You can see this yourself with the following code:
#include "colors.inc"
camera {
location <0.0, 0.0, -4.0>
look_at <0.0, 0.0, 0.0>
}
disc {
<0, 0, 0> // center position
z, // normal vector
1.0, // outer radius
0.0 // optional hole radius
pigment{Red}
finish{ambient 1}
}
#local Count = 0;
#local MyRand = seed(2534);
#while(Count<1000)
sphere{
0,0.025
translate y*rand(MyRand)
rotate z*360*rand(MyRand)
pigment{Green}
finish{ambient 1}
}
#local Count = Count +1;
#end
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tom Melly <tom### [at] tomandlu co uk> wrote:
> Imagine a disk, now take a random distance along the radius, and then a random
> rotation. You will get a disproportionate number of points near the center of
> the disk.
For the same reason the presented method of normalizing a random point
inside the cube will not give an even distribution of points on the
surface of the sphere. The points will be slightly more concentrated
on the direction of the corners of the box (because there are more points
at those directions than eg. in the direction of the main axes).
Granted, this concentration difference is very small and probably
mostly unnoticeable, but if mathematical distribution evenness is
important, one should know this limitation.
--
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Ignoring the issue of rand-function and TRULY random, I suspect you're
missing
> the point.
>
> Imagine a disk, now take a random distance along the radius, and then a
random
> rotation. You will get a disproportionate number of points near the center
of
> the disk. However, finding truly random points within a square that
contains the
> disk, and then checking whether they are inside the disk will produce a
proper
> random distrib. within the confines of the rand method.
Ah, okay, I get it. You mean with the box approach, the points in the
corners of the box, outside the sphere, will fall out, but in my case,
they'll be introduced into the sphere. Hence a larger distribution of points
in the "axis-corners" of the sphere, right?
Then you're both right about that. Still, depending on the amount of
lightsources required, I'd say there is no need to go into the hassle of the
more difficult approach with if-statements and all that. But that's probably
more an issue of taste, cause with random distribution, it *sometimes*
doesn't matter if its even or not...
--
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Email: tim.nikias (@) nolights.de
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.536 / Virus Database: 331 - Release Date: 03.11.2003
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tim Nikias v2.0 <tim.nikias (@) nolights.de> wrote:
> Ah, okay, I get it. You mean with the box approach, the points in the
> corners of the box, outside the sphere, will fall out, but in my case,
> they'll be introduced into the sphere. Hence a larger distribution of points
> in the "axis-corners" of the sphere, right?
I actually rendered an image to see if the difference in distribution
is visible. I placed 20000 dots on the surface of a sphere using the
normalization method. The distribution is quite visible:
http://www.cs.tut.fi/~warp/images/test.jpg
> Then you're both right about that. Still, depending on the amount of
> lightsources required, I'd say there is no need to go into the hassle of the
> more difficult approach with if-statements and all that.
It's no hassle to use the VRand_In_Sphere() macro in rand.inc.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Wesley Parker" <wes### [at] verizon net> a écrit dans le message de
news:3fa85c48$1@news.povray.org...
> nah, i cant resist the urge to see how long it takes.
>
> 20 minutes and counting...
Turn off the light buffers: -ul on the command line.
G.
--
**********************
http://www.oyonale.com
**********************
- Graphic experiments
- POV-Ray and Poser computer images
- Posters
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Wesley Parker" <wes### [at] verizon net> wrote in
news:3fa8468e@news.povray.org:
> [...]
> but placing the lights is troubling me. I need the placement to be
> random, but at the same time the lights need to be on the inside of
> [...]
Just another idea for the position. I think this should distribute quite
well for your purposes:
(Where 5 is your radius)
5/(1+rand(S))*vnormalize(-1+2*<rand(S),rand(S),rand(S)>)
This was derived from the random distribution:
5*rand(S)*vnormalize(-1+2*<rand(S),rand(S),rand(S)>)
But, given that a sphere will have a higher concentration of points near
the center, I thought you might prefer to place them inversely
proportional to the distance from the center.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Alain <noe### [at] on ca> wrote:
> But, given that a sphere will have a higher concentration of points near
> the center, I thought you might prefer to place them inversely
> proportional to the distance from the center.
I think that the idea was to place random points *evenly* inside the
sphere. Making a higher concentration near the center kind of defies
this goal.
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <Xns### [at] 204 213 191 226>,
Alain <noe### [at] on ca> wrote:
> (Where 5 is your radius)
>
> 5/(1+rand(S))*vnormalize(-1+2*<rand(S),rand(S),rand(S)>)
This will not give anything close to an even distribution. The places
where points in the corners of the box were projected onto the sphere
surface will have higher densities. And I have no idea what you think
you're doing by subtracting a uniform random value in the range [0, 1]
from 1...this has no effect. And then dividing 5 by that value...you do
know this will give points with distances from the origin from 5 units
out to infinity, don't you? Points *outside* the sphere, most of them
*far* outside.
> This was derived from the random distribution:
>
> 5*rand(S)*vnormalize(-1+2*<rand(S),rand(S),rand(S)>)
Which itself is badly flawed, and won't give anything close to a uniform
distribution.
> But, given that a sphere will have a higher concentration of points near
> the center, I thought you might prefer to place them inversely
> proportional to the distance from the center.
VRand_In_Sphere() gives an even distribution, the density of points is
equal over the volume of the sphere.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Warp" <war### [at] tag povray org> wrote in message news:3fa90775@news.povray.org...
> Alain <noe### [at] on ca> wrote:
> > But, given that a sphere will have a higher concentration of points near
> > the center, I thought you might prefer to place them inversely
> > proportional to the distance from the center.
>
> I think that the idea was to place random points *evenly* inside the
> sphere. Making a higher concentration near the center kind of defies
> this goal.
>
Ignoring any possible mis-terms, doesn't Alain's suggestion make sense?
Hmm, testing.... (with my disk-example)...
#include "colors.inc"
#declare MyRadius = .50;
camera {
location <0.0, 0.0, -MyRadius*2.5>
look_at <0.0, 0.0, 0.0>
}
disc {
<0, 0, 0> // center position
z, // normal vector
MyRadius, // outer radius
0.0 // optional hole radius
pigment{Red}
finish{ambient 1}
}
#local Count = 0;
#local MyRand = seed(457);
#while(Count<10000)
sphere{
0,0.01*MyRadius
translate y*(sqrt(rand(MyRand))*MyRadius)
rotate z*360*rand(MyRand)
pigment{Green}
finish{ambient 1}
}
#local Count = Count +1;
#end
Well, that seems to produce a fairly even distribution.... I dunno how you apply
this to 3 dimensions (i.e. a sphere), but it can't be that hard, can it?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp <war### [at] tag povray org> wrote in news:3fa90775@news.povray.org:
> Alain <noe### [at] on ca> wrote:
>> But, given that a sphere will have a higher concentration of points
>> near the center, I thought you might prefer to place them inversely
>> proportional to the distance from the center.
>
> I think that the idea was to place random points *evenly* inside the
> sphere. Making a higher concentration near the center kind of defies
> this goal.
>
Yeah, that's not the intention. I guess this is distributing randomly, but
radially. Oh well, it was just an idea. The first equation will simply
radially distribute more points towards the outside of the sphere.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christopher James Huff <cja### [at] earthlink net> wrote in
news:cja### [at] netplex aussie org:
> In article <Xns### [at] 204 213 191 226>,
> Alain <noe### [at] on ca> wrote:
>
>> (Where 5 is your radius)
>>
>> 5/(1+rand(S))*vnormalize(-1+2*<rand(S),rand(S),rand(S)>)
>
> This will not give anything close to an even distribution. The places
> where points in the corners of the box were projected onto the sphere
> surface will have higher densities. And I have no idea what you think
> you're doing by subtracting a uniform random value in the range [0, 1]
> from 1...this has no effect. And then dividing 5 by that value...you
> do know this will give points with distances from the origin from 5
> units out to infinity, don't you? Points *outside* the sphere, most of
> them *far* outside.
Sorry condescending dude, but I have no idea what you are talking about.
What subtraction do you have a problem with? The -1? It establishes a
range -1 to +1. You have a problem with the 1+? It's a simple inversely
proportional equation. Besides I just tried it in Pov and it seems to
work fine. Yes, it's not an even distribution, it favours points towards
the outside (but not outside), which was intended in that one. And, yes,
even the second equation I gave, as pointed out by Warp, will only
distribute randomly radially.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <Xns### [at] 204 213 191 226>,
Alain <noe### [at] on ca> wrote:
> Sorry condescending dude,
What you said was incorrect, so I corrected you. There's no reason to be
insulting.
> but I have no idea what you are talking about.
> What subtraction do you have a problem with? The -1? It establishes a
> range -1 to +1.
Bleh, I was misreading 1+rand(S) as 1-rand(S).
> You have a problem with the 1+? It's a simple inversely
> proportional equation. Besides I just tried it in Pov and it seems to
> work fine. Yes, it's not an even distribution, it favours points towards
> the outside (but not outside), which was intended in that one.
It is more than uneven: 5/(1+rand(S)) will range between 5 and 2.5. The
interior of the sphere will be empty...you end up filling a hollow shell
with inner radius 2.5 and outer radius 5. And within this shell, it will
still be more dense toward the inner side of the shell than the outer
side.
> And, yes, even the second equation I gave, as pointed out by Warp,
> will only distribute randomly radially.
This one?
5*rand(S)*vnormalize(-1+2*<rand(S),rand(S),rand(S)>)
That distribution is not even in any way. Points will be more dense
facing the corners of the cube you pull random points from, so the
distribution is uneven in angular density. A cone from the center
pointing at < 1, 1, 1> will contain more points than the same cone
pointing at < 0, 0, 1>.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Short and slightly faster (by 9%) than VRand_In_Sphere() from rand.inc:
#macro VRand_In_Sphere(Stream)
#local Y = 2*rand(Stream)-1;
vrotate ( (<sqrt(1-Y*Y),Y,0>*pow(rand(Stream),1/3)), 360*rand(Stream)*y )
#end
Sputnik
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
If the radius is a simple random number, then the point density varies with
the inverse square of the radius. This code compensates for the variance:
#macro EvenSpherePoint(pos, rad, sd)
#local irad = sqrt(min(rand(sd),0);
#local theta = rand(sd)*2*pi;
#local phi = (rand(sd)-0.5)*pi;
#local dir = <cos(phi)*cos(theta), sin(phi), cos(phi)*sin(theta)>;
#local pnt = pos+dir*irad*rad;
pnt
#end
To use it--
#declare sdBall = seed(4852); // Sample number
#declare bPos = <0, 0, 0>;
#declare bSiz = 5;
sphere { bPos, bSiz
pigment { rgbt 1 }
hollow
interior { /* your media */ }
}
#local i = 0;
#while (i<45)
#local col = <rand(sdBall), rand(sdBall), rand(sdBall)>;
#local pos = EvenSpherePoint(bPos, bSiz, sdBall);
light_source { pos, rgb col }
#local i = i + 1; // if using MegaPov v1.0 #set will work
#end
Now you avoid having to check for the sphere's boundary with each point.
"Warp" <war### [at] tag povray org> wrote in message
news:3fa8cf58@news.povray.org...
> Kurts <kur### [at] yahoo fr> wrote:
> > take a rayon
> > take a random number from 0 to 360
> > take an other random number from +90 to -90
> > then just convert polar coordonates from this 3 number to rectangular
<x,y,z>
>
> > pretty simply
>
> You don't get an even distribution that way.
>
> --
> #macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb
M()}}
> N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
> N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// -
Warp -
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |