|
![](/i/fill.gif) |
SharkD schrieb:
> The following function transforms a sphere such that it is expanded
> logarithmically along the y axis. What I would like to do next is to
> expand a sphere based on its distance from the origin instead. Any
> ideas? Of course, if the sphere is located a the origin like my example
> it will still look like a sphere.
You'd need to (a) define the center of the sphere, (b) compute the
desired radius from the distance to the origin, (c) redefine your
Temp_fnc1 to take into account a radius, and (e) offset the parameters
to Temp_fnc1 by the center, as in:
#local Center = <...>; // (a)
#local Radius = log(vlength(Center)+1) / log(2); // (b)
#local Temp_fnc1 = function
{
1 - min(1, sqrt(x*x + y*y + z*z)/Radius) // (c)
}
#local Temp_fnc3 = function
{
Temp_fnc1(x-Center.x,y-Center.y,z-Center.z) // (d)
}
I guess this definition for Temp_fnc3 might run into problems though,
due to POV-Ray's general inability to use vector stuff in functions; you
may need to define temporary variables for the Center vector components,
as in:
#local CenterX = Center.x;
#local CenterY = Center.y;
#local CenterZ = Center.z;
#local Temp_fnc3 = function
{
Temp_fnc1(x-CenterX,y-CenterY,z-CenterZ)
}
Note that this will produce just a single sphere. To get multiples of
them, you might want to add multiple instances of that function, as in:
#macro Temp_Fnc(Center)
#local Radius = log(vlength(Center)+1)
#local Temp_fnc1 = function
{
1 - min(1, sqrt(x*x + y*y + z*z)/Radius)
}
#local CenterX = Center.x;
#local CenterY = Center.y;
#local CenterZ = Center.z;
( Temp_fnc1(x-CenterX,y-CenterY,z-CenterZ) )
#end
#local Temp_fnc3 = function
{
Temp_Fnc(<0,1,0>) +
Temp_Fnc(<0,3,0>) +
Temp_Fnc(<0,10,0>) +
...
}
Post a reply to this message
|
![](/i/fill.gif) |