POV-Ray : Newsgroups : povray.newusers : Is there a better way of achieving this simple thing : Re: Is there a better way of achieving this simple thing Server Time
29 Jul 2024 00:30:30 EDT (-0400)
  Re: Is there a better way of achieving this simple thing  
From: Elija
Date: 14 Apr 2007 10:30:01
Message: <web.4620e5363ad8003d7fd315660@news.povray.org>
Thanks for the advice. Maybe its because I'm a beginner, but I find
sphere {<0,0,0>,1} much easier to read. The 1.25 was a guess - but it
was exactly what I wanted - how lucky is that?

Anyway that code was the beginnings of my first piccy which I have posted
here for the amusement of all :D

http://news.povray.org/povray.binaries.images/thread/%3Cweb.4620e373f1b9d0837fd315660%40news.povray.org%3E/


Christian Froeschlin <chr### [at] chrfrde> wrote:
> Elija wrote:
>
> > Is there a better way than this of achieving the pyramid of spheres?
>
> Well, you'll have to build it yourself anyway and you seem to be doing
> quite fine, except I think you arrived at "1.25" by trial and error;
> the mathematically correct value would be sqrt(2). Also, you can
> apply the texture to the outer union if all spheres are identical.
>
> As matter of style, you only need one line setting "xco = 0"
> if you do it directly before "#while (xco ...)", you can
> replace sphere {<0,0,0>,1} by sphere {0,1} and the
> double translate by "translate <-4,0,2*zco>".
>
> Here's a sphere pyramid macro I wrote recently:
>
> #macro sphere_grid(n)
> union
> {
>    #local i = 0;
>    #while (i < n)
>      #local j = 0;
>      #while (j < n)
>        sphere {<i,0,j>,0.5}
>        #local j = j + 1;
>      #end
>      #local i = i + 1;
>    #end
> }
> #end
>
> #macro sphere_pyramid(n)
> union
> {
>    #local level = 0;
>    #while (level < n)
>      object
>      {
>        sphere_grid(n-level)
>        translate <0.5*level,level/sqrt(2),0.5*level>
>      }
>      #local level = level + 1;
>    #end
>    translate -(n-1)/2*<1,0,1>
> }
> #end
>
> It was for the following image:
>
>
http://news.povray.org/povray.binaries.images/thread/%3C45c7ba1e@news.povray.org%3E/?ttop=240388&toff=50&mtop=239611&
moff=10


Post a reply to this message

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