POV-Ray : Newsgroups : povray.general : Math problem Server Time
15 Nov 2024 03:22:05 EST (-0500)
  Math problem (Message 1 to 10 of 16)  
Goto Latest 10 Messages Next 6 Messages >>>
From: Andrew Cocker
Subject: Math problem
Date: 12 Mar 1999 15:36:19
Message: <36e97ac3.0@news.povray.org>
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: Jerry Anning
Subject: Re: Math problem
Date: 12 Mar 1999 17:02:29
Message: <36e98aea.22674829@news.povray.org>
On Fri, 12 Mar 1999 20:32:52 -0000, "Andrew Cocker"
<and### [at] acockerfreeservecouk> wrote:

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

Give this little macro the array coordinates of the sphere you are
defining and of the sphere at the center of the effect. At the proper
point in the sphere definition say:

scale Size(Mysphrx, Mysphry, Mysphrz, Mycentx, Mycenty, Mycentz)

#macro Size(_Xloc, _Yloc, _Zloc, _Cxloc, _Cyloc, _Czloc)
  #local _Dist = min(min(abs(_Xloc - _Cxloc), abs(_Yloc -_Cyloc)),
                                 abs(_Zloc - _Czloc));
  #local _Scl = (5 - max(_Dist, 5)) / 5;
  <_Scl, _Scl, _Scl>
#end

The macro will, of course, work with actual position coordinates as
well and for noninteger positions (with a Manhattan metric).  To do
this for another range, replace every occurrence of 5 with a variable
and add that variable to the parameter list.  This reduces the size
linearly.  If you want to do inverse square or somesuch, or change the
metric, it is pretty simple.  You can also easily modify it to wrap
around.

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

From: Andrew Cocker
Subject: Re: Math problem
Date: 13 Mar 1999 13:56:59
Message: <36eab4fb.0@news.povray.org>
Thanks for that Jerry, although at this stage, it seems incomprehensible. You'll
perhaps
understand why when I tell you that, as yet, I have never even created an array, let
alone
manipulated one. I'll start from scratch, and ask more questions later when ( not *if*
) I
get really stuck.

If you have any further suggestions that might help me make progress, they'd be most
welcome.

Thanks again


-----------
Andy


Jerry Anning wrote in message <36e98aea.22674829@news.povray.org>...
>On Fri, 12 Mar 1999 20:32:52 -0000, "Andrew Cocker"
><and### [at] acockerfreeservecouk> wrote:
>
>>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.
>
>Give this little macro the array coordinates of the sphere you are
>defining and of the sphere at the center of the effect. At the proper
>point in the sphere definition say:
>
>scale Size(Mysphrx, Mysphry, Mysphrz, Mycentx, Mycenty, Mycentz)
>
>#macro Size(_Xloc, _Yloc, _Zloc, _Cxloc, _Cyloc, _Czloc)
>  #local _Dist = min(min(abs(_Xloc - _Cxloc), abs(_Yloc -_Cyloc)),
>                                 abs(_Zloc - _Czloc));
>  #local _Scl = (5 - max(_Dist, 5)) / 5;
>  <_Scl, _Scl, _Scl>
>#end
>
>The macro will, of course, work with actual position coordinates as
>well and for noninteger positions (with a Manhattan metric).  To do
>this for another range, replace every occurrence of 5 with a variable
>and add that variable to the parameter list.  This reduces the size
>linearly.  If you want to do inverse square or somesuch, or change the
>metric, it is pretty simple.  You can also easily modify it to wrap
>around.
>
>Jerry Anning
>clem "at" dhol "dot" com


Post a reply to this message

From: Josh English
Subject: Re: Math problem
Date: 15 Mar 1999 15:07:22
Message: <36ED68E1.77DEB9D2@spiritone.com>
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

I started a test file to look at this as follows:

#declare MyGrid = array[10][10]

// initalize the array
#macro InitGrid ()
  #declare i = 0;
  #declare j = 0;

  #while ( i < 10 )
    #while ( j < 10 )
      #declare MyGrid[i][j] = 1;
      #declare j = j + 1;
    #end
    #declare i = i + 1;
  #end
#end


#macro DrawGrid ()
  #declare i = 0;
  #declare j = 0;

  #while (i < 10 )
    #while ( j < 10 )
      sphere { <i*2,2,j*2> MyGrid[i][j]
               pigment { red 1 }
               finish { phong 1 } }
      #declare j = j + 1;
    #end
    #declare i = i + 1;
  #end
#end

InitGrid()
DrawGrid()

And in theory this is place to start, but when I render this code I get 10 spheres
instead of
100. It would appear that POV Ray does not like nested loops but there is nothing I
can find
to support this theory... has anyone else run into this or am I missing somthing very
obvious
in my code?
--
Josh English
eng### [at] spiritonecom
www.spiritone.com/~english


Post a reply to this message

From: Jerry Anning
Subject: Re: Math problem
Date: 15 Mar 1999 15:15:29
Message: <36ed6a32.9267778@news.povray.org>
On Mon, 15 Mar 1999 12:09:06 -0800, Josh English
<eng### [at] spiritonecom> wrote:

>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
>
>I started a test file to look at this as follows:
>
>#declare MyGrid = array[10][10]
>
>// initalize the array
>#macro InitGrid ()
>  #declare i = 0;
>  #declare j = 0;
>
>  #while ( i < 10 )
******Insert #declare j=0; here! *********
>    #while ( j < 10 )
>      #declare MyGrid[i][j] = 1;
>      #declare j = j + 1;
>    #end
>    #declare i = i + 1;
>  #end
>#end
>
>
>#macro DrawGrid ()
>  #declare i = 0;
>  #declare j = 0;
>
>  #while (i < 10 )
>    #while ( j < 10 )
>      sphere { <i*2,2,j*2> MyGrid[i][j]
>               pigment { red 1 }
>               finish { phong 1 } }
>      #declare j = j + 1;
>    #end
>    #declare i = i + 1;
>  #end
>#end
>
>InitGrid()
>DrawGrid()
>
>And in theory this is place to start, but when I render this code I get 10 spheres
instead of
>100. It would appear that POV Ray does not like nested loops but there is nothing I
can find
>to support this theory... has anyone else run into this or am I missing somthing very
obvious
>in my code?
>--
>Josh English
>eng### [at] spiritonecom
>www.spiritone.com/~english
>
>

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

From: Spider
Subject: Re: Math problem
Date: 15 Mar 1999 15:17:32
Message: <36ED6943.C5C3018A@bahnhof.se>
// initalize the array
 #macro InitGrid ()
   #local i = 0;
   #while ( i < 10 )
   #local j = 0;
//RESET J HERE !!!
     #while ( j < 10 )
       #declare MyGrid[i][j] = 1;
       #local j = j + 1;
     #end
     #local i = i + 1;
   #end
 #end
 
 #macro DrawGrid ()
   #local i = 0;
   #while (i < 10 )
//RESET J HERE !!!
   #local j = 0;
     #while ( j < 10 )
       sphere { <i*2,2,j*2> MyGrid[i][j]
                pigment { red 1 }
                finish { phong 1 } }
       #local j = j + 1;
     #end
     #local i = i + 1;
   #end
 #end
 

I set the comments. Sorry for screaming :-)
you only have to reinit J to 0 every outer loop, or it will only happen ince.
And, use #local inside a macro.
-- 
//Spider 
( spi### [at] bahnhofse ) [ http://www.bahnhof.se/~spider/ ]
#declare life = rand(seed(42))*sqrt(-1);


Post a reply to this message

From: Jerry Anning
Subject: Re: Math problem
Date: 15 Mar 1999 15:18:35
Message: <36ed6af4.9461722@news.povray.org>
On Mon, 15 Mar 1999 20:15:38 GMT, nos### [at] despamcom (Jerry Anning)
wrote:

>On Mon, 15 Mar 1999 12:09:06 -0800, Josh English
><eng### [at] spiritonecom> wrote:
>
>>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
>>
>>I started a test file to look at this as follows:
>>
>>#declare MyGrid = array[10][10]
>>
>>// initalize the array
>>#macro InitGrid ()
>>  #declare i = 0;
>>  #declare j = 0;
>>
>>  #while ( i < 10 )
>******Insert #declare j=0; here! *********
>>    #while ( j < 10 )
>>      #declare MyGrid[i][j] = 1;
>>      #declare j = j + 1;
>>    #end
>>    #declare i = i + 1;
>>  #end
>>#end
>>
>>
>>#macro DrawGrid ()
>>  #declare i = 0;
>>  #declare j = 0;
>>
>>  #while (i < 10 )
******** And here! ***********
>>    #while ( j < 10 )
>>      sphere { <i*2,2,j*2> MyGrid[i][j]
>>               pigment { red 1 }
>>               finish { phong 1 } }
>>      #declare j = j + 1;
>>    #end
>>    #declare i = i + 1;
>>  #end
>>#end
>>
>>InitGrid()
>>DrawGrid()
>>
>>And in theory this is place to start, but when I render this code I get 10 spheres
instead of
>>100. It would appear that POV Ray does not like nested loops but there is nothing I
can find
>>to support this theory... has anyone else run into this or am I missing somthing
very obvious
>>in my code?
>>--
>>Josh English
>>eng### [at] spiritonecom
>>www.spiritone.com/~english
>>
>>
>
>Jerry Anning
>clem "at" dhol "dot" com

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

From: Lance Birch
Subject: Re: Math problem
Date: 15 Mar 1999 22:44:33
Message: <36edd3a1.0@news.povray.org>
Is it just me or did you not actually write anything in those two previous
posts?  ;-)

--
Lance.


---
For the latest 3D Studio MAX plug-ins, images and much more, go to:
The Zone - http://come.to/the.zone


Post a reply to this message

From: Spider
Subject: Re: Math problem
Date: 15 Mar 1999 22:51:51
Message: <36EDD3BF.F24685B4@bahnhof.se>
he added the same comment that I did.

-- 
//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 12:40:36
Message: <36EE97FB.22C40B3E@spiritone.com>
Thank you. I figured it had to something obvious like that, I only couldn't admit
to it yesterday. Thank you.

I DID take programming courses at one point, granted it was a Modula-2 class, but
it was programming... that's what you forget over the years.



Spider wrote:

>  // initalize the array
>  #macro InitGrid ()
>    #local i = 0;
>    #while ( i < 10 )
>    #local j = 0;
> //RESET J HERE !!!
>      #while ( j < 10 )
>        #declare MyGrid[i][j] = 1;
>        #local j = j + 1;
>      #end
>      #local i = i + 1;
>    #end
>  #end
>
>  #macro DrawGrid ()
>    #local i = 0;
>    #while (i < 10 )
> //RESET J HERE !!!
>    #local j = 0;
>      #while ( j < 10 )
>        sphere { <i*2,2,j*2> MyGrid[i][j]
>                 pigment { red 1 }
>                 finish { phong 1 } }
>        #local j = j + 1;
>      #end
>      #local i = i + 1;
>    #end
>  #end
>
>
> I set the comments. Sorry for screaming :-)
> you only have to reinit J to 0 every outer loop, or it will only happen ince.
> And, use #local inside a macro.
> --
> //Spider
> ( spi### [at] bahnhofse ) [ http://www.bahnhof.se/~spider/ ]
> #declare life = rand(seed(42))*sqrt(-1);

--
Josh English
eng### [at] spiritonecom
www.spiritone.com/~english


Post a reply to this message

Goto Latest 10 Messages Next 6 Messages >>>

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