# Can a LatticeData image be displayed in a space filled fashion

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?

-

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],

spaceFilledPlot["FaceCenteredCubic"]


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

Oh, and you wanted to crop at the boundaries:

Show[
spaceFilledPlot["FaceCenteredCubic"],
PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]


Edit

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"],
},
Show[
img /. Sphere[pt_, r_] :> {},
Map[
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]]
]
]

volumetricPlot["FaceCenteredCubic"]


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:

volumetricPlot["HexagonalClosePacking"]


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.

-
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