POV-Ray : Newsgroups : povray.advanced-users : isosurface: Does the order of multiple functions matter? : Re: isosurface: Does the order of multiple functions matter? Server Time
26 Mar 2023 20:33:44 EDT (-0400)
  Re: isosurface: Does the order of multiple functions matter?  
From: Bald Eagle
Date: 28 Jan 2023 09:50:00
Message: <web.63d535f49b90547b1f9dae3025979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> Right now, it is like this (very simplified):
> isosurface{
> function{A + B + C + D}
> ....
> }

Since you only have addition (or subtraction), your function is both associative
and commutative with respect to the relevant terms.

If you had multiplication or division, it would (also) be distributive with
respect to the affected terms.

Once you start to do things that are "term-specific", like daisy-chaining
functions together like A(B(C(D(n)))) or having the need to enclose things in
parentheses to get the proper sign or Order of Operations, then you need to be
organized and aware of the consequences of changing things around.

you may have 5 - x + a, or 5 - x -a, which is different than 5 - (x+a) and 5 -

5-a/x will be different than (5-a)/x
same with 5-a*x and (5-a)*x

So, you can use an online equation solver to evaluate the equation in symbolic
terms, or to plug in values.   You can also evaluate parts of your functions in
POV-Ray and send the result to the #debug stream.

#declare A = function (N) {sqrt(N)}
#declare Result = A (27);
#debug concat (str(Result, 0, DecimalPlaces), " \n")

If you are unsure about changing things around, then you can start to separate
terms in your functions into subfunctions and then start to recombine them.

#declare A = function (X, Y, Z, N) {(3*X + pow (Y, 3))/Z*sqrt(N)}
#declare Asub1 = function (X, Y, Z, N) {(3*X + pow (Y, 3))/Z}
#declare Asub1a = function (X, Y, Z, N) {3*X+pow (Y, 3)}
#declare Asub2a = function (X, Y, Z, N) {3*X}
#declare Asub2b = function (X, Y, Z, N) {pow (Y, 3)}
#declare Asub1b = function (X, Y, Z, N) {Asub2a (X, Y, Z, N) + Asub2b (X, Y, Z,
#declare Asub1c = function (X, Y, Z, N) {Asub1b (X, Y, Z, N)/ Z}
#declare Asub2c = function (X, Y, Z, N) {sqrt(N)}
#declare Asub3 = function (Term1, Term2) {Asub1c (X, Y, Z, N) * Asub2c (X, Y, Z,

*before 1st coffee, untested code

So you can see inside the curly brackets how the functions get simpler, but due
to the nature of POV-Ray's function parser, the expressions to evaluate those
can get more complex.  It is however, good practice to understand the finer bits
of the function syntax and why things go wrong, and how they can go wrong in a

If you do you evaluations with a macro and declaring local identifiers to be the
result of chains of operations, then you can get the answers you need in the
#debug stream, and use that as a guide to getting it right in the invisible and
complicated operations that happen in functions and isosurfaces.

Your mission, Kenneth, should you choose/decide to accept it, is to concatenate
these functions and successfully render an error-free isosurface.  As always,
should you or any of your POV-Ray collaborators be caught or killed, the Dev
Team will disavow any knowledge of your actions. This message will self-destruct
in ten POV units. Good luck, Kenneth.

Post a reply to this message

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