POV-Ray : Newsgroups : povray.binaries.images : Vase - Isosurface - MathMod : Re: Vase - Isosurface - MathMod Server Time
21 Dec 2024 12:00:03 EST (-0500)
  Re: Vase - Isosurface - MathMod  
From: kurtz le pirate
Date: 21 Dec 2024 05:43:07
Message: <67669bbb$1@news.povray.org>
On 20/12/2024 19:19, Kenneth wrote:
> Wow, that is a beauty. And a really interesting use of isosurface functions.
> 
> I tried to follow your recent post about the function re-writing from MathMod,
> but got hopelessly lost :-(  Very sophisticated! I need to re-read it...over and
> over again, until it sinks into my poor brain...
> 


But no, it's not that difficult.
You just need to know a few tricks and have lot of patience...


* Replace the rise to power '^' by pow(a,b) or write explicitly a*a*a...
* A function is defined by its name and parameters.
   The current parameters (x,y,z) may not be written.
   #declare foo = function {...} is the same thing that
   #declare foo = function(x,y,z) {...}	
* Check the number of parameters required by the function.
   N required -> N passed and N passed ->  N required.
* Mathmod often uses the 't' parameter. In the vast majority of cases,
   this parameter can be omitted. 't' is used for animation and/or
   morphing.
* Matmod lets you use 'if' in functions. POVRay doesn't.
   You have to replace it with a 'select()'. See TOK's more detailed
   explanations.
* Remember also that POV compares to zero in the 'select()'.
   In Matmod this is not always the case.
* In Matmod, declaration is sequential and a function can be redefined.
   In fact, the same 'function name' can be used several times.
   In POV, this is forbidden (and so much the better!).
* Don't forget the constants and the domains





Sample :

"Animated Bone Cage model by Abderrahman Taha 12/11/2020"

"P_Skeletal0=-y-z+(51/100)*(-x*y+y*z+z*x)+12/10"

-> Add '#declare' at the beginning, remove the quotation marks, add
    'function {' after the equal sign and at the end of the line.
    #declare P_Skeletal0 = function{ -y-z+(51/100)*(-x*y+y*z+z*x)+12/10 }


Then
"isoTransform=if((x-pi)*(x-pi)<(13),P_Skeletal(x,y-4*t,z-20*t,t),(1))+exp((x-pi)*(x-pi)-9)"


Which can be rewritten as :
"isoTransform = if (
   (x-pi)*(x-pi)<(13),
   P_Skeletal(x,y-4*t,z-20*t,t),
   (1)
   )
   +exp((x-pi)*(x-pi)-9)"

We replace the 'if()' with a 'select()', paying attention to the
condition, which in this case is not relative to (zero) but to (13).

Resulting in :
#declare isoTransform = function {
   select (
     (x-pi)*(x-pi)-13, // A : condition with respect to 0
     P_Skeletal(x,y,z) // If A < 0
     1                 // Else (A >=0) 	
     )
   +exp((x-pi)*(x-pi)-9)
   }

Note the deletion of the 't' parameter.




The hardest part is still adjusting the isosurface parameters: 
contained_by, threshold, accuracy, max_gradient, ...




All this also works for the parametric part and the
parametric { } POV's object.



Have fun !!


-- 
kurtz le pirate
compagnie de la banquise


Post a reply to this message

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