Cuboid
Details and Options
- Cuboid is also known as interval, rectangle, square, cube, rectangular parallelepiped, tesseract, hypercube, orthotope, hyperrectangle, and box.
- Cuboid represents the region
where
and
. - Cuboid[] is equivalent to Cuboid[{0,0,0}].
- CanonicalizePolyhedron can be used to convert a cuboid to an explicit Polyhedron object.
- Cuboid can be used in Graphics and Graphics3D.
- In graphics, the points pmin and pmax can be Scaled, ImageScaled, Offset, and Dynamic expressions.
- Graphics rendering is affected by directives such as FaceForm, EdgeForm, Opacity, and color.
Examples
open all close allBasic Examples (5)
Graphics3D[Cuboid[]]Graphics3D[{Yellow, Cuboid[{0, 0, 0}], Blue, Cuboid[{0.5, 0.5, 0.5}]}]Graphics3D[{Yellow, Cuboid[{0, 0, 0}, {1, 3, 1}], Blue, Cuboid[{2, 1, 1}, {4, 2, 3}]}]{Graphics3D[{Pink, Cuboid[]}], Graphics3D[{EdgeForm[Thick], Cuboid[]}], Graphics3D[{EdgeForm[Dashed], Cuboid[]}], Graphics3D[{EdgeForm[Directive[Thick, Dashed, Blue]], Pink, Cuboid[]}]}Volume[Cuboid[{Subscript[x, 1], Subscript[y, 1], Subscript[z, 1]}, {Subscript[x, 2], Subscript[y, 2], Subscript[z, 2]}]]RegionCentroid[Cuboid[{Subscript[x, 1], Subscript[y, 1], Subscript[z, 1]}, {Subscript[x, 2], Subscript[y, 2], Subscript[z, 2]}]]Scope (21)
Graphics (11)
Specification (3)
Graphics3D[Cuboid[{1, 1, 1}]]Graphics[Cuboid[{1, 1}]]A cuboid parallel to each axis:
Graphics3D[Cuboid[{0, 0, 0}, {3, 2, 1}]]Short form for a unit cube cornered at the origin:
Graphics3D[Cuboid[], Axes -> True]Styling (5)
Color directives specify the face colors of cuboids:
Table[Graphics3D[{c, Cuboid[]}], {c, {Red, Green, Blue, Yellow}}]FaceForm and EdgeForm can be used to specify the styles of the faces and edges:
Graphics3D[{FaceForm[Pink], EdgeForm[Directive[Dashed, Thick, Blue]], Cuboid[]}]Different properties can be specified for the front and back of faces using FaceForm:
Graphics3D[{FaceForm[Yellow, Blue], Cuboid[Scaled[{.1, -.5, .1}], Scaled[{.9, .8, .9}]]}, PlotRange -> {{-1 / 4, 5 / 4}, {1 / 4, 5 / 4}, {-1 / 4, 5 / 4}}]Cuboid with different specular exponents:
Table[Graphics3D[{Orange, Specularity[White, n], Cuboid[]}, Lighting -> {{"Point", White, Scaled[{2, -1, 1.2}]}}], {n, {5, 20, 100}}]Graphics3D[{Glow[Red], Black, Cuboid[]}]Opacity specifies the face opacity:
Table[Graphics3D[{Opacity[o], Cuboid[]}, Boxed -> False], {o, {0.1, 0.5, 0.9}}]Coordinates (3)
Use Scaled coordinates:
Graphics3D[Cuboid[Scaled[{0, .2, .4}], Scaled[{1, .8, .6}]], PlotRange -> {{0, 10}, {0, 10}, {0, 10}}, Axes -> True]Specify scaled offsets from the ordinary coordinates:
Graphics3D[Cuboid[Scaled[{0, 0, 0.5}, {0, 0, 1}]], PlotRange -> {{0, 5}, {0, 5}, {0, 5}}, Axes -> True]Points can be Dynamic:
DynamicModule[{x}, {Slider[Dynamic[x], {0, 0.5}], Graphics3D[{Cuboid[Dynamic[{x, 0, 0}], {1, 1, 1}]}]}]Regions (10)
Embedding dimension is the dimension of the space in which the cuboid lives:
RegionEmbeddingDimension[Cuboid[{Subscript[l, 1], Subscript[l, 2], Subscript[l, 3]}, {Subscript[u, 1], Subscript[u, 2], Subscript[u, 3]}]]Geometric dimension is the dimension of the shape itself:
RegionDimension[Cuboid[{Subscript[l, 1], Subscript[l, 2], Subscript[l, 3]}, {Subscript[u, 1], Subscript[u, 2], Subscript[u, 3]}]]ℛ = Cuboid[{0, 0, 0}, {2, 2, 2}];{RegionMember[ℛ, {1, 1, 1}], RegionMember[ℛ, {3, 3, 3}]}Get conditions for point membership:
RegionMember[Cuboid[{Subscript[l, 1], Subscript[l, 2], Subscript[l, 3]}, {Subscript[u, 1], Subscript[u, 2], Subscript[u, 3]}], {x, y, z}]ℛ = Cuboid[{0, 0, 0}, {2, 2, 2}];{Volume[ℛ], RegionMeasure[ℛ]}c = RegionCentroid[ℛ]Graphics3D[{{Opacity[0.5], LightBlue, ℛ}, {PointSize[Large], Red, Point[c]}}]ℛ = Cuboid[{0, 0, 0}, {2, 2, 2}];{RegionDistance[ℛ, {1, 1, 1}], RegionDistance[ℛ, {3, 3, 3}]}The equidistance contours for a cuboid:
ContourPlot3D[Evaluate@RegionDistance[Cuboid[{-1, -1, -1}, {1, 1, 1}], {x, y, z}], {x, -2.1, 2.1}, {y, -2.1, 2.1}, {z, -2.1, 2.1}, Mesh -> None, Contours -> {0.25, 0.5, 1}, ContourStyle -> ColorData[94, "ColorList"], Lighting -> "Neutral", BaseStyle -> Opacity[0.5], BoxRatios -> Automatic]ℛ = Cuboid[{0, 0, 0}, {2, 2, 2}];{SignedRegionDistance[ℛ, {1, 1, 1}], SignedRegionDistance[ℛ, {3, 3, 3}]}ℛ = Cuboid[{-1, -1, -1}, {1, 1, 1}];{RegionNearest[ℛ, {0, 0, 0}], RegionNearest[ℛ, {2, 2, 2}]}Nearest points to an enclosing sphere:
spherePoints[{n_, m_}, c_, r_] :=
Flatten[Table[c + r{Cos[k 2π / n]Sin[l π / m], Sin[k 2π / n]Sin[l π / m], Cos[l π / m]}, {k, 0., n - 1}, {l, 0., m - 1}], 1];pl = spherePoints[{16, 8}, RegionCentroid[ℛ], 3];
npl = Table[RegionNearest[ℛ, p], {p, pl}];Legended[Graphics3D[{ℛ, {Thin, Gray, Line[Transpose[{pl, npl}]]}, {Red, Point[pl]}, {PointSize[Medium], Blue, Point[npl]}}, Lighting -> "Neutral", Boxed -> False], PointLegend[{Red, Blue}, {"start", "nearest"}]]BoundedRegionQ[Cuboid[{Subscript[l, 1], Subscript[l, 2], Subscript[l, 3]}, {Subscript[u, 1], Subscript[u, 2], Subscript[u, 3]}]]ℛ = Cuboid[{-1, -1, -1}, {1, 1, 1}];BoundedRegionQ[ℛ]r = RegionBounds[ℛ]Integrate over a cuboid region:
ℛ = Cuboid[{Subscript[l, 1], Subscript[l, 2], Subscript[l, 3]}, {Subscript[u, 1], Subscript[u, 2], Subscript[u, 3]}];Integrate[x y z, {x, y, z}∈ℛ]Optimize over a cuboid region:
ℛ = Cuboid[{0, 0, 0}, {1, 1, 1}];MinValue[{x y z - x y, {x, y, z}∈ℛ}, {x, y, z}]Solve equations in a cuboid region:
ℛ = Cuboid[{0, 0, 0}, {1, 1, 1}];Reduce[x^2 + y^2 + z^2 == 1 && x - y - z == -(1/2) && z^2 == x y + (1/4) && {x, y, z}∈ℛ, {x, y, z}]Applications (8)
Define a cuboid region by length, width, and height:
cuboid[l_, w_, h_] := Cuboid[{0, 0, 0}, {l, w, h}]Volume[cuboid[l, w, h]]Region /@ {cuboid[5, 1, 1], cuboid[2, 2, 4], cuboid[3, 3, 3]}Total mass for a cuboid region with density given by
:
ℛ = Cuboid[{0, 0, 0}, {l, w, h}];Integrate[x y z, {x, y, z}∈ℛ, Assumptions -> l > 0 && w > 0 && h > 0]Find the mass of ethanol in a cuboid:
ℛ = Cuboid[{0, 0, 0}, Quantity[{4, 3, 2}, "Centimeters"]];d = ChemicalData["Ethanol", "Density"]v = Volume[ℛ]Mass of ethanol in the cuboid:
FormulaData["MassDensity", {"ρ" -> d, "V" -> v}]Create a bounding box from RegionBounds:
ℛ = Cone[{{0, 0, 0}, {0, 0, 3}}, 1];bounds = RegionBounds[ℛ];boundingBox = Cuboid@@Transpose[bounds];Compute the difference in Volume:
Volume[boundingBox] - Volume[ℛ]Show[Graphics3D[{ℛ, EdgeForm[White], Opacity[0.2, Yellow], boundingBox}], Boxed -> False]data = RandomReal[{1, 10}, {12, 4}];Graphics3D[MapIndexed[{Hue[(Last[#2] - 1) / 4], Cuboid[Append[{1, 2}#2 - {.5, .5}, 0], Append[{1, 2}#2 + {.5, .5}, #1]]}&, data, {2}], Axes -> {False, False, True}, Lighting -> "Neutral"]Show a sequence of steps in the evolution of a 3D cellular automaton:
Graphics3D[Cuboid /@ Position[#, 1], ImageSize -> Tiny, Boxed -> False]& /@ Take[CellularAutomaton[{14, {2, 1}, {1, 1, 1}}, {{{{1}}}, 0}, 10], {1, -1, 2}]Use as a simple way to visualize volumes:
cuboidRegionPlot3D[p_, {x_, xmin_, xmax_, dx_}, {y_, ymin_, ymax_, dy_}, {z_, zmin_, zmax_, dz_}] := Module[{f = Function@@{{x, y, z}, p}}, Graphics3D[Table[If[f[x, y, z], Cuboid[{x, y, z}, {x, y, z} + {dx, dy, dz}], {}], {x, xmin, xmax, dx}, {y, ymin, ymax, dy}, {z, zmin, zmax, dz}]]]cuboidRegionPlot3D[1 ≤ x ^ 2 + y ^ 2 + z ^ 2 ≤ 2 && x y z ≥ 0, {x, -2, 2, .1}, {y, -2, 2, 0.1}, {z, -2, 2, 0.1}]Table[Graphics3D[With[{p = First@v, q = Last@v}, {Red, Thick, Line[{1.5p - .5q, 1.5q - .5p}], Yellow, EdgeForm[], Table[Rotate[Cuboid[], 2Pi k / 20, p - q, q], {k, 20}]}]],
{v, {{{1, 1, 1}, {0, 0, 0}}, {{1, .5, 1}, {0, .5, 0}}, {{.7, .7, 1}, {.3, .3, 0}}}}]Properties & Relations (8)
Use Transpose to convert Cuboid to a range specification:
Transpose[List@@Cuboid[{0, 0, 0}, {1, 2, 3}]]And conversely, a range specification to a Cuboid specification:
RegionBounds[Ball[]]Cuboid@@Transpose[%]Use Rotate to get all possible cuboids in Graphics3D:
Graphics3D[Rotate[Cuboid[{0, 0, 0}, {1, 2, 1}], -30 Degree, {0, 0, 1}], Axes -> True]Polygon is a generalization of Cuboid in 2D:
Subscript[ℛ, 1] = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}];
Subscript[ℛ, 2] = Cuboid[{0, 0}, {1, 1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]Rectangle is a special case of Cuboid:
Subscript[ℛ, 1] = Rectangle[{0, 0}, {1, 1}];
Subscript[ℛ, 2] = Cuboid[{0, 0}, {1, 1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]Hexahedron is a generalization of Cuboid:
Subscript[ℛ, 1] = Hexahedron[{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}, {1, 0, 1}}];
Subscript[ℛ, 2] = Cuboid[{0, 0, 0}, {1, 1, 1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]ImplicitRegion can represent any Cuboid:
Subscript[ℛ, 1] = ImplicitRegion[0 ≤ Subscript[t, 1] ≤ 1 && 0 ≤ Subscript[t, 2] ≤ 1 && 0 ≤ Subscript[t, 3] ≤ 1, {Subscript[t, 1], Subscript[t, 2], Subscript[t, 3]}];
Subscript[ℛ, 2] = Cuboid[{0, 0, 0}, {1, 1, 1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]Parallelepiped can represent any Cuboid:
Subscript[ℛ, 1] = Parallelepiped[{0, 0, 0}, {{1, 0, 0}, {0, 2, 0}, {0, 0, 3}}];
Subscript[ℛ, 2] = Cuboid[{0, 0, 0}, {1, 2, 3}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]Cuboid is a norm ball for the
-norm:
ℛ = Cuboid[{-1, -1, -1}, {1, 1, 1}];Reduce[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}∈ℛ⧦Norm[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, ∞] ≤ 1, {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, Reals]Neat Examples (3)
Graphics3D[Table[{EdgeForm[Opacity[.3]], Hue[RandomReal[]], Cuboid[RandomReal[4, 3]]}, {40}]]Sweep a cuboid around an axis:
Graphics3D[{Opacity[0.3], EdgeForm[], Table[{ColorData["Rainbow"][Rescale[c, {0, 2Pi}]], GeometricTransformation[Cuboid[], RotationTransform[c, {-1, 2, -3}, {1.5, 0, 0}]]}, {c, 0, 2Pi, 2Pi / 12}]}]A pyramid with random color cubes:
Graphics3D[{EdgeForm[Opacity[.3]], Table[{Hue[RandomReal[], .8], Cuboid[{#[[1]], #[[2]], -n}]}& /@ Tuples[Range[-n, n], 2], {n, 0, 10}]}, Lighting -> "Neutral", Boxed -> False]See Also
Cube Hexahedron Parallelogram Rectangle Simplex Polyhedron CanonicalizePolyhedron BoundingRegion
Formats: VTK
Function Repository: RoundedCuboid
Tech Notes
Related Guides
History
Introduced in 1991 (2.0) | Updated in 2014 (10.0) ▪ 2019 (12.0)
Text
Wolfram Research (1991), Cuboid, Wolfram Language function, https://reference.wolfram.com/language/ref/Cuboid.html (updated 2019).
CMS
Wolfram Language. 1991. "Cuboid." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/Cuboid.html.
APA
Wolfram Language. (1991). Cuboid. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Cuboid.html
BibTeX
@misc{reference.wolfram_2026_cuboid, author="Wolfram Research", title="{Cuboid}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/Cuboid.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_cuboid, organization={Wolfram Research}, title={Cuboid}, year={2019}, url={https://reference.wolfram.com/language/ref/Cuboid.html}, note=[Accessed: 12-June-2026]}