POV-Ray : Newsgroups : povray.newusers : question about user defined float functions : Re: question about user defined float functions Server Time
27 Jul 2024 12:20:11 EDT (-0400)
  Re: question about user defined float functions  
From: William F Pokorny
Date: 31 May 2024 11:01:58
Message: <6659e666$1@news.povray.org>
On 5/31/24 09:46, Jonathan Bush wrote:
> Okay, if I understand this correctly, if the input parameter A is boolean, I can
> provide any value I want for B, and C is the value returned when A is false, and
> D is the value when A is true. I hope I got that right.

I'll add, folks sometimes lose track of the fact the virtual machine 
(VM) select() functionality is mirrored in the Scene Description 
Language (SDL). In other words, you can test your logic outside of the 
function {} wrapper prior to use in the function itself - or alongside.

Bill P.


//---
#version 3.8;

#declare A=-1;
#declare B=-2;
#declare Z=0;
#declare C=+2;

#declare Fn_select3 = function (_a,_b,_c)    { select(_a,_b,_c) }
#declare Fn_select4 = function (_a,_b,_z,_c) { select(_a,_b,_z,_c) }

#debug concat("A = ",str(A,3,1),"\n")
#debug concat("B = ",str(B,3,1),"\n")
#debug concat("Z = ",str(Z,3,1),"\n")
#debug concat("C = ",str(C,3,1),"\n")
#debug "\n"
#debug concat("select(A,B,C)       = ",str(select(A,B,C),3,1),"\n")
#debug concat("Fn_select3(A,B,C)   = ",str(Fn_select3(A,B,C),3,1),"\n")
#debug "\n"
#debug concat("select(A,B,Z,C)     = ",str(select(A,B,Z,C),3,1),"\n")
#debug concat("Fn_select4(A,B,Z,C) = ",str(Fn_select4(A,B,Z,C),3,1),"\n")
#debug "\n"

#error "Stop early\n"
//---


Post a reply to this message

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