|
|
Kilgore Trout wrote:
>
> That's sort of different from what I'm tring to do. I'm trying to make a
> macro that can make a graph of surfaces defined by Y = F(X, Z), and I want
> to pass F(X, Z) as a parameter to the macro. But not just one value of F, I
> want to be able to pass the function F, so I can call it several times
> inside of the macro.
>...
Kilgore,
if you've downloded POV-Ray v3.5.beta by now,
(as JRG suggested) then maybe my example code
below will be useful for you. It shows how to
pass user declared functions to macros as
parameters.
You may also wan't to have a look at isosurfaces.
They are very useful for graphing in 3D.
Tor Olav
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// By Tor Olav Kristensen
// Email: tor### [at] hotmailcom
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
#version 3.5;
#include "colors.inc"
#include "golds.inc"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
#macro FunctionPlot(Fn, p1, p2, nn, Radius)
#local dX = (p2 - p1).x/nn;
#local dZ = (p2 - p1).z/nn;
#local X = p1.x;
#while (X < p2.x)
#local Z = p1.z;
#while (Z < p2.z)
#local Y = Fn(X, 0, Z);
sphere { <X, Y, Z>, Radius }
#local Z = Z + dZ;
#end // while
#local X = X + dX;
#end // while
#end // macro FunctionPlot
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
#declare SombreroFn =
function(x, y, z) { 10*sin(sqrt(x^2 + z^2))/(sqrt(x^2 + z^2) + 1) }
#declare pA = -35*<1, 0, 1>;
#declare pB = 35*<1, 0, 1>;
union {
FunctionPlot(function { SombreroFn(x, y, z) }, pA, pB, 200, 0.4)
texture { T_Gold_2B }
}
/* // This code will produce a somewhat disturbed "sombrero"
#declare BozoFn =
function { pattern { bozo scale 4 } }
#declare MixedFn =
function(x, y, z) { SombreroFn(x, 0, z) - 2*BozoFn(x, 0, z) }
union {
FunctionPlot(function { MixedFn(x, 0, z) }, pA, pB, 200, 0.4)
texture { T_Gold_2B }
}
*/
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
sky_sphere { pigment { color Blue/2 } }
light_source { < 5, 4, -1>*10 color White shadowless }
camera {
location <2, 5, -7>*2
look_at <0, -4, 0>
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
Post a reply to this message
|
|