POV-Ray : Newsgroups : povray.general : Functions (again) Server Time
6 Nov 2024 14:24:20 EST (-0500)
  Functions (again) (Message 1 to 3 of 3)  
From: Felbrigg
Subject: Functions (again)
Date: 25 May 2004 08:40:34
Message: <40b33ec2$1@news.povray.org>
Can functions be procedural rather than mathematic?  If so can someone show
me how it might be done

i.e rather than..

#declare foo2 = function(x, y, z) { x + y * z }

can I do something like this, where the function returns a variables
value....

#declare foo2 = function(x, y, z)
    {
    #declare r = 0;
    #if(x>10)
        #declare r = 0.5;
    #end
    #if(y>10)
        #declare r = r + 0.5;
    #end

    return r
     }


-- 
#include"colors.inc"#include"metals.inc"text{ttf"arial.ttf""Felbrigg"1,0text
ure{pigment{Red*.9}}translate<-1.8,0,0>}sphere{<0,0,0>,6hollow
texture{T_Chrome_5E}}camera{location<0,0,-5>look_at<0,0,0>}light_source{<0,-
2,-5>colour White}


Post a reply to this message

From: Christopher James Huff
Subject: Re: Functions (again)
Date: 25 May 2004 12:27:06
Message: <cjameshuff-315426.11273325052004@news.povray.org>
In article <40b33ec2$1@news.povray.org>,
 "Felbrigg" <som### [at] microsoftcom> wrote:

> Can functions be procedural rather than mathematic?  If so can someone show
> me how it might be done

You can not do "non-mathematical" functions. You can do conditional 
functions, though. Look at the select() function...

select(COND, A, B [, C])

If C is left out: if COND < 0, A is used, otherwise B.
If C is included: if COND < 0, A is used, if COND == 0, B is used, if 
COND > 0, C is used.

#declare foo2 = function {
    select(x - 10, 0, 0, 0.5) + select(y - 10, 0, 0, 0.5)
}

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Felbrigg
Subject: Re: Functions (again)
Date: 25 May 2004 12:36:34
Message: <40b37612@news.povray.org>
Hey, thats what I needed, thanks very much!


Post a reply to this message

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