POV-Ray : Newsgroups : povray.binaries.images : problem with functions.inc Server Time
15 May 2024 17:58:38 EDT (-0400)
  problem with functions.inc (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Norbert Kern
Subject: problem with functions.inc
Date: 1 Sep 2015 07:30:02
Message: <web.55e58a984a2649cbe2e8c9770@news.povray.org>
Hi,
here is minimal code for the famous burning ship fractal.
It renders fine as long as I don't include functions.inc (in another context I
need functions.inc).
Does anybody know the reason?


// using code from Tor Olav Kristensen / Slime  Difference Small objects and
Glass Cube
http://news.povray.org/povray.general/message/%3C41493956%241%40news.povray.org%3E/#%3C41493956%241%40news.povray.org%3
E

// formula from Paul Nylander  Fractals
http://bugman123.com/Fractals/index.html

#version 3.7;

global_settings {
        assumed_gamma 2.2
}

//#include "functions.inc" // uncommenting this line will cause a crash
                           // (3.7.0.msvc10.win64 / 3.6.2.msvc9.win64)
camera {
        location <0,0,-1>
        look_at <0,0,0>
        right x*image_width/image_height
        up y
        sky -y
        direction z*1.5
}

#declare IterFn =
function (N, Re, Im, Zr, Zi) {
        select (
                N > 300 | Zr*Zr+Zi*Zi > 4,
                0,
                IterFn (N+1, Re, Im, Zr*Zr-Zi*Zi+Re, 2*abs (Zr*Zi)+Im),
                N/300
        )
}

#declare BurningShip = function (Re, Im) {IterFn (0, Re, Im, Re, Im)}

plane {
        -z, -2.5
 texture {
                pigment {
                        function {BurningShip (x,y)}
                        color_map {
                                [0      rgb -1]
                                [0.01   rgb 1]
                                [1      rgb -1]
                        }
                }
                finish {ambient 1}
                translate <1.745,0.0375,0>
                scale 27
        }
}

Norbert Kern


Post a reply to this message


Attachments:
Download 'burning_ship_fn.jpg' (319 KB)

Preview of image 'burning_ship_fn.jpg'
burning_ship_fn.jpg


 

From: scott
Subject: Re: problem with functions.inc
Date: 1 Sep 2015 09:35:40
Message: <55e5a9ac@news.povray.org>
On 01/09/2015 12:25, Norbert Kern wrote:
> Hi,
> here is minimal code for the famous burning ship fractal.
> It renders fine as long as I don't include functions.inc (in another context I
> need functions.inc).
> Does anybody know the reason?

It seems it's nothing special about functions.inc, declaring *any* 
function before your IterFn causes the crash.


Post a reply to this message

From: Cousin Ricky
Subject: Re: problem with functions.inc
Date: 1 Sep 2015 11:22:48
Message: <55e5c2c8$1@news.povray.org>
On 09/01/2015 07:25 AM, Norbert Kern wrote:
> //#include "functions.inc" // uncommenting this line will cause a crash
>                             // (3.7.0.msvc10.win64 / 3.6.2.msvc9.win64)

More specifically, a hard crash (a segmentation fault on my system).

POV-Ray version: 3.7.0.unofficial (g++ 4.8 @ x86_64-unknown-linux-gnu)
Operating system: openSUSE 13.2 (GNU/Linux)
CPU: Intel Core i7

I also confirm Scott's observation.


Post a reply to this message

From: Norbert Kern
Subject: Re: problem with functions.inc
Date: 1 Sep 2015 11:35:01
Message: <web.55e5c57bfed76a76e2e8c9770@news.povray.org>
> declaring *any* function before your IterFn causes the crash.



Thanks very much

Norbert


Post a reply to this message

From: Cousin Ricky
Subject: Re: problem with functions.inc
Date: 1 Sep 2015 11:40:34
Message: <55e5c6f2@news.povray.org>
On 2015-09-01 07:25 AM (-4), Norbert Kern wrote:
> #declare IterFn =
> function (N, Re, Im, Zr, Zi) {
>          select (
>                  N > 300 | Zr*Zr+Zi*Zi > 4,
>                  0,
>                  IterFn (N+1, Re, Im, Zr*Zr-Zi*Zi+Re, 2*abs (Zr*Zi)+Im),
>                  N/300
>          )
> }

Reducing the recursion level does not prevent the crash.  I tried all 
the way down to 1.


Post a reply to this message

From: Anthony D  Baye
Subject: Re: problem with functions.inc
Date: 1 Sep 2015 15:00:01
Message: <web.55e5f483fed76a76a36927440@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
> On 2015-09-01 07:25 AM (-4), Norbert Kern wrote:
> > #declare IterFn =
> > function (N, Re, Im, Zr, Zi) {
> >          select (
> >                  N > 300 | Zr*Zr+Zi*Zi > 4,
> >                  0,
> >                  IterFn (N+1, Re, Im, Zr*Zr-Zi*Zi+Re, 2*abs (Zr*Zi)+Im),
> >                  N/300
> >          )
> > }
>
> Reducing the recursion level does not prevent the crash.  I tried all
> the way down to 1.

The reason for this, I believe, is that pic doesn't support recursive functions.
You can get away with exactly one, if -and only if- it is defined before
anything else in the file.

Regards,
A.D.B.


Post a reply to this message

From: Anthony D  Baye
Subject: Re: problem with functions.inc
Date: 1 Sep 2015 18:00:01
Message: <web.55e61fb8fed76a762aaea5cb0@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> Cousin Ricky <ric### [at] yahoocom> wrote:
> > On 2015-09-01 07:25 AM (-4), Norbert Kern wrote:
> > > #declare IterFn =
> > > function (N, Re, Im, Zr, Zi) {
> > >          select (
> > >                  N > 300 | Zr*Zr+Zi*Zi > 4,
> > >                  0,
> > >                  IterFn (N+1, Re, Im, Zr*Zr-Zi*Zi+Re, 2*abs (Zr*Zi)+Im),
> > >                  N/300
> > >          )
> > > }
> >
> > Reducing the recursion level does not prevent the crash.  I tried all
> > the way down to 1.
>
> The reason for this, I believe, is that pic

pov* -- stupid ipod.

anyway... it causes your system to crash, or just causes povray to crash?

Regards,
A.D.B.


Post a reply to this message

From: Norbert Kern
Subject: Re: problem with functions.inc
Date: 1 Sep 2015 19:25:01
Message: <web.55e63331fed76a76e2e8c9770@news.povray.org>
"Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:

> anyway... it causes your system to crash, or just causes povray to crash?
>
> Regards,
> A.D.B.

Hi Anthony,
only povray. I condensed the problem in perhaps 100 steps by deleting nearly
everything including tests with 3.6 and on a second pc.
There were similar problems with other (typically recursive) functions in the
past, but here I was getting angry, because I like this special fractal very
much.

Norbert


Post a reply to this message

From: scott
Subject: Re: problem with functions.inc
Date: 2 Sep 2015 03:16:16
Message: <55e6a240$1@news.povray.org>
>> declaring *any* function before your IterFn causes the crash.
>

>
> Thanks very much

You can get around the problem by unrolling the iteration into 300 
different functions in an array:


#declare MAX_ITERATIONS = 300;

#declare Fns = array[MAX_ITERATIONS];
#declare Fns[MAX_ITERATIONS-1] = function (N, Re, Im, Zr, Zi) { 0 }
#local ITERATION = MAX_ITERATIONS-2;
#while(ITERATION>=0)

#declare Fns[ITERATION] =
function (N, Re, Im, Zr, Zi) {
         select (
                 Zr*Zr+Zi*Zi > 4,
                 0,
                 Fns[ITERATION+1] (N+1, Re, Im, Zr*Zr-Zi*Zi+Re, 2*abs 
(Zr*Zi)+Im),
                 ITERATION/300
         )
}

#local ITERATION=ITERATION-1;
#end

#declare BurningShip = function (Re, Im) {Fns[0] (0, Re, Im, Re, Im)}


Post a reply to this message

From: Norbert Kern
Subject: Re: problem with functions.inc
Date: 2 Sep 2015 04:15:00
Message: <web.55e6af2efed76a769dd03fb90@news.povray.org>
scott <sco### [at] scottcom> wrote:

> You can get around the problem by unrolling the iteration into 300
> different functions in an array:
>
>
> #declare MAX_ITERATIONS = 300;
>
> #declare Fns = array[MAX_ITERATIONS];
> #declare Fns[MAX_ITERATIONS-1] = function (N, Re, Im, Zr, Zi) { 0 }
> #local ITERATION = MAX_ITERATIONS-2;
> #while(ITERATION>=0)
>
> #declare Fns[ITERATION] =
> function (N, Re, Im, Zr, Zi) {
>          select (
>                  Zr*Zr+Zi*Zi > 4,
>                  0,
>                  Fns[ITERATION+1] (N+1, Re, Im, Zr*Zr-Zi*Zi+Re, 2*abs
> (Zr*Zi)+Im),
>                  ITERATION/300
>          )
> }
>
> #local ITERATION=ITERATION-1;
> #end
>
> #declare BurningShip = function (Re, Im) {Fns[0] (0, Re, Im, Re, Im)}

wow, it works!
Thank you very much.

Norbert


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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