POV-Ray : Newsgroups : povray.newusers : isosurface function - scale,move Server Time
30 Jul 2024 00:18:51 EDT (-0400)
  isosurface function - scale,move (Message 1 to 4 of 4)  
From: Rafal 'Raf256' Maj
Subject: isosurface function - scale,move
Date: 30 Jan 2005 11:22:27
Message: <Xns95EEB0AEA7A44raf256com@203.29.75.35>
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
  }

?



-- 
http://www.raf256.com/3d/
Rafal Maj 'Raf256', home page - http://www.raf256.com/me/
Computer Graphics


Post a reply to this message

From: Warp
Subject: Re: isosurface function - scale,move
Date: 30 Jan 2005 15:07:55
Message: <41fd3e9b@news.povray.org>
Rafal 'Raf256' Maj <spa### [at] raf256com> 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
>   }

> ?

  I failed to understand what actually is your question...

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Mike Williams
Subject: Re: isosurface function - scale,move
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

From: Slime
Subject: Re: isosurface function - scale,move
Date: 30 Jan 2005 16:45:39
Message: <41fd5583$1@news.povray.org>
Judging from your post's topic, I'm assuming you want an easy way to
transform a function (scale/rotate/translate) that you're using in an
isosurface. For that I would suggest the IsoCSG library (
http://www-public.tu-bs.de:8080/~y0013390/pov/ic/ ). Then you can do
something like

#declare myfunc = function {x*x + y*y + z*z - 1}
#declare mynewfunc = IC_Transform (myfunc, transform {scale 3 rotate 90*x
translate y} )

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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