POV-Ray : Newsgroups : povray.general : Blob functions help Server Time
30 Jul 2024 02:19:02 EDT (-0400)
  Blob functions help (Message 1 to 6 of 6)  
From: SharkD
Subject: Blob functions help
Date: 29 Jan 2010 21:31:48
Message: <4b639a14@news.povray.org>
I've described some different blob functions here:

http://www.geogebra.org/en/upload/files/english/Michael_Horvath/Metaballs/geogebra_metaballs.htm

How would one create a blob function that simulates the way gravity 
works? I.e. the interaction of multiple gravitational bodies.


-- 
--
Michael Horvath
mik### [at] gmailcom
http://isometricland.com


Post a reply to this message

From: Le Forgeron
Subject: Re: Blob functions help
Date: 30 Jan 2010 06:37:00
Message: <4b6419dc$1@news.povray.org>
Le 30/01/2010 03:31, SharkD nous fit lire :
> I've described some different blob functions here:
> 
>
http://www.geogebra.org/en/upload/files/english/Michael_Horvath/Metaballs/geogebra_metaballs.htm
> 
> 
> How would one create a blob function that simulates the way gravity
> works? I.e. the interaction of multiple gravitational bodies.

Looks to me that gravity fields and electric fields are similar (Method
1, the long one).
You would have to add weight (mass) in the equation as the strength of
the field. (similar to using electric fields from different voltage),
also your h would be the sum of vectors, something along

f(x,y,z) = Mass_of_F / sqrt((x-xA)^2 + (y-yA)^2 + (z -zA)^2)
g(x,y,z) = Mass_of_G / sqrt((x-xC)^2 + (y-yC)^2 + (z -zC)^2)
h(x,y,z)/as vect = f(x,y,z).unit_vector(<xA-x,yA-y,zA-z>)
+ g(x,y,z).unit_vector(<xC-x,yC-y,zC-z>)

i = length_of(h);

Notice that with 2 bodies, you have 1 zero.
With more than 2 bodies, even in 2D plane, it's starting to be "interesting"

Of course, that's unrealistic, as it assume ponctual mass (traditional
in physic for low level) and do not take into account the Roche limit.
And it does not take into account the relativity's issues if a mass is
moving fast. (with that set of equations, the fields move faster than
the information limit: c!)

PS: black holes are not responding well to that set of equations either.
(horizon seems to be linear to the mass, not like classical distance we
are used to... )

PS2: gravity does not exist, the earth is sucking.


Post a reply to this message

From: SharkD
Subject: Re: Blob functions help
Date: 30 Jan 2010 18:36:35
Message: <4b64c283@news.povray.org>
Thanks! The next question I was going to ask is how to get the 
*direction* of the force as well.

Unfortunately, the code you provided results in an error. There is no 
"unit_vector" property of a function as far as I can tell.


On 1/30/2010 6:36 AM, Le_Forgeron wrote:
> Le 30/01/2010 03:31, SharkD nous fit lire :
>> I've described some different blob functions here:
>>
>>
http://www.geogebra.org/en/upload/files/english/Michael_Horvath/Metaballs/geogebra_metaballs.htm
>>
>>
>> How would one create a blob function that simulates the way gravity
>> works? I.e. the interaction of multiple gravitational bodies.
>
> Looks to me that gravity fields and electric fields are similar (Method
> 1, the long one).
> You would have to add weight (mass) in the equation as the strength of
> the field. (similar to using electric fields from different voltage),
> also your h would be the sum of vectors, something along
>
> f(x,y,z) = Mass_of_F / sqrt((x-xA)^2 + (y-yA)^2 + (z -zA)^2)
> g(x,y,z) = Mass_of_G / sqrt((x-xC)^2 + (y-yC)^2 + (z -zC)^2)
> h(x,y,z)/as vect = f(x,y,z).unit_vector(<xA-x,yA-y,zA-z>)
> + g(x,y,z).unit_vector(<xC-x,yC-y,zC-z>)
>
> i = length_of(h);
>
> Notice that with 2 bodies, you have 1 zero.
> With more than 2 bodies, even in 2D plane, it's starting to be "interesting"
>
> Of course, that's unrealistic, as it assume ponctual mass (traditional
> in physic for low level) and do not take into account the Roche limit.
> And it does not take into account the relativity's issues if a mass is
> moving fast. (with that set of equations, the fields move faster than
> the information limit: c!)
>
> PS: black holes are not responding well to that set of equations either.
> (horizon seems to be linear to the mass, not like classical distance we
> are used to... )
>
> PS2: gravity does not exist, the earth is sucking.

-- 
--
Michael Horvath
mik### [at] gmailcom
http://isometricland.com


Post a reply to this message

From: SharkD
Subject: Re: Blob functions help
Date: 30 Jan 2010 22:33:32
Message: <4b64fa0c@news.povray.org>
Here are the POV-Ray versions of the formulas I'm using:

#switch (Blob_method)
	// GameDev.net tutorial
	#case (1)
		#declare Blob_threshold_1 = 3;
		#declare Blob_threshold_2 = 3;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.5;
		#declare fn_A = function { Blob_radius / sqrt(pow(x+Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_B = function { Blob_radius / sqrt(pow(x-Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_C = function { Blob_threshold_1 };
		#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
		#declare fn_E = function { min(Blob_threshold_2, max(0, fn_D(x,y,z))) };
	#break
	// POV-Ray isosurface tutorial
	#case (2)
		#declare Blob_strength  = 0.5;
		#declare Blob_threshold = 1;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.5;
		#declare fn_A = function { pow(x+Blob_distance,2) + pow(y,2) + 
pow(z,2) - pow(Blob_radius,2) };
		#declare fn_B = function { pow(x-Blob_distance,2) + pow(y,2) + 
pow(z,2) - pow(Blob_radius,2) };
		#declare fn_C = function { Blob_strength + 1 }
		#declare fn_D = function { pow(Blob_strength, fn_A(x,y,z)) + 
pow(Blob_strength, fn_B(x,y,z)) - fn_C(x,y,z) - Blob_threshold };
		#declare fn_E = function { max(0, fn_D(x,y,z)) };
	#break
	// POV-Ray blob tutorial
	#case (3)
		#declare Blob_strength  = 3;
		#declare Blob_threshold = 1;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2;
		#declare fn_A = function { min(sqrt(pow(x+Blob_distance,2) + pow(y,2) 
+ pow(z,2)), Blob_radius) };
		#declare fn_B = function { min(sqrt(pow(x-Blob_distance,2) + pow(y,2) 
+ pow(z,2)), Blob_radius) };
		#declare fn_C = function { Blob_strength * pow(1 - pow(fn_A(x,y,z) / 
Blob_radius, 2), 2) };
		#declare fn_D = function { Blob_strength * pow(1 - pow(fn_B(x,y,z) / 
Blob_radius, 2), 2) };
		#declare fn_G = function { fn_C(x,y,z) + fn_D(x,y,z) - Blob_threshold };
		#declare fn_E = function { max(0, fn_G(x,y,z)) };
	#break
	// Wikipedia
	#case (4)
		#declare Blob_threshold_1 = 2;
		#declare Blob_threshold_2 = 4;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.75;
		#declare fn_A = function { Blob_radius / (pow(x+Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_B = function { Blob_radius / (pow(x-Blob_distance,2) + 
pow(y,2) + pow(z,2)) };
		#declare fn_C = function { Blob_threshold_1 };
		#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
		#declare fn_E = function { min(Blob_threshold_2, max(0, fn_D(x,y,z))) };
	#break
	// GameDev.net tutorial, diamond
	#case (5)
		#declare Blob_threshold_1 = 2;
		#declare Blob_threshold_2 = 3;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 2.75;
		#declare fn_A = function { Blob_radius / (abs(x+Blob_distance) + 
abs(y) + abs(z)) };
		#declare fn_B = function { Blob_radius / (abs(x-Blob_distance) + 
abs(y) + abs(z)) };
		#declare fn_C = function { Blob_threshold_1 };
		#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
		#declare fn_E = function { min(Blob_threshold_2, max(0, fn_D(x,y,z))) };;
	#break
	// isosurface tutorial, diamond
	#case (6)
		#declare Blob_strength  = 0.5;
		#declare Blob_threshold = 0;
		#declare Blob_boxsize   = <1,1,1,> * Scene_scale * 3;
		#declare fn_A = function { (abs(x+Blob_distance) + abs(y) + abs(z) - 
Blob_radius) / pow(Scene_scale,2) };
		#declare fn_B = function { (abs(x-Blob_distance) + abs(y) + abs(z) - 
Blob_radius) / pow(Scene_scale,2) };
		#declare fn_C = function { Blob_strength + 1 }
		#declare fn_D = function { pow(Blob_strength, fn_A(x,y,z)) + 
pow(Blob_strength, fn_B(x,y,z)) - fn_C(x,y,z) - Blob_threshold };
		#declare fn_E = function { max(0, fn_D(x,y,z)) };
	#break
#end


Post a reply to this message

From: SharkD
Subject: Re: Blob functions help
Date: 31 Jan 2010 21:00:19
Message: <4b6635b3@news.povray.org>
On 1/30/2010 6:36 AM, Le_Forgeron wrote:
> Le 30/01/2010 03:31, SharkD nous fit lire :
>> I've described some different blob functions here:
>>
>>
http://www.geogebra.org/en/upload/files/english/Michael_Horvath/Metaballs/geogebra_metaballs.htm
>>
>>
>> How would one create a blob function that simulates the way gravity
>> works? I.e. the interaction of multiple gravitational bodies.
>
> Looks to me that gravity fields and electric fields are similar (Method
> 1, the long one).
> You would have to add weight (mass) in the equation as the strength of
> the field. (similar to using electric fields from different voltage),
> also your h would be the sum of vectors, something along
>
> f(x,y,z) = Mass_of_F / sqrt((x-xA)^2 + (y-yA)^2 + (z -zA)^2)
> g(x,y,z) = Mass_of_G / sqrt((x-xC)^2 + (y-yC)^2 + (z -zC)^2)
> h(x,y,z)/as vect = f(x,y,z).unit_vector(<xA-x,yA-y,zA-z>)
> + g(x,y,z).unit_vector(<xC-x,yC-y,zC-z>)
>
> i = length_of(h);
>
> Notice that with 2 bodies, you have 1 zero.
> With more than 2 bodies, even in 2D plane, it's starting to be "interesting"
>
> Of course, that's unrealistic, as it assume ponctual mass (traditional
> in physic for low level) and do not take into account the Roche limit.
> And it does not take into account the relativity's issues if a mass is
> moving fast. (with that set of equations, the fields move faster than
> the information limit: c!)
>
> PS: black holes are not responding well to that set of equations either.
> (horizon seems to be linear to the mass, not like classical distance we
> are used to... )
>
> PS2: gravity does not exist, the earth is sucking.


I would still be interested in knowing how to extract a vector from the 
above function.

-- 
--
Michael Horvath
mik### [at] gmailcom
http://isometricland.com


Post a reply to this message

From: Tim Attwood
Subject: Re: Blob functions help
Date: 1 Feb 2010 08:17:23
Message: <4b66d463$1@news.povray.org>
If you have two points P1 and P2, then
the direction D of P2 from P1 is (P2-P1) normalized.

So the gravity F between P1 and P2 is
g*mass1*mass2/(distance P1 to P2)^2,
which is a real number, so you multiply
that by the direction to get a change in the
velocity of P1.  (V1=V1+F*D, P1=P1+V1*Time)

For more objects you just calculate each force and
add them onto the velocity. The real problem is this
is O(n^2) to calculate, a thousand objects would
take about a million force calculations to animate 
per frame.


Post a reply to this message

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