POV-Ray : Newsgroups : povray.advanced-users : Isosurface custom Function? / Macro? Server Time
3 Jul 2024 05:34:13 EDT (-0400)
  Isosurface custom Function? / Macro? (Message 1 to 5 of 5)  
From: Woody
Subject: Isosurface custom Function? / Macro?
Date: 13 Nov 2007 12:30:00
Message: <web.4739dee61b94503b94e61a50@news.povray.org>
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


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Isosurface custom Function? / Macro?
Date: 13 Nov 2007 13:41:10
Message: <4739efc6$1@news.povray.org>
Woody wrote:
> I'm trying to create two macros for use with Iso-surfaces
> they are

RTFM: <http://www.povray.org/documentation/view/3.6.1/231/>


Post a reply to this message

From: Mike Williams
Subject: Re: Isosurface custom Function? / Macro?
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

From: Alain
Subject: Re: Isosurface custom Function? / Macro?
Date: 13 Nov 2007 16:15:05
Message: <473a13d9$1@news.povray.org>
Mike Williams nous apporta ses lumieres en ce 2007/11/13 15:01:
> 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.
It's only a problem if your treshold is zero. If you increase the treshold, it 
gets whider and whider.
> 
> 


-- 
Alain
-------------------------------------------------
I find that the harder I work, the more luck I seem to have.
Thomas Jefferson


Post a reply to this message

From: Mark Weyer
Subject: Re: Isosurface custom Function? / Macro?
Date: 14 Nov 2007 08:00:00
Message: <web.473af0e13c1b91b3fddaa4670@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> RTFM: <http://www.povray.org/documentation/view/3.6.1/231/>

By the way: Is there a good reason, why function variables may
not be passed to macros? I use to think that Woody's mac_2
example and such are quite sensible.

  Mark Weyer


Post a reply to this message

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