POV-Ray : Newsgroups : povray.general : Spiraling objects. : Re: Spiraling objects. Server Time
10 Aug 2024 01:23:30 EDT (-0400)
  Re: Spiraling objects.  
From: Chris Huff
Date: 31 Mar 2000 15:48:55
Message: <chrishuff_99-4F3286.15511531032000@news.povray.org>
In article <38e4f901$1@news.povray.org>, "Wil Hale" 
<whh### [at] nvlarmymil> wrote:

> I thinks this is too advanced to put in new users so here it is.

This is one of the reasons "povray.advanced-users" was created... :-)


> Been trying to figure out how to do a spiral of spheres (or boxes or 
> anything)  Starting with a close sphere and generating the other 
> spheres at appropriate xyz locations depending on whether i wanted 
> the spiral to move away or closer.
> 
> It seems I could do this with a #while statement but the coding eludes 
> me.

A #while loop is the best way to do it. You can also wrap it in a macro, 
to save typing and avoid duplicated code.

#macro Spiral(Obj, Num, StartRadius, StopRadius, Revolutions)
    union {
        #local J=0;
        #while(J<Num)
            object {Obj
                translate x*((StopRadius-StartRadius)
                           *J/(Num-1)+StartRadius)
                rotate y*Revolutions*360*J/(Num-1)
            }
            #local J=J+1;
        #end
    // the } is left off the union so specific transformations,
    // texture, etc. can be specified more easily.
#end


An example of using this macro:
#declare TestObject = sphere  {< 0, 0, 0 >, 0.1}

Spiral(TestObject, 350, 2, 3, 3)
    texture {
        pigment {color White}
    }
    rotate y*90
}

-- 
Christopher James Huff - Personal e-mail: chr### [at] yahoocom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Web page: http://chrishuff.dhs.org/


Post a reply to this message

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