POV-Ray : Newsgroups : povray.general : Re: Difference Small objects and Glass Cube Server Time
2 Aug 2024 20:21:31 EDT (-0400)
  Re: Difference Small objects and Glass Cube (Message 11 to 15 of 15)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Tor Olav Kristensen
Subject: Re: Difference Small objects and Glass Cube
Date: 16 Sep 2004 03:10:20
Message: <41493c5c$1@news.povray.org>
Tor Olav Kristensen wrote:

> Slime wrote:
> 
>>>  If the functions supported true recursion it would be rather easy:
>>>
>>> #declare MandIter =
>>>  function(n, Re, Im, Zr, Zi)
>>>  { select(n>50 | Zr*Zr+Zi*Zi > 2, 0,
>>>           MandIter(n+1, Re, Im, Zr*Zr-Zi*Zi+Re, 2*Zr*Zi+Im), n/50)
>>>  }
>>>
>>> #declare Mandel = function(Re, Im) { MandIter(0, Re, Im, Re, Im) }
>>>
>>>  (Now you could do for example "pigment { function { Mandel(x,y) }
>>
>>
>> ... }".)
>>
>> And you can! Looks good. =)
> 
> ...
> 
> Woaw ! That's nice. AFAIR from the pre-beta test period for v3.5,
> it should not be possible for users to define recursive functions.
> 
> But obviously this has changed since then. (Unintentionally ?)


Here's what happened when I tried the same with v3.5:

   Persistence of Vision Ray Tracer(tm) for Windows.
   ...
     This is version 3.5.icl.win32.
   ...
   File: E:\Raytracinger\RecursiveFunctionTest.pov  Line: 14
       )

     } <----ERROR

   Parse Error: Recursive function calls are not allowed!


   Returned from renderer with error status



This time I also checked the output when rendering with v3.6:

   Persistence of Vision Raytracer(tm) for Windows.
   ...
     This is version 3.6.1.icl8.win32.
   ...
   File: E:\Raytracinger\RecursiveFunctionTest.pov  Line: 14
   Possible Parse Error: Recursive function calls are not allowed!



- So it should still not be possible.

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: Slime
Subject: Re: Difference Small objects and Glass Cube
Date: 16 Sep 2004 09:09:09
Message: <41499075$1@news.povray.org>
>    Possible Parse Error: Recursive function calls are not allowed!

That's weird... and yet I use recursion all the time without problems. Never
noticed that error.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Mike Andrews
Subject: Re: Difference Small objects and Glass Cube
Date: 16 Sep 2004 14:15:00
Message: <web.4149d7868f309b73c717c9af0@news.povray.org>
Hi Tor,

Tor Olav Kristensen <tor### [at] TOBEREMOVEDgmailcom> wrote:
> Woaw ! That's nice. AFAIR from the pre-beta test period for v3.5,
> it should not be possible for users to define recursive functions.
>
> But obviously this has changed since then. (Unintentionally ?)
>
>

I haven't seen this change in any of the change-logs, maybe it's an 'Easter
Egg' :-)

There's an nice variation I remembered from my days playing with Fractint,
so I went looking ...

[Mandelbrot code snipped]
>
> --
> Tor Olav
> http://subcube.net
> http://subcube.com

// start of code

#version 3.6;

#include "colors.inc"

// returns the 'potential' surface from 'Fractint'
#declare IterFn =
   function(N, Max, Bail, Slope, Re, Im, Zr, Zi) {
     select(
       N = Max | sqrt(Zr*Zr + Zi*Zi) > Bail,
       0,
       IterFn(N + 1, Max, Bail, Slope, Re, Im, Zr*Zr - Zi*Zi + Re, 2*Zr*Zi +
Im),
       min(1,select(N = Max, 0, pow(log(sqrt(Zr*Zr +
Zi*Zi))/pow(2,N),Slope), 0))
     )
   }

#declare MandelFn = function(Re, Im, Max, Bail, Slope) { IterFn(0, Max,
Bail, Slope, Re, Im, Re, Im) }

isosurface {
  function { y + MandelFn(x-0.7, z, 500, 2000, 0.6) }
  contained_by { box {-<3,1,3>,<3,0,3> } }
  max_gradient 6.5
  pigment {
    function { 1-MandelFn(x-0.7, z, 500, 2000, 0.3) }
    color_map {
      [ 0.0 color Black   ]
      [ 0.25 color Cyan    ]
      [ 0.5 color Magenta ]
      [ 0.75 color Yellow  ]
      [ 1.0 color White   ]
    }
  }
  rotate 10*z
  rotate -50*x
  translate 3*z
}

background { rgb <.5,.6,.7> }

light_source { <-2,4,0>*100 colour rgb 1 }

// end of code


Post a reply to this message

From: Warp
Subject: Re: Difference Small objects and Glass Cube
Date: 16 Sep 2004 19:52:09
Message: <414a2729@news.povray.org>
Slime <fak### [at] emailaddress> wrote:
> And you can! Looks good. =)

  Oh! Seems like 3.6 has more surprises than I expected. :-o

  During the beta-test of POV-Ray 3.5 I was working with Thorsten
testing the possibility of adding support for recursive calls in
functions, and they more or less worked ok, but due to some problems
which were difficult to solve back then it was decided that recursion
would not be supported (and explicitly disallowed).

  During the development of 3.6 I never heard of anything related
to this, so I assumed that no change had been done. However, seems
that something has been done (either purposely or inadvertedly, I don't
know which).

  Cool. This opens a whole new set of possibilities for functions.
(I just hope this was not just a mistake which will be "corrected"
in the next release... ;) )

> (I find it impressive that you could do that from memory without actually
> checking if it worked... though I think the > 2 should be > 4)

  I have written the mandelbrot set code so many times that I can do
it in my dreams... Except that this time I didn't remember to raise
the 2 to the square, so you are right: It should be 4, not 2. Perhaps
I'm getting old.

-- 
#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

From: Warp
Subject: Re: Difference Small objects and Glass Cube
Date: 16 Sep 2004 19:53:50
Message: <414a278e@news.povray.org>
Slime <fak### [at] emailaddress> wrote:
> >   I didn't know user-defined functions supported recursion or iteration...

> Recursion I'm pretty sure they do support directly

  The thing is that it was not supported in 3.5, and since I never heard
of any change regarding this, I assumed it was still unsupported.
  Well, you always learn something new. :)

-- 
#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

<<< Previous 10 Messages Goto Initial 10 Messages

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