POV-Ray : Newsgroups : povray.general : function please Server Time
7 Aug 2024 03:23:19 EDT (-0400)
  function please (Message 1 to 6 of 6)  
From: Tom Melly
Subject: function please
Date: 21 Dec 2001 09:40:58
Message: <3c2349fa$1@news.povray.org>
what function would return 1 when x = 0 but 0 when abs(x)>=1 ?

--
#macro G(D,E,F)#local I=array[3]{D,E,F}#local B=0;triangle{#while(
B<3)#while(I[B])A[mod(I[B],10)]+#local I[B]=div(I[B],10);#end<-5,-
2,9>#local B=B+1;#end}#end #local A=array[7]{x,x*2,x*4,y,y*2,y*4,z
}light_source{-x*6-z*9,1}mesh{G(105,10,146)G(105,246,10)G(105,56,
146)G(105,1256,246)G(1256,126,220)G(22156,2216,201)pigment{rgb 1}}//TM


Post a reply to this message

From: Trevor Quayle
Subject: Re: function please
Date: 21 Dec 2001 09:51:16
Message: <3c234c64@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3c2349fa$1@news.povray.org...
> what function would return 1 when x = 0 but 0 when abs(x)>=1 ?


Try:

max(floor(1-abs(x)),0)

-tgq


Post a reply to this message

From:
Subject: Re: function please
Date: 21 Dec 2001 09:52:39
Message: <5ki62u89r6gbkviclcib1imr8vvk60bqg2@4ax.com>
On Fri, 21 Dec 2001 14:40:58 -0000, "Tom Melly" <tom### [at] tomandlucouk> wrote:
> what function would return 1 when x = 0 but 0 when abs(x)>=1 ?

#include "math.inc"
#declare f_for_tom=function(x){clip(1-abs(x),0,1)}

is it good ?

ABX


Post a reply to this message

From:
Subject: Re: function please
Date: 21 Dec 2001 09:56:41
Message: <haj62uopsknnimj13du3mri74r844kijep@4ax.com>
On Fri, 21 Dec 2001 09:51:15 -0500, "Trevor Quayle" <Tin### [at] hotmailcom>
wrote:
> "Tom Melly" <tom### [at] tomandlucouk> wrote in message
> news:3c2349fa$1@news.povray.org...
> > what function would return 1 when x = 0 but 0 when abs(x)>=1 ?
>
> max(floor(1-abs(x)),0)

this could be wrong becouse it return 1 when x=0 but 0 for _all_ other cases.

ABX


Post a reply to this message

From: Trevor Quayle
Subject: Re: function please
Date: 21 Dec 2001 09:58:48
Message: <3c234e28$1@news.povray.org>

news:haj62uopsknnimj13du3mri74r844kijep@4ax.com...
> On Fri, 21 Dec 2001 09:51:15 -0500, "Trevor Quayle"
<Tin### [at] hotmailcom>
> wrote:
> > "Tom Melly" <tom### [at] tomandlucouk> wrote in message
> > news:3c2349fa$1@news.povray.org...
> > > what function would return 1 when x = 0 but 0 when abs(x)>=1 ?
> >
> > max(floor(1-abs(x)),0)
>
> this could be wrong becouse it return 1 when x=0 but 0 for _all_ other
cases.
>
> ABX

Oops, a bit too hasty, didn't really read the fine print there. Thought he
wanted 1 for x=0 and 0 for everything else.

-tgq


Post a reply to this message

From: Tom Melly
Subject: Re: function please
Date: 21 Dec 2001 10:20:50
Message: <3c235352$1@news.povray.org>

news:5ki62u89r6gbkviclcib1imr8vvk60bqg2@4ax.com...

<snip>

Thanks - I'll play with that...


Post a reply to this message

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