POV-Ray : Newsgroups : povray.binaries.images : Path with sphere attached. . . : Re: Path with sphere attached. . . Server Time
17 Aug 2024 08:16:46 EDT (-0400)
  Re: Path with sphere attached. . .  
From: Mike Williams
Date: 22 Oct 2001 01:26:57
Message: <5ogF3FAU0607EwQ5@econym.demon.co.uk>
Wasn't it Arie L. Stavchansky who wrote:
>Okay, this note may get a little complicated so forgive me if I confuse you.
>
>I have written a macro that makes stacks of rings of spheres as seen in the
>attached image.  The macro adjusts the radius of the spheres in a ring
>dependant on the radius of the ring because I wanted to make sure that all
>spheres are tangential (touching each other at a tangent).
>
>Now, what I would like to do is at the top of the "cylinder of spheres" is
>start to make the rings, but so that every stack of it fits the profile i
>have drawn in.  Figuring out what the radius of the ring should be and the y
>value of the ring is very difficult for me--especially since the sphere's
>radius changes as the ring's radius gets smaller.  I have attempted to
>figure this out and in the second attached image you can see my initial
>approach.
>
>Initially I have thought to define a "path" for the profile by a polynomial
>equation.  I would then input an x-coordinate value into the function with
>the equation and I would get a y-coordinate as an output.  The problem is
>that when you actually go and make this a macro, how can I determine the
>change in the x value so it will give me the correct y value and STILL have
>the sphere be tangential?   In other words how do I determine the
>x-coordinate to input into the function that gives me the appropriate y
>value?  Well I imagined that the change in x could be (as shown in the
>diagram):
>
>radius1*(sin theta1) + radius2(sin theta2)
>
>I have figured out how to determine the radius for each sphere of any ring
>size, but I simply can not figure out how to determine the "thetas" of which
>to use for my equation.  Am I way off?  Is there an easier way to do this?
>
>F. Audet has put up his Apple code which does something similar, and I have
>looked at it, but I am trying to understand how I can figure the math so
>that I can become more adept at making what I want.  Thanks for your time
>and help I appreciate it a great deal since it has helped me realize the
>images I see in my head :)

I think it gets rather messy, but here are a few pointers:-

Firstly, note that the green lines in your diagram are parallel, so
theta1 and theta2 are equal. So

1.      x = (r1 + r2)*sin theta

Now consider the ratio of r2 to r1. Because there are the same number of
spheres in each ring, the size of the spheres decreases by the same
ratio as the radius of the ring. Call the radius of the first ring "R",
then

2.      r2/r1 = (R-x)/R

The polynomial path that you are trying to follow provides the
relationship between y and x

3.      y = p(x)

And we can see that

4.      tan theta = x/y

The values of r1 and R are known, so we now have a system of four
simultaneous equations involving four unknowns (x, y, r2, theta).
Reducing these gives (if my algebra is correct)

5.      x = (r1 + (R - x)/(R * r1)) * sin(atan(x/p(x))

That's a horribly messy equation, but the only unknown in there is x, so
it should be soluble. The method of solution may well depend on the
nature of p(x). Good luck!

Once you've calculated x, obtain y from #3, r2 from #2, and theta (not
that you need it) from #4.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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