POV-Ray : Newsgroups : povray.advanced-users : Isosurface custom Function? / Macro? : Re: Isosurface custom Function? / Macro? Server Time
5 Jul 2024 14:58:46 EDT (-0400)
  Re: Isosurface custom Function? / Macro?  
From: Mike Williams
Date: 13 Nov 2007 15:02:21
Message: <JnqR2LAsKgOHFwUs@econym.demon.co.uk>
Wasn't it Woody who wrote:
>I'm trying to create two macros for use with Iso-surfaces
>they are
>
>#macro mac_1()
>    #if(abs(x)+abs(y)<=0.05)
>          0
>    #else
>          1
>    #end
>#end
>
>#macro mac_2(a,b,c)
>   abs(a)+abs(b)
>#end
>
>
>they are called from the isosurface as
>
>isosurface{
>function{ mac_1() }
>
>}
>
>isosurface{
>function { mac_2(x,y,z) }
>}
>
>both produce 'float expected vector identifier found instead' errors.
>
>anybody got any ideas

Macros are evaluated once, at parse time. Isosurface functions need to
be evaluated for many possible x,y,z values at run time. So you have to
rewrite your expressions as functions, not macros.

The second one is easy to write:
  function { abs(x)+abs(y) }

The problem is that the expression is >=0 everywhere. It's only zero
along an infinitely thin line along the z axis, and you see nothing.


You could write mac_1 as
    function { select ((abs(x)+abs(y)-0.05),1,0) }
but that doesn't produce any results either because the isosurface root
finder doesn't work well with functions that have an infinite gradient.


A different function that creates the same surface as that, but
evaluates differently at points that are not on the surface is
    function { abs(x)+abs(y)-0.05 }
which renders quite nicely.


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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