POV-Ray : Newsgroups : povray.advanced-users : Math help Server Time
1 Nov 2024 01:21:14 EDT (-0400)
  Math help (Message 1 to 7 of 7)  
From: SharkD
Subject: Math help
Date: 11 Sep 2009 23:38:40
Message: <4aab17c0$1@news.povray.org>
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.

-Mike



#local Temp_fnc1 = function
{
     1 - min(1, sqrt(x*x + y*y + z*z))
}
#local Temp_fnc3 = function
{
     max(0,min(1,Temp_fnc1(x, log(y + 1) / log(2),z)))
}


Post a reply to this message

From: clipka
Subject: Re: Math help
Date: 12 Sep 2009 05:08:57
Message: <4aab6529$1@news.povray.org>
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

From: SharkD
Subject: Re: Math help
Date: 12 Sep 2009 22:23:17
Message: <4aac5795$1@news.povray.org>
clipka wrote:
> 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:

Thanks. I'll try it out tonight or tomorrow.

> 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:

Yeah, I have trouble with the algebraic functions. I use another 
program, called GeoGebra, to test out operations before I do them in 
POVray. Unfortunately, this program uses algebraic functions in the 
format of f(x) =  2 * x, which can sometimes be hard two convert to 
POVray's format of 0 = 2 * x - y.

-Mike


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Math help
Date: 13 Sep 2009 14:23:57
Message: <4aad38bd@news.povray.org>
SharkD wrote:

> Unfortunately, this program uses algebraic functions in the 
> format of f(x) =  2 * x, which can sometimes be hard two convert to 
> POVray's format of 0 = 2 * x - y.

I probably misunderstood that problem ... isn't the conversion just
subtracting the function value from both sides of the equations?


Post a reply to this message

From: SharkD
Subject: Re: Math help
Date: 13 Sep 2009 15:29:07
Message: <4aad4803$1@news.povray.org>
Christian Froeschlin wrote:
> SharkD wrote:
> 
>> Unfortunately, this program uses algebraic functions in the format of 
>> f(x) =  2 * x, which can sometimes be hard two convert to POVray's 
>> format of 0 = 2 * x - y.
> 
> I probably misunderstood that problem ... isn't the conversion just
> subtracting the function value from both sides of the equations?

In this case it is. However, consider the functions 0 = 2 * x - y^2 and 
0 = 2 * x - log(y). Things begin to get a little tricky.

-Mike


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Math help
Date: 13 Sep 2009 20:24:52
Message: <4aad8d54@news.povray.org>
SharkD wrote:
> Christian Froeschlin wrote:
>> SharkD wrote:
>>
>>> Unfortunately, this program uses algebraic functions in the format of 
>>> f(x) =  2 * x, which can sometimes be hard two convert to POVray's 
>>> format of 0 = 2 * x - y.
>>
>> I probably misunderstood that problem ... isn't the conversion just
>> subtracting the function value from both sides of the equations?
> 
> In this case it is. However, consider the functions 0 = 2 * x - y^2 and 
> 0 = 2 * x - log(y). Things begin to get a little tricky.

ok. I thought you wished to convert in the other direction.


Post a reply to this message

From: SharkD
Subject: Re: Math help
Date: 24 Sep 2009 22:53:19
Message: <4abc309f$1@news.povray.org>
clipka wrote:
> 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>) +
>   ...
> }

I finally got around to trying this, and it didn't produce the results I 
want. The main problem as I see it is that the Sphere parameter is 
defined outside the function and stores only a single parameter.

-Mike


Post a reply to this message

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