POV-Ray : Newsgroups : povray.advanced-users : Condition in functions : Re: Condition in functions Server Time
21 Dec 2024 11:59:17 EST (-0500)
  Re: Condition in functions  
From: kurtz le pirate
Date: 8 Dec 2024 11:25:16
Message: <6755c86c$1@news.povray.org>
On 07/12/2024 19:54, Tor Olav Kristensen wrote:

> Hi Kurtz
> 
> That's an interesting project.
> 
> I found some MathMod documentation here:
>
https://fossies.org/linux/mathmod/documentation/index.html#SupportedOperatorsFunctions

Hi Tor,

I also found the doc in the MathMod package.


> 
> ...
> ...
> ...
> 
> One of its mathematical functions:
> 
> if(A, B, C)
> if A differs from 0, the return value of this function is B, else C
> 
> 
> In POV-Ray 0 = 0.0, so I have removed the all the int() calls in the
> expressions above.
> 
>  From this documentation I understand that any value equal to 0 is treated
> as a logical False and any other numerical value is treated as logical True.
> (I think this convention makes expressions harder to understand, so I will
> not use it further in my simplified expressions, even if POV-Ray also uses it.
> Writing readable expressions is more important than writing compact
> expressions.)
> 
Yes, indeed, difficult to understand.
MathMod's language is, on certain points, obscure ... at least for me.

I also have problems with PrettyBall_1. 3 isosurfaces. Two are ok. The 
third really doesn't match. Yet the code is/looks ok.



> To make it easier to get an overview, I rename the MathMod functions in your
> post, remove their parameter lists and arguments, insert some white space
> and finally simplify them a bit.
> 
> isoTransform_2(): IT2()
> isoTransform_6(): IT6()
> CarvinCondition(): CC()
> ThickIsoExterior(): TIE()
> ThickIso2(): TI2()
> Iso6(): I6()
> 
> 
> IT2() =
>      if(
>          CC() = 0,
>          TIE(),
>          1
>      )
> 
> IT2() =
>      if(
>          CC(),
>          1,
>          TIE()
>      )
> 
> IT6() =
>      if(
>          CC() & (TIE() < 0),
>          -TI2()*I6()*I6(),
>          1
>      )
> 
> IT6() =
>      if(
>          TIE() < 0,
>          if(
>              CC(),
>              -TI2()*I6()*I6(),
>              1
>          ),
>          1
>      )
> 
> The nested ifs above has the same effect as the & operator.
> 
> Now a rewrite to POV-Ray expressions is not so difficult:
> 
> IT2():
>      select(
>          CC(),
>          1,
>          TIE(),
>          1
>      )
> 
> IT6():
>      select(
>          TIE(),
>          select(
>              CC(),
>              -TI2()*I6()*I6(),
>              1,
>              -TI2()*I6()*I6()
>          ),
>          1
>      )
> 
> The nested selects above has the same effect as the & operator.
> 
> Now you can fill in the parameter lists, the arguments, give back functions
> their original names and give them a proper POV-Ray function syntax.
> 

Ingenious approach. I'm going to look into it very closely.




Thanks+



-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

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