POV-Ray : Newsgroups : povray.newusers : Newbie question about functions : Re: Newbie question about functions Server Time
2 Jul 2024 21:40:14 EDT (-0400)
  Re: Newbie question about functions  
From: Thorsten Froehlich
Date: 20 Dec 2010 08:00:00
Message: <web.4d0f52a6234b9e10e619b42c0@news.povray.org>
"TheBigH" <nomail@nomail> wrote:
> I see, thank for the heads up. I'm beginning to see that many things that are
> straightforward and logical in other programming languages require awkward
> contortions in POV-ray. Of course I could just do something like
>
> #declare Gridd = function(X,Y) {
>   (( X-floor(X)<thick )|(X-floor(X)>(1-thick))|( Y-floor(Y)<thick
> )|(Y-floor(Y)>(1-thick)))
>   }
>
> because the function I want only takes the values zero and one, but if I ever
> want other values, or more than two different values, I need proper selection of
> cases. And I would definitely have preferred a nice orderly succession of #ifs
> to the horror of nested selects. Oh well.

The real question you should ask yourself is why you need a function at all and
if another macro won't suffice. The primary use of functions is for objects that
require runtime evaluation, i.e. isosurfaces, and a binary selection is not the
best solution. Another user for functions is in user-defined patterns, where
your problem mightbbe much better solved using a map, i.e. a color_map.

Thorsten


Post a reply to this message

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