# Graphing the locus of points a unit distance from a rectangular prism

I am a new Mathematica user.

For one of my first projects, I am attempting to graph the locus of all points that are a unit distance from a rectangular prism with given dimensions.

I have no idea how to do this, except potentially graphing the components of the graph individually (eight eighth-spheres, 12 quarter-cylinders, and a rectangular prism). This seems very tedious.

I would appreciate it if anyone helped me to do this.

p2 = {Ball[{0, 0, 0}, 1]}
p1 = {Ball[{0, 0, 10}, 1]}
p3 = {Ball[{4, 0, 10}, 1]}
p4 = {Ball[{4, 8, 10}, 1]}
p5 = {Ball[{0, 8, 0}, 1]}
p6 = {Ball[{0, 8, 10}, 1]}
p7 = {Ball[{4, 0, 0}, 1]}
p8 = {Ball[{4, 8, 0}, 1]}

Show[Graphics3D[p1], Graphics3D[p2], Graphics3D[p3], Graphics3D[p4],
Graphics3D[p5], Graphics3D[p6], Graphics3D[p7], Graphics3D[p8],
Graphics3D[Cuboid[{0, 0, 0}, {4, 8, 10}]] ,
Graphics3D[Cuboid[{0, 0, 0}, {-1, 8, 10}]] ,
Graphics3D[Cuboid[{0, 0, 0}, {0, 8, 10}]] PlotRange -> All]

• Welcome to the Mathematica Stack Exchange. The introductory book written by the inventor is a good learning resource. There is a fast intro for math students as well as a fast intro for programmers to choose from.
– Syed
Commented Sep 2, 2023 at 1:18
• Please post the Mathematica code about rectangular prism and something you have try. Commented Sep 2, 2023 at 1:38
• Sorry, what does this mean? Commented Sep 2, 2023 at 3:50
• For example ,what is rectangular prism ?Graphics3D[Cuboid[{0, 0, 0}, {3, 4, 5}], Boxed -> False]? We need to post the Mathematica code in this forum. Commented Sep 2, 2023 at 3:57
• Sure that is rectangular prism. Sorry, im new here Commented Sep 2, 2023 at 4:03

• One way is RegionDilation according to a unit ball Ball[{0, 0, 0}, 1].
Graphics3D[{FaceForm[Yellow], EdgeForm[],
RegionDilation[Cuboid[{0, 0, 0}, {4, 8, 10}], Ball[{0, 0, 0}, 1]]},
Boxed -> False]


• Or defined a RegionDistanceFunction and use ContourPlot3D to draw the level set equal to 1.
Clear[reg, dist];
reg = Cuboid[{0, 0, 0}, {4, 8, 10}];
dist = RegionDistance@reg;
ContourPlot3D[
dist@{x, y, z} == 1, {x, -2, 6}, {y, -2, 10}, {z, -2, 12},BoxRatios -> Automatic]


• We can also use the function OpenCascadeShapeFillet in OpenCascadeLink. But we need to expand the Cuboid[{0,0,0},{x,y,z}] to Cuboid[{-r, -r, -r}, {x + r, y + r, z + r}]] at first.
Needs["OpenCascadeLink"];
Needs["NDSolveFEM"];
r = 1;
{x, y, z} = {4, 8, 10};
Cuboid[{-r, -r, -r}, {x + r, y + r, z + r}]];
"ShapeSurfaceMeshOptions" -> {"AngularDeflection" -> 0.1}];
groups = bmesh["BoundaryElementMarkerUnion"];
colors = ColorData["BrightBands"] /@ Subdivide[Length@groups];
bmesh["Wireframe"[
"MeshElementStyle" -> (Directive@{EdgeForm[], FaceForm[#]} & /@
colors)]]


• Thank you! Is there any way to make the components of the solid appear individuakly? Commented Sep 7, 2023 at 19:11
Clear["Global*"];
c1 = Cuboid[{0, 0, 0}, {4, 8, 10}];
df = RegionDistance[c1];
reg[r_] := ImplicitRegion[df[{x, y, z}] <= r, {x, y, z}]

Show[
Region[Style[reg[1], Opacity[0.5, Lighter@Blue]]]
, Region[Style[c1, Opacity[0.5, Lighter@Red]]]
]