POV-Ray : Newsgroups : povray.advanced-users : Sphere placement issues : Re: Sphere placement issues Server Time
28 Jul 2024 20:30:56 EDT (-0400)
  Re: Sphere placement issues  
From: Marvin Taylor
Date: 22 Mar 2004 14:05:07
Message: <405f38e3$1@news.povray.org>
Oldstench wrote:
> Ok math wizards... 
> 
> This scene is just a test of pyramidal sphere structures, but I am
> having a small issue. If I want the topmost sphere to appear as if it
> is laying on top of the 4 sphere base, what kind of math do I need to
> do to get the sphere to be placed in exactly the right position
> vertically?
> 
> The closest I can get is to move the sphere up by twice the radius +
> the radius / pi. This is incorrect, however. 
> 
> If anyone knows the answer (I know you do!) please not only tell me
> what the solution is, but could you explain why? (As long as that is
> not too much trouble.)

If each row (aside from the top) is set up on a rectangular grid, then 
the answer you want is rad*sqrt(2).

Christopher - I did not really follow your response, although I think 
you said the same thing:
 > the radius is half the length of the diagonal: sqrt(2)/2.
 > Scale the centers by the reciprocal of this

However, doesn't "tetrahedron" apply only to a 3 sided "pyramid"?  He 
was asking for a 4-sided one -- is there a mathematical term for that 
particular polyhedron?

Meanwhile Oldstench, try the scene below, and note that 'yy' is the 
height offset which is incremented by R*sqrt(2).   Change 'N' to get 
taller or shorter pyramids.

Marvin

---------------------------
// Try with: +KF1 +KFF16 +W400 +H300

// 4-sided pyramid of balls:
light_source { <0,100,-50>, 1.0 }
light_source { <20,100,10>, 1.0 shadowless }
light_source { <20,-50,10>, 1.0 shadowless }

#declare R = 1;  // Radius of balls.
#declare N = 4;  // number of layers

camera {
  location R*N*<10*sin(clock*2*pi),3,10*cos(clock*2*pi)>
  look_at y*R*N   angle 30
}

plane {y,0 pigment{rgb<0,0,1>}}

#macro show(tag,var) concat(" ",tag,"=",str(var,4,3)) #end
#local yy = R;
#local ii = N;
#while (ii>0)
   #local xx = -R*(ii-1);
   #local aa = 0; #while (aa<ii) #local aa=aa+1;
     #local zz = -R*(ii-1);
     #local bb = 0; #while (bb<ii) #local bb=bb+1;
       sphere { <xx,yy,zz>, R  pigment {rgb<.8.8.8>}}
       #local zz = zz + 2*R;
     #end /* bb */
     #local xx = xx + 2*R;
   #end /* aa */
   #local yy = yy + R*sqrt(2);
#local ii=ii-1; #end /* ii */


Post a reply to this message

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