POV-Ray : Newsgroups : povray.advanced-users : Trace() and memory Server Time
29 Jul 2024 18:28:08 EDT (-0400)
  Trace() and memory (Message 4 to 13 of 13)  
<<< Previous 3 Messages Goto Initial 10 Messages
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

From: Rune
Subject: Re: Trace() and memory
Date: 12 Dec 2001 18:21:15
Message: <3c17e66b@news.povray.org>
"Alf Peake" wrote:
> 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 :(

It's my preferred method too because it's so simple looking, and it even
parses faster than the alternatives even though you wouldn't think so! Some
tests I posted a long time ago (in povray.general I think) showed that.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Nov 5)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Ron Parker
Subject: Re: Trace() and memory
Date: 12 Dec 2001 21:14:29
Message: <slrna1g3o8.8l3.ron.parker@fwi.com>
On Thu, 13 Dec 2001 00:21:21 +0100, Rune wrote:
> "Alf Peake" wrote:
>> 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 :(
> 
> It's my preferred method too because it's so simple looking, and it even
> parses faster than the alternatives even though you wouldn't think so! Some
> tests I posted a long time ago (in povray.general I think) showed that.

Faster than vdot(Norm,Norm)  (probably, because the latter takes longer to
parse...)

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

From:
Subject: Re: Trace() and memory
Date: 12 Dec 2001 21:19:31
Message: <er3g1u0n23okq486ph06v4sku4ot1b3ifp@4ax.com>

wrote:
> you want something like this ?

here are visualizations from showed code

http://news.povray.org/kk1f1u0tvda2ul55rclt1or8opfkah6i5j@4ax.com
http://news.povray.org/spkf1ugdk9ffq6q3shrfs0f1sqrgf8v9se@4ax.com

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

<<< Previous 3 Messages Goto Initial 10 Messages

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