POV-Ray : Newsgroups : povray.advanced-users : Sphere placement issues : Re: Sphere placement issues Server Time
28 Jul 2024 20:25:05 EDT (-0400)
  Re: Sphere placement issues  
From: Mark Weyer
Date: 22 Mar 2004 06:34:25
Message: <405ED1B7.5070000@informatik.uni-freiburg.de>
> 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 solution is: Pythagoras

I will assume sphere radii of 1.

Your scene suggests that you want 2 base spheres at positions <0,0,0>
and <2,0,0>. Then the third must be at <1,y,0>, where y is such that
the spheres touch. The do touch, if they are exactly 2 apart, that is
if (1-0)^2+(y-0)^2=2^2, or, equivalently, y=sqrt(3).

If you want, like Christopher James assumes, 3 base spheres, then you
want to place those as above, but in the xz-plane, that is as positions
<0,0,0>, <2,0,0>, and <1,0,sqrt(3)>. Now before we look for the fouth
sphere, let us find the center of the triangle formed by the three
spheres so far. It will be <1,0,z> for some z, so that is is equally
far apart from each of the first two spheres. The requirement for being
as far apart in turn from the third sphere is
   (1-0)^2+(z-0)^2 = (1-1)^2+(sqrt(3)-z)^2
that is
   1+z^2 = 3-2*sqrt(3)*z+z^2
that is
   2*sqrt(3)*z = 2
that is
   z = sqrt(3)/3
The forth sphere must be above this center, so it has coordinates
<1,y,sqrt(3)/3>. Now we are looking for y such that the distance from
the other 3 spheres (say the first) is 2, that is
   (1-0)^2+(y-0)^2+(sqrt(3)/3)^2=2^2
that is
   1+y^2+1/3=4
that is
   y^2=8/3
that is
   y=sqrt(8/3)

If you want, like the term pyramid suggests, 4 base spheres, then
these will be at positions <0,0,0>, <2,0,0>, <0,0,2>, and <2,0,2>. The
fifth sphere will be at <1,y,1> such that its distance from the first
is 2, that is (1-0)^2+(y-0)^2+(1-0)^2=2^2, that is y^2=2, that is
y=sqrt(2).

Be aware of computational flaws I might have made.


-- 
merge{#local i=-11;#while(i<11)#local
i=i+.1;sphere{<i*(i*i*(.05-i*i*(4e-7*i*i+3e-4))-3)10*sin(i)30>.5}#end
pigment{rgbt 1}interior{media{emission x}}hollow}//  Mark Weyer


Post a reply to this message

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