POV-Ray : Newsgroups : povray.general : Re: Difference Small objects and Glass Cube Server Time
6 Nov 2024 04:18:16 EST (-0500)
  Re: Difference Small objects and Glass Cube (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: nomail
Subject: Re: Difference Small objects and Glass Cube
Date: 12 Sep 2004 19:25:01
Message: <web.4144daa28f309b731858e3680@news.povray.org>
Well if I use scattering media, and those picutres contains fractals: and
POVRAY know what fractal is: can I use fractal for pattern in scattering
media?
Or say in other word : can I make scattering media "follows" fractal
results?


Post a reply to this message

From: Slime
Subject: Re: Difference Small objects and Glass Cube
Date: 12 Sep 2004 19:53:46
Message: <4144e18a$1@news.povray.org>
> Well if I use scattering media, and those picutres contains fractals: and
> POVRAY know what fractal is: can I use fractal for pattern in scattering
> media?
> Or say in other word : can I make scattering media "follows" fractal
> results?


(Is there a reason you didn't respond to my post specifically?)

If your pattern is based on a fractal, then you may have a few options:

 - If it's the mandel or julia fractals, POV-Ray has built-in patterns to
handle these.
 - If you can express the fractal through recursion or iteration as a
function{}, you can use that to construct the density pattern.
 - Otherwise, you'll probably have to somehow generate a density_file (.df3)
based on your fractal and use this. (This could be done with an external
program or with POV-Ray and a utility that turns a series of 2D images into
the 3D df3 file.

However, if none of these options are practical, then you should probably
use the solution that Mike Williams gave.

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


Post a reply to this message

From: nomail
Subject: Re: Difference Small objects and Glass Cube
Date: 12 Sep 2004 21:25:00
Message: <web.4144f64c8f309b731858e3680@news.povray.org>
"Slime" <fak### [at] emailaddress> wrote:
> > Well if I use scattering media, and those picutres contains fractals: and
> > POVRAY know what fractal is: can I use fractal for pattern in scattering
> > media?
> > Or say in other word : can I make scattering media "follows" fractal
> > results?
>
>
> (Is there a reason you didn't respond to my post specifically?)

Slime: I just have a problem:and ask other how to resolve problem,have idea
and ask opinion: and wont to anyone on this group would be angry at me.
>
> If your pattern is based on a fractal, then you may have a few options:

Yes, mine pattern is fractal.

>  - If it's the mandel or julia fractals, POV-Ray has built-in patterns to
> handle these.
>  - If you can express the fractal through recursion or iteration as a
> function{}, you can use that to construct the density pattern.
>  - Otherwise, you'll probably have to somehow generate a density_file (.df3)
> based on your fractal and use this. (This could be done with an external
> program or with POV-Ray and a utility that turns a series of 2D images into
> the 3D df3 file.
>
> However, if none of these options are practical, then you should probably
> use the solution that Mike Williams gave.
>
>  - Slime
>  [ http://www.slimeland.com/ ]

This part  with pattern in scattering media looks best solution for me:
thanks
Any other idea?


Post a reply to this message

From: Warp
Subject: Re: Difference Small objects and Glass Cube
Date: 14 Sep 2004 04:33:25
Message: <4146acd5@news.povray.org>
Slime <fak### [at] emailaddress> wrote:
>  - If you can express the fractal through recursion or iteration as a
> function{}, you can use that to construct the density pattern.

  I didn't know user-defined functions supported recursion or iteration...

-- 
#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: Thorsten Froehlich
Subject: Re: Difference Small objects and Glass Cube
Date: 14 Sep 2004 09:56:43
Message: <4146f89b$1@news.povray.org>
In article <4146acd5@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   I didn't know user-defined functions supported recursion or iteration...

You can view "sum" and "prod" as iterations...

    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: Warp
Subject: Re: Difference Small objects and Glass Cube
Date: 14 Sep 2004 11:28:29
Message: <41470e1d@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> >   I didn't know user-defined functions supported recursion or iteration...

> You can view "sum" and "prod" as iterations...

  Perhaps, but they are very limited.

  For example, I can't think of any way of making a mandelbrot function
using those.
  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) } ... }".)

-- 
#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: Slime
Subject: Re: Difference Small objects and Glass Cube
Date: 15 Sep 2004 20:00:11
Message: <4148d78b$1@news.povray.org>
>   I didn't know user-defined functions supported recursion or iteration...

Recursion I'm pretty sure they do support directly, although you need a base
case which has to kick in before 1024 recursions:

plane {
 -z,0
 pigment {
  #local myfunc = function(x) {select(x,0,x+myfunc(x-1))}
  function {myfunc(x)}
 }
 finish {ambient 1 diffuse 0}
}

camera {location -z*10 look_at 0}


Iteration isn't supported directly except with the sum/prod functions as
Thorsten said. What I tend to do when I need iteration is code it with SDL,
which results in a huge function and is only feasible in some cases
(excluding cases where some variable needs to be kept track of and its value
responded to in future iterations). For instance, this function (from my UV
Oven macro) does an O(log(n)) search through an SDL array in order to call
the function in the n'th index:

 #macro generateCallFaceColor(low, high)
  #if (low = high)
   facecolor[low](u,v, colorindex)
  #else
   #local mid = floor((low + high)*0.5);
   select(
    n - mid - 0.5,
    generateCallFaceColor(low, mid),
    generateCallFaceColor(mid+1, high)
   )
  #end
 #end
 #local callfacecolor = function(n, u, v, colorindex) {
  select(n,
   0.5, // if n < 0, use grey
   generateCallFaceColor(0, numfaces-1)
  )
 }

The resulting function doesn't actually iterate, but it behaves as though it
does.

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


Post a reply to this message

From: Slime
Subject: Re: Difference Small objects and Glass Cube
Date: 15 Sep 2004 20:00:17
Message: <4148d791$1@news.povray.org>
>   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. =)

(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)

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


Post a reply to this message

From: Slime
Subject: Re: Difference Small objects and Glass Cube
Date: 15 Sep 2004 23:36:49
Message: <41490a51$1@news.povray.org>
> Recursion I'm pretty sure they do support directly, although you need a
base
> case which has to kick in before 1024 recursions:


By the way, I think I'll take this opportunity to say that if POV-Ray's
functions implemented tail recursion as iteration internally, that would
make them a lot more powerful (by removing the limit on recursion depth,
letting us effectively use it for iteration). Feature request! =)

(That feature plus support for data types other than numbers (which I'm sure
is easier said than done) might actually make POV functions nearly as
powerful as scheme or lisp.)

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


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Difference Small objects and Glass Cube
Date: 16 Sep 2004 02:57:26
Message: <41493956$1@news.povray.org>
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 ?)


#version 3.6;

#include "colors.inc"

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

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

plane {
   -z, -2.5
   pigment {
     function { MandelFn(x, y) }
     color_map {
       [ 0.1 color Black   ]
       [ 0.3 color Cyan    ]
       [ 0.5 color Magenta ]
       [ 0.7 color Yellow  ]
       [ 0.9 color White   ]
     }
   }
   finish { ambient color White }
   translate 0.7*x
}

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


Post a reply to this message

Goto Latest 10 Messages Next 5 Messages >>>

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