POV-Ray : Newsgroups : povray.advanced-users : Sphere placement issues : Re: Sphere placement issues Server Time
28 Jul 2024 20:30:59 EDT (-0400)
  Re: Sphere placement issues  
From: Christopher James Huff
Date: 21 Mar 2004 22:37:43
Message: <cjameshuff-D9AB84.22375521032004@news.povray.org>
In article <e9ls5054rc1rs76j1p493oi862o85vpgrb@4ax.com>,
 Oldstench <sry### [at] nocom> wrote:

> Ok math wizards... 

Will I do?


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

This is just a tetrahedron. You can easily put the spheres in the proper 
position relative to each other:

Take a cube from <-1,-1,-1> to < 1, 1, 1>.
Place a sphere at four corners of the cube, on opposing diagonals. For 
example: <-1,-1,-1>, < 1, 1,-1>, <-1, 1, 1>, < 1,-1, 1>.
You now have a sphere centered at each corner of the tetrahedron. The 
point where each sphere meets one of its neighbors is the midpoint of 
the cube side they share. Thus, the radius is half the length of the 
diagonal: sqrt(2)/2. Scale the centers by the reciprocal of this to get 
a tetrahedron with unit spheres.

This isn't oriented very conveniently for a pyramid. However, it 
shouldn't be too hard to work out the distance of one sphere center from 
the plane of the other sphere centers, which will give you the 
information you need. Take a vector from the origin to one of the 
spheres as the plane normal. The height of the tetrahedron the spheres 
are placed on will be the length of that vector plus the distance of one 
of the other points to the plane defined by it. Hint: dot product.

I hope that's enough to get you started. It's probably not the best way, 
but it seems simplest.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

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