|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi,
I created a bunch of cylinders with a while loop and the rand() function.
But some of the cylinders are overlapping like in this picture:
http://alien23.de/test4/cylinders.jpg
The code I used was this:
#declare zufall_1= seed (1199);
#declare zufall_2= seed (342);
#declare ab=.09; /// abstand
#declare Loop_x =0;
#declare Loop_x_end =9;
union {
#while (Loop_x < Loop_x_end)
#declare Loop_y =0;
#declare Loop_y_end =9;
#while (Loop_y < Loop_y_end)
#if (even (Loop_y))
object { cyl translate
<-.08+Loop_x*ab+rand(zufall_1)/15+Loop_x*.05 ,
Loop_y*ab+rand(zufall_1)/15+Loop_y*.035 , 0> }
#else
object { cyl translate <.1+Loop_x*ab-rand(zufall_1)/1+Loop_x*.05
, Loop_y*ab+rand(zufall_1)/16+Loop_y*.025 , 0> }
#end
#declare Loop_y=Loop_y+1;
#end
#declare Loop_x=Loop_x+1;
#end
}
------------------------------------------------------
By now I've spent hours trying out other values for the cylinders' translation.
But when I use other values together with rand() I can prevent the cylinders
from overlapping but then everything looks too orderly.
So I basically want the bunch of cylinders to look like in the picture just
without the 4 or 5 overlapping cylinders.
I know it might work with the trace function to check whether they overlap and
so I read through Jonathan Hunt's pebbles.pov where he uses this.
But I found it very difficult and I don't know how too adapt the trace function
to my scene.
Or maybe it is possible to put all the translation data into an output file, and
manually edit the overlapping cylinders and then reimport it? But I have no clue
how to do this either.
Best wishes,
Simone
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Simone <inf### [at] alienenterprisesde> wrote:
> So I basically want the bunch of cylinders to look like in the picture just
> without the 4 or 5 overlapping cylinders.
Two possible solutions:
1) Develop a complicated algorithm in SDL which checks for the intersection
of cylinders and which skips creating those cylinders which intersect
with existing ones.
2) Since there are only a few intersecting cylinders, make a manual exception
list in the form of hard-coded loop index values (in other words, when
the loop counter reaches such a value, the coordinates of the cylinder
are calculated as normal, but the cylinder itself will not be
instantiated). You could use an array for this.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Simone" <inf### [at] alienenterprisesde> wrote:
> Hi,
> I created a bunch of cylinders with a while loop and the rand() function.
> But some of the cylinders are overlapping like in this picture:
> http://alien23.de/test4/cylinders.jpg
>
>I've spent hours trying out other values for the cylinders' translation.
> But when I use other values together with rand() I can prevent the cylinders
> from overlapping but then everything looks too orderly.
>
> So I basically want the bunch of cylinders to look like in the picture just
> without the 4 or 5 overlapping cylinders.
>
> I know it might work with the trace function to check whether they overlap and
> so I read through Jonathan Hunt's pebbles.pov where he uses this.
> But I found it very difficult and I don't know how too adapt the trace function
> to my scene.
>
> Or maybe it is possible to put all the translation data into an output file, and
> manually edit the overlapping cylinders and then reimport it? But I have no clue
> how to do this either.
Hi Simone!
Can I suggest a different function than rand() for placing the cylinders - there
is a mathematical set of functions call low discrepancy sequences, and the
simplest one of those to implement in POV macros is a Halton Sequence. The
output looks like the output from rand(), but the positions don't overlap (the
positions it produces just fill in the spaces, so the points get more and more
closely packed).
The code is:
#macro halton( index, base )
#local out = 0.0;
#local fraction = 1.0 / base;
#local i = index;
#while( i > 0 )
#local remainder = mod( i, base );
#local out = out + (fraction * remainder);
#local i = int(i / base);
#local fraction = fraction / base;
#end
out
#end
and you call it with a integer value that simply increases - e.g. a loop counter
(1,2,3,4,5,6...) - and a prime number as the base (2, 3, 5 etc - the smaller
ones give more pleasing results for what you are wanting to do)
You can create another macro to output a 2D coord:
#macro halton2D( n )
#local baseX = 2;
#local baseY = 3;
< halton( n, baseX ), halton( n, baseY ), 0 >
#end
then you could place the cylinders with something like this:
union {
#declare num_cylinders = 100;
#declare i = 0;
#while( i < num_cylinders )
object { cyl translate halton2D( i ) * some_scale_value }
#declare i = i + 1;
#end
}
You can also place objects in full 3D space with a helper like:
#macro halton3D( n )
#local baseX = 2;
#local baseY = 3;
#local baseZ = 5;
< halton( n, baseX ), halton( n, baseY ), halton( n, baseZ ) >
#end
Cheers,
Edouard.
Post a reply to this message
|
|
| |
| |
|
|
From: Stephen
Subject: Re: how to prevent overlapping random objects?
Date: 15 Aug 2010 18:02:41
Message: <4c686401@news.povray.org>
|
|
|
| |
| |
|
|
On 15/08/2010 9:58 PM, Edouard wrote:
> Hi Simone!
>
> Can I suggest a different function than rand() for placing the cylinders - there
> is a mathematical set of functions call low discrepancy sequences, and the
> simplest one of those to implement in POV macros is a Halton Sequence. The
> output looks like the output from rand(), but the positions don't overlap (the
> positions it produces just fill in the spaces, so the points get more and more
> closely packed).
>
> The code is:
>
Thanks for that Edouard it looks very interesting.
--
Best Regards,
Stephen
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Hi,
> I created a bunch of cylinders with a while loop and the rand() function.
> But some of the cylinders are overlapping like in this picture:
> http://alien23.de/test4/cylinders.jpg
>
> The code I used was this:
>
> #declare zufall_1= seed (1199);
> #declare zufall_2= seed (342);
>
> #declare ab=.09; /// abstand
>
> #declare Loop_x =0;
>
> #declare Loop_x_end =9;
>
> union {
> #while (Loop_x< Loop_x_end)
> #declare Loop_y =0;
> #declare Loop_y_end =9;
> #while (Loop_y< Loop_y_end)
>
> #if (even (Loop_y))
> object { cyl translate
> <-.08+Loop_x*ab+rand(zufall_1)/15+Loop_x*.05 ,
> Loop_y*ab+rand(zufall_1)/15+Loop_y*.035 , 0> }
>
> #else
> object { cyl translate<.1+Loop_x*ab-rand(zufall_1)/1+Loop_x*.05
> , Loop_y*ab+rand(zufall_1)/16+Loop_y*.025 , 0> }
> #end
>
> #declare Loop_y=Loop_y+1;
> #end
>
> #declare Loop_x=Loop_x+1;
> #end
> }
>
> ------------------------------------------------------
> By now I've spent hours trying out other values for the cylinders' translation.
> But when I use other values together with rand() I can prevent the cylinders
> from overlapping but then everything looks too orderly.
>
> So I basically want the bunch of cylinders to look like in the picture just
> without the 4 or 5 overlapping cylinders.
>
> I know it might work with the trace function to check whether they overlap and
> so I read through Jonathan Hunt's pebbles.pov where he uses this.
> But I found it very difficult and I don't know how too adapt the trace function
> to my scene.
>
> Or maybe it is possible to put all the translation data into an output file, and
> manually edit the overlapping cylinders and then reimport it? But I have no clue
> how to do this either.
>
>
> Best wishes,
>
> Simone
>
>
>
>
>
>
Yet another possibility:
First, you need to create two set of cylinders. One will be the one that
is visible, the second will never be viewed and you never give it any
texture.
The cylinders in the second set will be twice the radius of the first
and slightly longer.
Next, as you create your cylinders, you make inside teste against the
previour large cylinders. If the test is positive, it means that you
have overlaping objects. Ignore that coordinate and chose another.
The extra computing should be acceptable in your case as you don't seem
to have that many cylinders, 81 to 100 cylinders is still "small".
Then, you can also place the cylinders in a regular gird and jitter them
somewhat. It can be acceptable if you have comparatively small cylinders
in a large gird. Here, you only need to set the random displacement just
large enough so that the cylinders can at most just touch.
Alain
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Stephen wrote:
> > ... simplest one of those to implement in POV macros is a Halton Sequence ...
>
> Thanks for that Edouard it looks very interesting.
Halton Sequences are really interesting and useful - I happened to be instant
messaging a friend in London a couple of weeks ago and mentioned that I used
them all the time, and he pointed to me to a sketch he did for SIGGraph on them!
Take a look if you are interested - it's the one entitled "Fast Object
Distribution" on this page: http://www.andrewwillmott.com/s2007
Until I looked at his sketch I hadn't realised the property that each subsequent
value in the sequence is guaranteed to be almost maximally distance from the
previous one, and that you can use that to drive variations like object colour
or size (so the same types of tree are close to each other, but big trees are
always interspersed with small trees, etc). Really fascinating stuff.
I'd love to find the time to write up an article in the Wiki on them for POVRay,
but it's hard finding time with two young kids :-)
Cheers,
Edouard.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thanks to all of you for the great advice!
I will consider all of it and try around a little to improve my poor POV-Ray
skills when it comes to things like arrays, macros and the like ...
The halton sequence is really a cool piece of code, I tried it and it renders
very quickly. I can imagine it's also useful for all kinds of things, like
abstract cityscapes, floating objects and things like that.
At first it seemed to me really miraculous how it worked, but I managed to put
the output values in a text object and now I slowly start to understand the
workings of macros a little, I hope.
Best wishes,
Simone
Post a reply to this message
|
|
| |
| |
|
|
From: Thomas de Groot
Subject: Re: how to prevent overlapping random objects?
Date: 16 Aug 2010 03:10:37
Message: <4c68e46d@news.povray.org>
|
|
|
| |
| |
|
|
"Edouard" <pov### [at] edouardinfo> schreef in bericht
news:web.4c688dc1d03a138b20e671e70@news.povray.org...
> Until I looked at his sketch I hadn't realised the property that each
> subsequent
> value in the sequence is guaranteed to be almost maximally distance from
> the
> previous one, and that you can use that to drive variations like object
> colour
> or size (so the same types of tree are close to each other, but big trees
> are
> always interspersed with small trees, etc). Really fascinating stuff.
These are interesting thoughts indeed. I certainly shall have to experiment
with this. Thank you!
>
> I'd love to find the time to write up an article in the Wiki on them for
> POVRay,
> but it's hard finding time with two young kids :-)
True. Put them to work on POV-Ray candy ;-)
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 16/08/2010 2:00 AM, Edouard wrote:
> I'd love to find the time to write up an article in the Wiki on them for POVRay,
> but it's hard finding time with two young kids:-)
>
As Thomas said, this will require experimenting with. :-D
And if you can find time to make two young kids then doing a Wiki
article will be a breeze ;-)
--
Best Regards,
Stephen
Post a reply to this message
|
|
| |
| |
|
|
From: Christian Froeschlin
Subject: Re: how to prevent overlapping random objects?
Date: 16 Aug 2010 11:05:35
Message: <4c6953bf@news.povray.org>
|
|
|
| |
| |
|
|
Simone wrote:
> At first it seemed to me really miraculous how it worked, but I managed to put
> the output values in a text object
Note that there is also a #debug directive for text stream output.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |