POV-Ray : Newsgroups : povray.general : Math problem Server Time
12 Aug 2024 11:24:53 EDT (-0400)
  Math problem (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Spider
Subject: Re: Math problem
Date: 16 Mar 1999 17:14:28
Message: <36EED62A.AFC7BB06@bahnhof.se>
I've been coding for years, and I still do that mistake sometimes...

-- 
//Spider
        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
What I can do and what I could do, I just don't know anymore
                "Marian"
        By: "Sisters Of Mercy"


Post a reply to this message

From: Josh English
Subject: Re: Math problem
Date: 16 Mar 1999 18:51:35
Message: <36EEEEEB.7B9D4BE@spiritone.com>
Okay, barring any stupid coding problems, here we go with an example. It will only to
two
dimentions right now and it not even complete there, but it provides a starting point:

#declare Max_X = 10; // number of spheres along X Axis
#declare Max_Z = 10; // number of spheres along Y Axis
#declare Base_Radius = 1; // radius of a sphere that is not under the influence
#declare Max_Radius = 2; // radius of the sphere that is under the influence
#declare Steps = 5; // the fifth sphere from the center of the effect will be at Base
Radius

#declare Each_Step = (Max_Radius - Base_Radius)/Steps; // Quick formula to determine

// how different adjacent spheres will be
#declare separation = 4; // the distance between sphere centers


#declare MyGrid = array[Max_X][Max_Z]

// initalize the array, giving everything a value of Base Radius
#macro InitGrid ()
  #declare i = 0;
  #while ( i < Max_X )
    #declare j = 0;
    #while ( j < Max_Z )
      #declare MyGrid[i][j] = Base_Radius;
      #declare j = j + 1;
    #end
    #declare i = i + 1;
  #end
#end


#macro DrawGrid ()
  #declare i = 0;
  #while (i < Max_X )
  #declare j = 0;
    #while ( j < Max_Z )
      sphere { <i*separation,2,j*separation> MyGrid[i][j] // Y value is merely
temporary
               pigment { red 1 }
               finish { phong 1 } }
      #declare j = j + 1;
    #end
    #declare i = i + 1;
  #end
#end

#macro CheckCord(a,b) // we will use this one extensively
  ( (a < Max_X) & (a >= 0) & (b < Max_Z ) & ( b >= 0 ) )
#end

#macro AlterGrid (m,n) // this macro changes the spheres in the gird
  #declare MyGrid[m][n] = Max_Radius;
  #declare cvar = 1;
  #while (cvar < Steps )

    #declare Temp_Radius =  Max_Radius- (cvar * Each_Step );

    #if (CheckCord(m + cvar, n) ) // spheres in the +X direction
      #declare MyGrid[m+cvar][n] = Temp_Radius;
    #end

    #if (CheckCord(m-cvar, n) ) // spheres in the -X direction
      #declare MyGrid[m-cvar][n] = Temp_Radius;
    #end

    #if (CheckCord(m, n+cvar) ) // spheres in the +Z direction
      #declare MyGrid[m][n+cvar] = Temp_Radius;
    #end

    #if (CheckCord(m, n-cvar) ) // spheres in the -Z direction
      #declare MyGrid[m][n-cvar] = Temp_Radius;
    #end

    #if ( CheckCord (m+cvar,n+cvar) ) // spheres in +X,+Z diagonal
      #declare MyGrid[m+cvar][n+cvar] = Temp_Radius;
    #end

    #if ( CheckCord (m+cvar,n-cvar) ) // spheres in the +X,-Z direction
      #declare MyGrid[m+cvar][n-cvar] = Temp_Radius;
    #end

    #if ( CheckCord (m-cvar,n+cvar) ) // spheres in -X,+Z direction
      #declare MyGrid[m-cvar][n+cvar] = Temp_Radius;
    #end

    #if ( CheckCord (m-cvar,n-cvar) ) // spheres in the -X,-Z direction.
      #declare MyGrid[m-cvar][n-cvar] = Temp_Radius;
    #end

    #declare cvar = cvar + 1;
  #end

#end // AlterGrid


InitGrid()

AlterGrid (4,5)

DrawGrid()

Sadly, this still misses 24 cubes in the grid. I'm sure there's an easier way to do
it, and
this is mostly brute force, but it works.


Andrew Cocker wrote:

> I hope someone can help get me started with my latest experiment.
>
> I want to try out arrays. My plan is to create a cube made up of, say, 20x20x20 tiny
> spheres. If I pick one of these spheres and designate it to be the centre of the
effect
> I'm trying to create, and scale it by a factor of 2, how do I make the surrounding
spheres
> get gradually smaller until 5 spheres away they are back to scale 1? I plan to
animate the
> effect so that the centre of the effect moves around inside the array of spheres.
>
> I have heard the term 'fields' used. Is this the method I should use, and if so,
could
> anyone suggest either how it is done, or else point me in the direction of where I
can
> find more out about it.
>
> I am not a mathematician or a programmer, but I hand-code only so I should be able
to make
> use of any suggestions, as long as you assume large levels of ignorance on my part.
>
> Many thanks in anticipation.
>
> -----------
> Andy


Post a reply to this message

From: Andrew Cocker
Subject: Re: Math problem
Date: 16 Mar 1999 19:20:26
Message: <36eef54a.0@news.povray.org>
Thankyou all.

--
Andy


Josh English wrote in message <36E### [at] spiritonecom>...
>Okay, barring any stupid coding problems, here we go with an example. It will only to
two
>dimentions right now and it not even complete there, but it provides a starting
point:
>
>#declare Max_X = 10; // number of spheres along X Axis
>#declare Max_Z = 10; // number of spheres along Y Axis
>#declare Base_Radius = 1; // radius of a sphere that is not under the influence
>#declare Max_Radius = 2; // radius of the sphere that is under the influence
>#declare Steps = 5; // the fifth sphere from the center of the effect will be at Base
Radius
>
>#declare Each_Step = (Max_Radius - Base_Radius)/Steps; // Quick formula to determine
>
>// how different adjacent spheres will be
>#declare separation = 4; // the distance between sphere centers
>
>
>#declare MyGrid = array[Max_X][Max_Z]
>
>// initalize the array, giving everything a value of Base Radius
>#macro InitGrid ()
>  #declare i = 0;
>  #while ( i < Max_X )
>    #declare j = 0;
>    #while ( j < Max_Z )
>      #declare MyGrid[i][j] = Base_Radius;
>      #declare j = j + 1;
>    #end
>    #declare i = i + 1;
>  #end
>#end
>
>
>#macro DrawGrid ()
>  #declare i = 0;
>  #while (i < Max_X )
>  #declare j = 0;
>    #while ( j < Max_Z )
>      sphere { <i*separation,2,j*separation> MyGrid[i][j] // Y value is merely
temporary
>               pigment { red 1 }
>               finish { phong 1 } }
>      #declare j = j + 1;
>    #end
>    #declare i = i + 1;
>  #end
>#end
>
>#macro CheckCord(a,b) // we will use this one extensively
>  ( (a < Max_X) & (a >= 0) & (b < Max_Z ) & ( b >= 0 ) )
>#end
>
>#macro AlterGrid (m,n) // this macro changes the spheres in the gird
>  #declare MyGrid[m][n] = Max_Radius;
>  #declare cvar = 1;
>  #while (cvar < Steps )
>
>    #declare Temp_Radius =  Max_Radius- (cvar * Each_Step );
>
>    #if (CheckCord(m + cvar, n) ) // spheres in the +X direction
>      #declare MyGrid[m+cvar][n] = Temp_Radius;
>    #end
>
>    #if (CheckCord(m-cvar, n) ) // spheres in the -X direction
>      #declare MyGrid[m-cvar][n] = Temp_Radius;
>    #end
>
>    #if (CheckCord(m, n+cvar) ) // spheres in the +Z direction
>      #declare MyGrid[m][n+cvar] = Temp_Radius;
>    #end
>
>    #if (CheckCord(m, n-cvar) ) // spheres in the -Z direction
>      #declare MyGrid[m][n-cvar] = Temp_Radius;
>    #end
>
>    #if ( CheckCord (m+cvar,n+cvar) ) // spheres in +X,+Z diagonal
>      #declare MyGrid[m+cvar][n+cvar] = Temp_Radius;
>    #end
>
>    #if ( CheckCord (m+cvar,n-cvar) ) // spheres in the +X,-Z direction
>      #declare MyGrid[m+cvar][n-cvar] = Temp_Radius;
>    #end
>
>    #if ( CheckCord (m-cvar,n+cvar) ) // spheres in -X,+Z direction
>      #declare MyGrid[m-cvar][n+cvar] = Temp_Radius;
>    #end
>
>    #if ( CheckCord (m-cvar,n-cvar) ) // spheres in the -X,-Z direction.
>      #declare MyGrid[m-cvar][n-cvar] = Temp_Radius;
>    #end
>
>    #declare cvar = cvar + 1;
>  #end
>
>#end // AlterGrid
>
>
>InitGrid()
>
>AlterGrid (4,5)
>
>DrawGrid()
>
>Sadly, this still misses 24 cubes in the grid. I'm sure there's an easier way to do
it,
and
>this is mostly brute force, but it works.
>
>
>Andrew Cocker wrote:
>
>> I hope someone can help get me started with my latest experiment.
>>
>> I want to try out arrays. My plan is to create a cube made up of, say, 20x20x20
tiny
>> spheres. If I pick one of these spheres and designate it to be the centre of the
effect
>> I'm trying to create, and scale it by a factor of 2, how do I make the surrounding
spheres
>> get gradually smaller until 5 spheres away they are back to scale 1? I plan to
animate
the
>> effect so that the centre of the effect moves around inside the array of spheres.
>>
>> I have heard the term 'fields' used. Is this the method I should use, and if so,
could
>> anyone suggest either how it is done, or else point me in the direction of where I
can
>> find more out about it.
>>
>> I am not a mathematician or a programmer, but I hand-code only so I should be able
to
make
>> use of any suggestions, as long as you assume large levels of ignorance on my part.
>>
>> Many thanks in anticipation.
>>
>> -----------
>> Andy
>


Post a reply to this message

From: Spider
Subject: Re: Math problem
Date: 16 Mar 1999 19:32:58
Message: <36EEF69E.A0D14EC4@bahnhof.se>
To reduce memory of the scene, declare a pigment for the spheres, and then call
that. This will reduce it grately if you have more advanced scenes.
Here's a test.
#declare N = 100000;
#while(N>0)
	#declare N = N-1;
	sphere {
		<0,0,N>,.25
		texture {
			pigment {
				hexagon
				Red
				Blue
				Green
			}
			finish { ambient 1 }
		}
	}
#end
compared to

#declare T = 
texture {
	pigment {
		hexagon
		Red
		Blue
		Green
	}
	finish { ambient 1 }
}

#declare N = 100000;
#while(N>0)
	#declare N = N-1;
	sphere { <0,0,N>,.25 texture { T } }
#end

(sorry about the tabs)
-- 
//Spider
        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
What I can do and what I could do, I just don't know anymore
                "Marian"
        By: "Sisters Of Mercy"


Post a reply to this message

From: Ron Parker
Subject: Re: Math problem
Date: 17 Mar 1999 08:14:26
Message: <36efaab2.0@news.povray.org>
On Wed, 17 Mar 1999 01:26:06 +0100, Spider <spi### [at] bahnhofse> wrote:
>To reduce memory of the scene, declare a pigment for the spheres, and then call
>that. This will reduce it grately if you have more advanced scenes.
>Here's a test.

That's only true for meshes.  Each sphere still has a copy of the 
entire texture.


Post a reply to this message

From: Spider
Subject: Re: Math problem
Date: 18 Mar 1999 00:06:26
Message: <36F08833.B8460FB@bahnhof.se>
Oh? Hmm, ok.


Ron Parker wrote:
> 
> On Wed, 17 Mar 1999 01:26:06 +0100, Spider <spi### [at] bahnhofse> wrote:
> >To reduce memory of the scene, declare a pigment for the spheres, and then call
> >that. This will reduce it grately if you have more advanced scenes.
> >Here's a test.
> 
> That's only true for meshes.  Each sphere still has a copy of the
> entire texture.

-- 
//Spider
        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
What I can do and what I could do, I just don't know anymore
                "Marian"
        By: "Sisters Of Mercy"


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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