POV-Ray : Newsgroups : povray.general : limited exclusion/inclusion object placment..needs improvement Server Time
27 Nov 2024 08:53:38 EST (-0500)
  limited exclusion/inclusion object placment..needs improvement (Message 1 to 4 of 4)  
From: [GDS|Entropy]
Subject: limited exclusion/inclusion object placment..needs improvement
Date: 13 Feb 2009 00:44:27
Message: <499508bb$1@news.povray.org>
Hello,

Lets assume we have an area (or areas) of undefined shape, and we wish to 
place objects everywhere *but* that spot in 3 dimensions or two.

Would this normally be accomplished by some horrific inversion of the 
Trace() function, or calls to a min/max_extent vector array macro for each 
object to be tested against?
It seems that it would be awful to test every vector against every other 
vector in two or more large arrays...so that can't be the right way to do 
it...

In a more simple scenario if we knew that the space we wished to (or to NOT) 
populate was everywhere between <-5,-5,-5> and <5,5,5>, I was able to come 
up with the folowing:
  #if (((vectorArray[i].x <= vectorB.x) & (vectorArray[i].x >= vectorA.x)) &
       ((vectorArray[i].y <= vectorB.y) & (vectorArray[i].y >= vectorA.y)) &
       ((vectorArray[i].z <= vectorB.z) & (vectorArray[i].z >= vectorA.z)))

This does NOT take mixed sign vectors well at all, but works nicely with 
everything else that I have tested it with.

How can I fix that? Does it involve breaking the if condition up into 
seperate blocks or something?

I've posted the source in p.t.s-f and image in p.b.i.
Its nothing glorious, just something that hit me while drinking my Bass Ale 
earlier...

Does anyone else have any ideas? There has to be a better way.

ian


Post a reply to this message

From: Mike Williams
Subject: Re: limited exclusion/inclusion object placment..needs improvement
Date: 13 Feb 2009 01:11:00
Message: <zpJqcSB00QlJFwyE@econym.demon.co.uk>
Wasn't it [GDS|Entropy] who wrote:
>Hello,
>
>Lets assume we have an area (or areas) of undefined shape, and we wish to
>place objects everywhere *but* that spot in 3 dimensions or two.
>
>Would this normally be accomplished by some horrific inversion of the
>Trace() function, or calls to a min/max_extent vector array macro for each
>object to be tested against?
>It seems that it would be awful to test every vector against every other
>vector in two or more large arrays...so that can't be the right way to do
>it...
>
>In a more simple scenario if we knew that the space we wished to (or to NOT)
>populate was everywhere between <-5,-5,-5> and <5,5,5>, I was able to come
>up with the folowing:
>  #if (((vectorArray[i].x <= vectorB.x) & (vectorArray[i].x >= vectorA.x)) &
>       ((vectorArray[i].y <= vectorB.y) & (vectorArray[i].y >= vectorA.y)) &
>       ((vectorArray[i].z <= vectorB.z) & (vectorArray[i].z >= vectorA.z)))
>
>This does NOT take mixed sign vectors well at all, but works nicely with
>everything else that I have tested it with.
>
>How can I fix that? Does it involve breaking the if condition up into
>seperate blocks or something?
>
>I've posted the source in p.t.s-f and image in p.b.i.
>Its nothing glorious, just something that hit me while drinking my Bass Ale
>earlier...
>
>Does anyone else have any ideas? There has to be a better way.

You can do it with inside() as long as you can create a closed object 
that fits the space.

#declare Object = sphere{0,1.1}
#declare R = seed(123);
#declare N=0;
#while (N<2000)
   #declare Point = <rand(R)*2-1,rand(R)*2-1,rand(R)*2-1>;

   #if (inside(Object,Point))
     // do nothing
   #else
     sphere {Point,0.1 pigment {rgbt <1,1,1,0.9>}}
   #end

   #declare N=N+1;
#end



-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: [GDS|Entropy]
Subject: Re: limited exclusion/inclusion object placment..needs improvement
Date: 13 Feb 2009 12:28:14
Message: <4995adae$1@news.povray.org>
Hmm...I tried the inside statement, but it gave unexpected results and 
rendered slowly when used with semi-complicated objects.

Do min_extent and max_extent produce a cube/bounding box size, or are they 
more form fitting?

ian

"Mike Williams" <nos### [at] econymdemoncouk> wrote in message 
news:zpJ### [at] econymdemoncouk...
> Wasn't it [GDS|Entropy] who wrote:
>>Hello,
>>
>>Lets assume we have an area (or areas) of undefined shape, and we wish to
>>place objects everywhere *but* that spot in 3 dimensions or two.
>>
>>Would this normally be accomplished by some horrific inversion of the
>>Trace() function, or calls to a min/max_extent vector array macro for each
>>object to be tested against?
>>It seems that it would be awful to test every vector against every other
>>vector in two or more large arrays...so that can't be the right way to do
>>it...
>>
>>In a more simple scenario if we knew that the space we wished to (or to 
>>NOT)
>>populate was everywhere between <-5,-5,-5> and <5,5,5>, I was able to come
>>up with the folowing:
>>  #if (((vectorArray[i].x <= vectorB.x) & (vectorArray[i].x >= vectorA.x)) 
>> &
>>       ((vectorArray[i].y <= vectorB.y) & (vectorArray[i].y >= vectorA.y)) 
>> &
>>       ((vectorArray[i].z <= vectorB.z) & (vectorArray[i].z >= 
>> vectorA.z)))
>>
>>This does NOT take mixed sign vectors well at all, but works nicely with
>>everything else that I have tested it with.
>>
>>How can I fix that? Does it involve breaking the if condition up into
>>seperate blocks or something?
>>
>>I've posted the source in p.t.s-f and image in p.b.i.
>>Its nothing glorious, just something that hit me while drinking my Bass 
>>Ale
>>earlier...
>>
>>Does anyone else have any ideas? There has to be a better way.
>
> You can do it with inside() as long as you can create a closed object that 
> fits the space.
>
> #declare Object = sphere{0,1.1}
> #declare R = seed(123);
> #declare N=0;
> #while (N<2000)
>   #declare Point = <rand(R)*2-1,rand(R)*2-1,rand(R)*2-1>;
>
>   #if (inside(Object,Point))
>     // do nothing
>   #else
>     sphere {Point,0.1 pigment {rgbt <1,1,1,0.9>}}
>   #end
>
>   #declare N=N+1;
> #end
>
>
>
> -- 
> Mike Williams
> Gentleman of Leisure
>


Post a reply to this message

From: Alain
Subject: Re: limited exclusion/inclusion object placment..needs improvement
Date: 13 Feb 2009 14:30:20
Message: <4995ca4c$1@news.povray.org>
[GDS|Entropy] nous illumina en ce 2009-02-13 12:28 -->
> Hmm...I tried the inside statement, but it gave unexpected results and 
> rendered slowly when used with semi-complicated objects.
> 
> Do min_extent and max_extent produce a cube/bounding box size, or are they 
> more form fitting?
> 
> ian
> 
Those return the corners of a box.
If your shape is somewhat complicated:
To place outside the shape, you should first check against that box. This is a 
very simple and quick insideness check against a simple box. Then, if you are 
inside the box, do the slower tests against the actual shape.
If you want to place the objects inside the shape, only shoot inside that box to 
minimize the missed shots.

A thing that you should be aware of: you must acount for the dimention of the 
objects that you want to place. So, the target shape must be made larger, or 
smaller, by the dimention of the objects to be placed.
Easy if you place spheres, enlarge or reduce the object by the radius of the 
spheres. If you use scale, use it on the component objects at the origin then 
place them where they belong.
If you test for a complex object, use a croase mockup made out of spheres, boxes 
and cylinders. Never use merge for that target object.

-- 
Alain
-------------------------------------------------
AAAAAA: American Association Against Acronym Abuse and Ambiguity.


Post a reply to this message

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