4
$\begingroup$

I'd like to connect many spheres, by adding a new sphere at some point that's sitting on the surface of a previous sphere. How could we do this?

Suppose I have a unit sphere and a point on it:

myShpere1=Sphere[];
myPoint1=SpherePoints[1];
Graphics3D[{myShpere1, Point[myPoint1]}]

enter image description here

How can we add a second sphere who's surface is touching the previous one at the random point, then a third sphere on a random point of the second sphere, and so on? (for any number of spheres, always choosing a new random point). On a related issue, do spheres have an orientation in MMA, as ellipsoids do? If so, how do we get the "vector/axis" of orientation?

Thanks!

$\endgroup$
5
$\begingroup$
spheres = Sphere[#, 1] & /@ NestList[
  With[{rp = RandomPoint[Sphere[#, 1]]}, 2 rp - #] &, {0, 0, 0}, 5];

chained spheres

If you need the spheres to be self avoiding, then you could look into this question.

All spheres are oriented upward.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ You don't need to map Sphere[], since it can support multiple centers if the radius is fixed: Graphics3D[Sphere[NestList[With[{rp = RandomPoint[Sphere[#, 1]]}, 2 rp - #] &, {0, 0, 0}, 5], 1]] $\endgroup$ – J. M.'s technical difficulties Aug 5 at 14:55
4
$\begingroup$

NestList as in flinty's answer is a bit overkill. You can simply use Accumulate like this:

Graphics3D@Sphere@Accumulate[2 RandomPoint[Sphere[], 5]]

Output

| improve this answer | |
$\endgroup$
  • $\begingroup$ Very cool! From @flinty answer I was able to get the coordinates of the points of sphere-sphere contact from the NestList. How could I get this info from your answer? $\endgroup$ – TumbiSapichu Jul 12 at 0:00
  • 1
    $\begingroup$ @TumbiSapichu That's a great question for you to figure out, I think, to make sure that you truly understand the solution. It's not difficult. $\endgroup$ – C. E. Jul 12 at 0:01
  • $\begingroup$ Ah, I see everything to the right of the accumulate is the points, the rest is just the plotting. I've just never used Accumulate so I though it'd do something weird. Thanks! $\endgroup$ – TumbiSapichu Jul 12 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.