POV-Ray : Newsgroups : povray.advanced-users : Trace() and memory Server Time
29 Jul 2024 12:25:54 EDT (-0400)
  Trace() and memory (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Tim Nikias
Subject: Trace() and memory
Date: 12 Dec 2001 02:02:33
Message: <3C1700A6.28651428@gmx.de>
I've found in the docs that the new trace()-function from POV-Ray3.5
only
checks for an intersection with a declared object.

Now I'm wondering. This, if I want to check for an intersection in a
complex
scene, requires me to declare the entire scene, and thus, also to place
it using
object{}.
So, how much does this affect memory consumption?

And, while we're at it:
If I want to do an algorithm that trace()s a plane and places sphere on
top,
and does so over and over again, but is also supposed to place spheres
ON spheres just placed as well...
Do I have to create an array, in which I save the objects placed, and
call on these
again and again for each new sphere?

So, my main question is:
Is there an easy solution which provides me with a way to use trace() on
a
scene, alter it, and use trace() again after the alterations, without
having to
tamper around with arrays and declarations of objects en mass?

Tim


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Trace() and memory
Date: 12 Dec 2001 05:29:52
Message: <3c1731a0$1@news.povray.org>
In article <3C1700A6.28651428@gmx.de> , Tim Nikias <Tim### [at] gmxde>  
wrote:

> So, how much does this affect memory consumption?

During parsing you need slightly more memory, but no additional memory will
be needed.

As for you problem, you don't need trace to place spheres on a plane.  The
math to know where the plane is in space really isn't that hard...

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Tim Nikias
Subject: Re: Trace() and memory
Date: 12 Dec 2001 06:57:14
Message: <3C1745B9.66BB82A3@gmx.de>
I wasn't literary speaking about "spheres on planes". Take any object, and
any environment. Use trace to place the object anywhere. Now, when I
want to place the next object, it should also consider the new object I just
placed. And this goes on and on, perhaps inside a loop?

Tim


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: Trace() and memory
Date: 12 Dec 2001 07:29:19
Message: <3c174d9f@news.povray.org>
Tim Nikias schrieb in Nachricht <3C1745B9.66BB82A3@gmx.de>...

>Now, when I
>want to place the next object, it should also consider the new object I
just
>placed. And this goes on and on, perhaps inside a loop?


I would say: Just union{} the new Object with the old union{}. This way you
can always trace() against the same object. No arrays needed IMO.

Marc-Hendrik


Post a reply to this message

From:
Subject: Re: Trace() and memory
Date: 12 Dec 2001 07:37:47
Message: <rpje1uknmu0c8ip0530f6dfje5o8hbv0p8@4ax.com>
On Wed, 12 Dec 2001 12:55:37 +0100, Tim Nikias <Tim### [at] gmxde> wrote:

> I wasn't literary speaking about "spheres on planes". Take any object, and
> any environment. Use trace to place the object anywhere. Now, when I
> want to place the next object, it should also consider the new object I just
> placed. And this goes on and on, perhaps inside a loop?

you want something like this ?

#local Base=box{<-1,-1,-1><1,0,1> pigment{granite}}
#local Count=100;
#local Spheres=array[Count];
#local Counter=0;
#local rs=seed(0);
#local R=.1;
#while (Counter<Count)
  #local Found=no;
  #while (!Found)
    #local Start=2*<2*rand(rs)-1,rand(rs),2*rand(rs)-1>;
    #local Dir=<2*rand(rs)-1,rand(rs),2*rand(rs)-1>;
    #local Dir=vnormalize(Dir-Start);
    #local Norm=<0,0,0>;
    #local Intersection=trace(Base,Start,Dir,Norm);
    #if(vlength(Norm)>0)
      #local Center=Intersection+Norm*R;
      #if(Center.y>=R)
        #local Bad=no;
        #local Temp=0;
        #while (Temp<Counter)
          #if(vlength(Spheres[Temp]-Center)<2*R)
            #local Bad=yes;
          #end
          #local Temp=Temp+1;
        #end
        #if(!Bad)
          #local Found=yes;
          #local Spheres[Counter]=Center;
          #local Base=union{
            object{Base}
            sphere{
              Center
              R
              pigment{color rgb .5+.5*<rand(rs)rand(rs)rand(rs)>}
            }
          }
        #end
      #end
    #end
  #end
  #local Counter=Counter+1;
#end

object{Base no_shadow}
camera{
  location <2,2,-3>
  right x*image_width/image_height
  up y
  look_at <0,.5,0>
}
light_source{ y*100 color rgb 1}

ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)&_((x+y)*.7,z,.1)&_((x+y+2)*.7,z,.1)&_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35


Post a reply to this message

From:
Subject: Re: Trace() and memory
Date: 12 Dec 2001 07:39:35
Message: <lsje1ugjcq77mqt0f2k96bfagmt08u593b@4ax.com>
On Wed, 12 Dec 2001 13:29:15 +0100, "Marc-Hendrik Bremer"
<Mar### [at] t-onlinede> wrote:

>Tim Nikias schrieb in Nachricht <3C1745B9.66BB82A3@gmx.de>...
>
> > Now, when I
> > want to place the next object, it should also consider the new object I just
> > placed. And this goes on and on, perhaps inside a loop?
>
>
> I would say: Just union{} the new Object with the old union{}. This way you
> can always trace() against the same object. No arrays needed IMO.

Without arrays with previous parameters intersection testing is much more
complicated. But probably possible.

ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)&_((x+y)*.7,z,.1)&_((x+y+2)*.7,z,.1)&_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35


Post a reply to this message

From: Tim Nikias
Subject: Re: Trace() and memory
Date: 12 Dec 2001 10:19:13
Message: <3C17750F.5249405@gmx.de>
Though I couldn't test your code yet (POV-Ray doesn't do multiple
instances yet, and I've got an I/O thingy running), I had a close look at it.

Somehow, I don't know why, there is this rumour that objects itself
can't be stored in arrays. You can actually do things like:

#declare Objects=array[3]
 {sphere{<0,0,0>,1},box{-1,1},cylinder{0,y,1}}

Somehow, most people think you can only store variables in there...

But yes, your code did actually (in some other method, not using objects
themselves) do the job I was talking about. Though that was of no concern,
I just wanted to know, if there is some easier way, some special clue, which
might improve the process.

Seems there is not, but that's fine.

Another thing that was just on my mind:
Using Macros, one could also increase the dimensions of arrays dynamically,
so there is also no need to set an amount beforehand.(Just in case someone was
curious about that).

Tim


Post a reply to this message

From:
Subject: Re: Trace() and memory
Date: 12 Dec 2001 10:30:31
Message: <fmte1ukc8osi309h4db72ja0o8uainlce0@4ax.com>
On Wed, 12 Dec 2001 16:17:35 +0100, Tim Nikias <Tim### [at] gmxde> wrote:
> Though I couldn't test your code yet (POV-Ray doesn't do multiple
> instances yet

POV-Ray does multiple instances, but... with previous beta :-)

> Somehow, I don't know why, there is this rumour that objects itself
> can't be stored in arrays. You can actually do things like:
> #declare Objects=array[3]
> {sphere{<0,0,0>,1},box{-1,1},cylinder{0,y,1}}

of course I know. but it complicates intersection checking.
you considered memory problems and mine seems optimal in this case.

> But yes, your code did actually (in some other method, not using objects
> themselves) do the job I was talking about. Though that was of no concern,
> I just wanted to know, if there is some easier way, some special clue, which
> might improve the process.

My code is universal. Just replace spheres condition (distance<2R) with own
method based on another set of traces or whatever you want.

> Another thing that was just on my mind:
> Using Macros, one could also increase the dimensions of arrays dynamically,
> so there is also no need to set an amount beforehand.(Just in case someone was
> curious about that).

I know. My point was to write readable and fast enough code.

ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)&_((x+y)*.7,z,.1)&_((x+y+2)*.7,z,.1)&_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35


Post a reply to this message

From: JRG
Subject: Re: Trace() and memory
Date: 12 Dec 2001 13:00:51
Message: <3c179b53$1@news.povray.org>
Hmm, do you mean something like this:
http://news.povray.org/povray.binaries.images/20145/?ttop=20670&toff=50 ?

--
Jonathan.


Post a reply to this message

From: Alf Peake
Subject: Re: Trace() and memory
Date: 12 Dec 2001 18:08:18
Message: <3c17e362@news.povray.org>

news:rpje1uknmu0c8ip0530f6dfje5o8hbv0p8@4ax.com...
[snip]
>     #if(vlength(Norm)>0)

There was a discussion on p.u.p re trace() and I think also this
section a while ago on the difficulty of testing for <0,0,0>. This is
the first time I've seen this solution and it seems so simple. I can't
believe I missed it when I first tried to figure out an easy answer :(

Alf


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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