POV-Ray : Newsgroups : povray.newusers : isosurface function - scale,move : Re: isosurface function - scale,move Server Time
29 Jul 2024 22:26:15 EDT (-0400)
  Re: isosurface function - scale,move  
From: Mike Williams
Date: 30 Jan 2005 15:34:32
Message: <SzTXjBAOTU$BFwnJ@econym.demon.co.uk>
Wasn't it Rafal 'Raf256' Maj who wrote:
>
>What is the best way to write syntax like:
>
>  #macro X() x*S.x+W.x #end
>  #macro Y() y*S.y+W.y #end
>  #macro Z() z*S.z+W.z #end
>  
>  function {
>    pow(X(),2) + pow(Y(),2) + pow(Z(),2) - 1
>  }

There's all sorts of things that you could mean by that.

I'm going to assume that you want "x", "y" and "z" to be the function
parameters (not shorthand for the unit vectors, which is what they
always are inside a macro).

Note that "S.x+W.x" is a constant, so we can write
  #declare X = S.x+W.x;
rather than using a macro, and it has the advantage that we can evaluate
it in part of the SDL where vector calculations are legal. It is legal
to call a macro from inside a function (it only gets evaluated once, at
parse time) but not one that uses vectors.


So the whole thing becomes

#declare X = S.x+W.x;
#declare Y = S.y+W.y;
#declare Z = S.z+W.z;
  
function {pow(x*X,2) + pow(y*Y,2) + pow(z*Z,2) - 1}

which is an ellipsoid.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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