POV-Ray : Newsgroups : povray.advanced-users : Two blob questions : Re: Two blob questions Server Time
3 Jul 2024 05:50:18 EDT (-0400)
  Re: Two blob questions  
From: SharkD
Date: 8 Nov 2008 03:25:00
Message: <web.49154bfceca3f981288f25570@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> I have two questions regarding blobs.
>
> 1) How can I color (or add media to) a blob based on its strength? I would like
> the blob to be "denser" where the blob is greatest.
>
> 2) Would someone please provide a parametric formula for a blob object? I need
> it for another, non-POV-Ray-related project, but would like to use POV-Ray to
> create a "proof-of-concept" and make sure all my math is correct.
>
> Thanks!
>
> -Mike

I think I got it. In the example below, the spheres are supposed to be more
common where the strength of the field is greater. Please correct me if I am
wrong.

#declare Blob_threshold = 0.01;
#declare Blobs = array[2][4]
{
 {+1/4,+1/4,+1/4,+1/2},
 {-1/4,-1/4,-1/4,+1/2}
}
#declare Bound_width = 4;
#declare Polkadot_radius = 1/10;

#declare fn_A = function { sqrt(pow(x+Blobs[0][0],2) + pow(y+Blobs[0][1],2) +
pow(z+Blobs[0][2],2)) - Blobs[0][3] };
#declare fn_B = function { sqrt(pow(x+Blobs[1][0],2) + pow(y+Blobs[1][1],2) +
pow(z+Blobs[1][2],2)) - Blobs[1][3] };

#local fn_Blob_b = function
{
 (1+Blob_threshold)
 - pow(Blob_threshold, fn_A(x,y,z))
 - pow(Blob_threshold, fn_B(x,y,z))
}
#local Max_strength = (1 + Blob_threshold) - pow(Blob_threshold, -Blobs[0][3]) -
pow(Blob_threshold, -Blobs[1][3]);

#local R1 = seed(12345);
#local iCount = 0;
#local iMax = 1000;
#while (iCount < iMax)
 #local varA = (rand(R1)-1/2) * Bound_width;
 #local varB = (rand(R1)-1/2) * Bound_width;
 #local varC = (rand(R1)-1/2) * Bound_width;
 #local varD = rand(R1);
 #local fnResult = fn_Blob_b(varA,varB,varC);
 #local Strength_ratio = fnResult/Max_strength;

 #if (varD <= Strength_ratio)
  sphere
  {
   <varA,varB,varC>, 1/100
  }
  #debug concat(str(fnResult,0,-1),"\n")
  #local iCount = iCount + 1;
 #end
#end


Post a reply to this message

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