POV-Ray : Newsgroups : povray.advanced-users : Distributing spheres of differnent sizes... Server Time
2 Nov 2024 09:19:53 EDT (-0400)
  Distributing spheres of differnent sizes... (Message 1 to 7 of 7)  
From: Rune
Subject: Distributing spheres of differnent sizes...
Date: 3 Jan 2000 17:12:41
Message: <38711ed9@news.povray.org>
Imagine a straight line from a to b. Along that line multiple spheres are
centered. The spheres have different sizes. From a to b the radius of a
sphere gets linearly smaller. I want a certain number of spheres to be on
the line. The first sphere centered at a, and the last sphere on b. I want
the spheres to be distributed along the line in a certain way. It must not
be linearly but relative to the radii(sp?) of the spheres. That is, the
smaller the spheres get, the smaller distance between them.

What I can't figure out is how to calculate the points along the line at
which the spheres must be centered.

It may be possible to use some kind of forces to calculate it, but I would
prefer "straight" math.

Anyone know how to do it?

Oh, if you haven't guessed yet, this is for my Inverse Kinematics Neck...

Greetings,

Rune

---
Updated December 22: http://rsj.mobilixnet.dk
Containing 3D images, stereograms, tutorials,
The POV Desktop Theme, 350+ raytracing jokes,
miscellaneous other things, and a lot of fun!


Post a reply to this message

From: Adam Coffman
Subject: Re: Distributing spheres of differnent sizes...
Date: 3 Jan 2000 19:47:45
Message: <38714331.F4E9E67E@ipfw.edu>
Rune wrote:

> Imagine a straight line from a to b. Along that line multiple spheres are
> centered. The spheres have different sizes. From a to b the radius of a
> sphere gets linearly smaller. I want a certain number of spheres to be on
> the line. The first sphere centered at a, and the last sphere on b. I want
> the spheres to be distributed along the line in a certain way. It must not
> be linearly but relative to the radii(sp?) of the spheres. That is, the
> smaller the spheres get, the smaller distance between them.
>
> What I can't figure out is how to calculate the points along the line at
> which the spheres must be centered.
>
> It may be possible to use some kind of forces to calculate it, but I would
> prefer "straight" math.
>

Here's something interesting, even if it's not what you're trying to
find.

I simplified the problem a bit by setting a=0, so we're looking at a
line segment from 0 to b on the number line.

I'm assuming that b is given, and also r_0, the radius of the sphere
with center 0, is given, and a positive integer n is given.

I'll label the centers c_0=0, c_1, c_2, c_3, ..., c_i, ..., c_n=b, so
there will actually be n+1 spheres centered on the segment.  I'm also
assuming that the spheres are tangent to each other, and the radius
numbers are labeled r_0, r_1, ..., r_n.  (r_0 is the given initial
radius.)

Here's the "linear dependence" of the radius on the center's position:

r_i = m * c_i + r_0.  (note that at i=0, c_i=c_0=0, so r_0=r_0.)

The center of the "i" sphere is to the right of the "i-1" sphere by
distance r_{i-1}+r_i, so:

c_i = c_{i-1} + r_{i-1} + r_i.

From these two equations, we're trying to find the "unknown" center
points c_i.  The only other unknown variable that showed up was the
slope "m" from the first equation.

Here's the solution I got:

c_i = ( ( (1+m)/(1-m) )^i - 1) * r_0 / m.

This isn't so bad, but there's still the problem of finding m.

At i=0, the solution is c_0= 0 * r_0 / m = 0, which we already knew.

At i=n, the solution is c_n = ( ( (1+m)/(1-m) )^n - 1) * r_0 / m, and
also we want to have c_n = b, so we can use this to find m:

b = ( ( (1+m)/(1-m) )^n - 1) * r_0 / m

simplifies into a polynomial equation:

m * b * (1-m)^n = ( (1+m)^n - (1-m)^n ) * r_0.  (*)


Now, since b, r_0, and n were given, you can find m.  Of course, this
isn't going to be pleasant for large n ("large" meaning more than 2)
and there are also going to be as many as n+1 solutions of (*), only
one of which is the m that will work.

Once you get the formula for c_i, you can plug it into the first
equation to get the radius r_i.

I tried this with r_0=4, b=10, and n=4, and got an approximate
solution m=-.3843543262.  There should be 5 spheres, the first with
radius 4, and decreasing in radius (because m is negative), but all
tangent to each other until c_4=10.

In this set-up, the size r_n of the last sphere isn't an input, it's
an output determined entirely by r_0, n, and b.  Another
interpretation of the calculation, which might be closer to your
intent, is that you could pick the slope m in advance, and use m, b,
and n to solve the polynomial solution (*) for r_0.  (at m=0, the
spheres will be the same size, and (*) won't help, but there are
easier ways to solve that problem.)

Adam C.


Post a reply to this message

From: Michael Andrews
Subject: Re: Distributing spheres of differnent sizes...
Date: 6 Jan 2000 11:12:18
Message: <3874BE81.F1F9ABA@reading.ac.uk>
Hi Rune,

Well here's my attempt at the problem:

Given that:
	r_i => radius of sphere i, 0 <= i <= n
	r_0 => radius of sphere at a
	r_n => radius of sphere at b, r_n >= r_0
	p_i => position of sphere i along vector ab
	p_0 => position of sphere at a
	p_n => position of sphere at b

Known values:
	a, b, r_0, n

Since the radii linearly decrease from a to b

	average(r_i) == (r_0 + r_n) / 2

thus average separation is

	vlength(p_n-p_0) / n == r_0 + r_n

so as long as r_0 is between 1/2 and 1 times the average separation as
limits

	r_n == vlength(p_n-p_0)/n - r_0

and

	r_i == r_0 + i*(r_n-r_0)/n

so 

	p_i == p_(i-1) + (p_n-p_0) * (r_(i-1) + r_i) / vlength(p_n-p_0), 1 <= i
<= n

Well, thats my solution anyway. I think it's right ...

	Bye for now,
		Mike Andrews.


Rune wrote:
> 
> Imagine a straight line from a to b. Along that line multiple spheres are
> centered. The spheres have different sizes. From a to b the radius of a
> sphere gets linearly smaller. I want a certain number of spheres to be on
> the line. The first sphere centered at a, and the last sphere on b. I want
> the spheres to be distributed along the line in a certain way. It must not
> be linearly but relative to the radii(sp?) of the spheres. That is, the
> smaller the spheres get, the smaller distance between them.
> 
> What I can't figure out is how to calculate the points along the line at
> which the spheres must be centered.
> 
> It may be possible to use some kind of forces to calculate it, but I would
> prefer "straight" math.
> 
> Anyone know how to do it?
> 
> Oh, if you haven't guessed yet, this is for my Inverse Kinematics Neck...
> 
> Greetings,
> 
> Rune
> 
> ---
> Updated December 22: http://rsj.mobilixnet.dk
> Containing 3D images, stereograms, tutorials,
> The POV Desktop Theme, 350+ raytracing jokes,
> miscellaneous other things, and a lot of fun!


Post a reply to this message

From: Rune
Subject: Re: Distributing spheres of differnent sizes...
Date: 6 Jan 2000 16:23:26
Message: <387507ce@news.povray.org>
Thanks to both of you for your replies! (there were two who replied right?
With this OE newsreader I'm never sure if there's some messages hidden to
me... nevermind...)

After a while I found a solution by myself but I'll have a look at yours
too, of course, because they might be better and it'll be interesting to see
them anyway :-)

The solution I found is available in povray.binaries.scene-files

Greetings,

Rune

---
Updated December 22: http://rsj.mobilixnet.dk
Containing 3D images, stereograms, tutorials,
The POV Desktop Theme, 350+ raytracing jokes,
miscellaneous other things, and a lot of fun!


Post a reply to this message

From: Adam Coffman
Subject: Re: Distributing spheres of differnent sizes...
Date: 7 Jan 2000 12:24:35
Message: <38762154.88C9B9B0@ipfw.edu>
The really nice neck picture in binaries.images shows that my previous
answer wasn't quite what you had in mind.  My formula was for spheres
which are just touching each other, instead of overlapping.

So, I tried the problem again, this time assuming instead that the
distance between the centers was proportional to the radius, and that
the first and last radii were given.  I got the same answer as your
post to binaries.scene-files!

Adam C.


Rune wrote:

> Thanks to both of you for your replies! (there were two who replied right?
> With this OE newsreader I'm never sure if there's some messages hidden to
> me... nevermind...)
>
> After a while I found a solution by myself but I'll have a look at yours
> too, of course, because they might be better and it'll be interesting to see
> them anyway :-)
>
> The solution I found is available in povray.binaries.scene-files


Post a reply to this message

From: Michael Andrews
Subject: Re: Distributing spheres of differnent sizes...
Date: 7 Jan 2000 14:14:30
Message: <38763AB7.3FF8E3@reading.ac.uk>
Adam Coffman wrote:
> 
> The really nice neck picture in binaries.images shows that my previous
> answer wasn't quite what you had in mind.  My formula was for spheres
> which are just touching each other, instead of overlapping.
> 

Yeah, so was mine! I was thinking 'string of beads' rather than
'spheresweep'.

> So, I tried the problem again, this time assuming instead that the
> distance between the centers was proportional to the radius, and that
> the first and last radii were given.  I got the same answer as your
> post to binaries.scene-files!
> 
> Adam C.
> 

I haven't looked at the posted code yet, but I've done similar things
for blob-splines. Oh well, back to designing isosurfaces ...

Bye for now,
	Mike Andrews.


Post a reply to this message

From: Rune
Subject: Re: Distributing spheres of differnent sizes...
Date: 7 Jan 2000 20:14:48
Message: <38768f88@news.povray.org>
Michael Andrews wrote:
>Adam Coffman wrote:
>>
>> The really nice neck picture in binaries.images shows that my previous
>> answer wasn't quite what you had in mind.  My formula was for spheres
>> which are just touching each other, instead of overlapping.
>
>Yeah, so was mine! I was thinking 'string of beads' rather than
>'spheresweep'.

I know, I'm not so good at explaining. :-(

>> So, I tried the problem again, this time assuming instead that the
>> distance between the centers was proportional to the radius, and that
>> the first and last radii were given.  I got the same answer as your
>> post to binaries.scene-files!

That's good!
I know that it then must be the right, probably best and maybe only solution
:-)

>I haven't looked at the posted code yet, but I've done similar things
>for blob-splines.

Blob... splines... Hmm, that should work with the IKN too. I must have a
look at that.

Thank you both again for you efforts! :-)

Greetings,

Rune

---
Updated December 22: http://rsj.mobilixnet.dk
Containing 3D images, stereograms, tutorials,
The POV Desktop Theme, 350+ raytracing jokes,
miscellaneous other things, and a lot of fun!


Post a reply to this message

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