Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'd like a FaceCenteredCubic image as in the in LatticeData docs, but space packed, and cropped on all the boundaries, so that it illustrates the geometry of the calculation that leads to the $\pi/\sqrt{18}$ density result.

The call that produces the plot is

LatticeData["FaceCenteredCubic", "Image"]

but this has small spheres, and probably doesn't have a way to crop on the boundaries. I see that there's a PackingRadius listed in the documentation. I thought it might be possible to use the PackingRadius property, to display the spheres in the lattice in a space packed fashion (so that they touch), but that wouldn't handle the cropping part of the problem.

Is there any easy way to do this, perhaps using the lattice data to draw spheres using the Graphics drawing options, and then using the various ViewAngle type options to crop that appropriately?

share|improve this question

1 Answer 1

up vote 17 down vote accepted

All the information is there, but to adjust the sphere radius I had to do a replacement as follows:

spaceFilledPlot[latticeType_] := 
 LatticeData[latticeType, "Image"] /. 
  Sphere[pt_, r_] :> {Opacity[.5], 
    Sphere[pt, LatticeData[latticeType, "PackingRadius"]]}


close packed

I added the opacity for better visibility of the underlying lattice.

Oh, and you wanted to crop at the boundaries:

 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]



In response to the comment, here is how one could replace the spheres in the default plot by RegionPlot so that the cut surfaces show up in a cropped display, giving a more solid appearance:

volumetricPlot[latticeType_] := Module[
   img = LatticeData[latticeType, "Image"],
   r = LatticeData[latticeType, "PackingRadius"]
   img /. Sphere[pt_, r_] :> {},
    RegionPlot3D[(EuclideanDistance[{x, y, z}, #] < r),
      {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
      Mesh -> False,
      PlotStyle -> Opacity[.5]
      ] &, Cases[img, Sphere[pos_, _] :> pos, Infinity]]


solid filling

Edit 2

There is at least one bug in LatticeData. I just found this when thinking about how to crop a unit cell for a non-cubic lattice. So I tried the hexagonal close-packed structure, which is closely related to the previous example. But here is the plot:



This is clearly not very closely packed! The error is in the "Image" data for this lattice. It's very easy to spot this when you use my function because it expands the spheres to where they should touch. So I'd recommend being very careful when using these data. A somewhat better-working notebook for this case can be downloaded from Mathworld.

share|improve this answer
Very cool. I didn't realize what LatticeData was actually returning here. To understand what you did, running LatticeData["FaceCenteredCubic", "Image"] // InputForm is very helpful. Is there a way to draw the spheres as solids instead of shells? I tried Opacity[1], but that still renders the spheres as shells. – Peeter Joot Jan 31 '13 at 16:38
Yes, you can create a volumetric appearance, but then I have to replace the spheres by something else. I'll edit the post. – Jens Jan 31 '13 at 19:20
fyi. I've submitted a bug report through the wolfram support site for the HCP LatticeData bug (using a notebook containing your volumetricPlot function to illustrate). – Peeter Joot Nov 16 '13 at 14:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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