POV-Ray : Newsgroups : povray.advanced-users : Conditional expressions in functions : Re: Conditional expressions in functions Server Time
27 Sep 2021 05:10:35 EDT (-0400)
  Re: Conditional expressions in functions  
From: BayashiPascal
Date: 28 Feb 2021 00:30:01
Message: <web.603b2a358a182d6d6396ca3e0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I was also trying to minimize the processing of vectors, and executed the
> following:
>
> #declare f_Axis = function (Vector) {select (Vector, x, y, z)}
>
> Which worked, but did not give me the expected results.
> My debug statements with str complained that it expected a value, but a vector
> was encountered instead, which leads me to believe that it was returning the
> _vector_ quantities x, y, and z - which I thought functions couldn't do?
>
> modifying/correcting to:
>
> #declare f_Axis = function (x, y, z, Vector) {select (Vector, x, y, z)}
>
> yielded the expected scalar world-coordinate, so that's an interesting pair of
> results.


+1 to the addition of conditional in user-defined functions ! I also use select
as a replacement but as you say it would be much easier to use an explicit
condition.
Having no limitation of parameters to float values would also be very helpful.
Also, I found the equivalence x/u and y/v, the default x,y,z optional arguments,
or the fact they share the same name with the predefined vectors x,y,z, all very
confusing. It made me avoid the use of user-defined functions for a long time,
and even now I'm always a bit reluctant, trying to find workaround as much as
possible.
Hopefully a future version of Pov-ray will improve their usability.

Pascal


Post a reply to this message

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