# Planes for tetragonal lattice

I've edited a code written for cubic lattice to make it for a tertagonal lattice, but the planes are wrong. They should reach the boundary of the shape, so I need a correction for this code:

 Manipulate[
Show[
LatticeData[ Which[Type == "SimpleTetragonal", "SimpleTetragonal"],
"Image"],

Table[ ContourPlot3D[  h*x + k*y + l*z - r == 0,
{x, -1, 1}, {y, -1, 1}, {z, -1, 1},
ColorFunction -> Function[{x, y, z, f}, {Blue, Opacity[Op]}],
Mesh -> False, BoundaryStyle -> Black], {r, -(h + k + l),
h + k + l - 2, 2}],

Graphics3D[{Thick,
Red, Arrow[{{-1.01, -1.01, -1.01}, {1.6, -1.01, -1.01}}],
Blue, Arrow[{{-1.01, -1.01, -1.01}, {-1.01, 1.6, -1.01}}],
Darker@Green, Arrow[{{-1.01, -1.01, -1.01}, {-1.01, -1.01, 1.6}}]
}],
SphericalRegion -> True, ImageSize -> 1.1 {500, 400}
],
{{Type, "SimpleTetragonal", "lattice"}, {"SimpleTetragonal"}},
Row[{"Miller indices", Spacer[20],
Control[{{h, 1, Style["h", Italic]}, Range[0, 10, 1]}], Spacer[20],
Control[{{k, 1, Style["k", Italic]}, Range[0, 10, 1]}], Spacer[20],
Control[{{l, 1, Style["l", Italic]}, Range[0, 10, 1]}]}],
{{Op, 0.5, "plane opacity"}, 0, 1}]


Original code from : https://demonstrations.wolfram.com/CrystallographicPlanesForCubicLattices/

You need to change the variable ranges in ContourPlot3D to match the ranges from LatticeData, which are wider for this lattice than for the one you were using before:

PlotRange@
LatticeData["SimpleTetragonal", "Image"]

(* Out: {{-1.06, 1.06}, {-1.06, 1.06}, {-1.06, 1.56}} *)


So change your ContourPlot3D call to:

ContourPlot3D[
h*x + k*y + l*z - r == 0,
{x, -1.06, 1.06},
{y, -1.06, 1.06},
{z, -1.06, 1.56},
ColorFunction -> Function[{x, y, z, f}, {Blue, Opacity[Op]}],
Mesh -> False, BoundaryStyle -> Black
]

• thanks! @MarcoB actually it didn't work for me (i changed the whole code to make it work lol) but now i know the dimensions. may i ask how to change lattice dimensions? for example i want a Tetragonal with dimensions 11x11x15 in cm. Dec 20, 2020 at 20:16
• @DemaSD not sure what it would mean for the dimensions to be specified in cm. Everything is relative in an image anyway. What would you need it for? Dec 20, 2020 at 20:58
• because i want to compare the atoms (balls at each corner) volume with cell volume (lattice volume), i already know how to change balls volume using this code for example: inline LatticeData["SimpleCubic", "Image"] /. Sphere[cents_, r_] -> Ball[cents, 1.255 r] Dec 20, 2020 at 21:25