Cuboid
更多信息和选项
- Cuboid 也被称为是区间、 长方形、 正方形、 立方体、 长方体、 超正方体、 超立方体、立方体、 原位、超矩形和盒框.
- Cuboid 表示区域
,其中
且
. - Cuboid[] 等价于 Cuboid[{0,0,0}].
- CanonicalizePolyhedron 可用于将长方体转换为显式的 Polyhedron 对象.
- Cuboid 可用于 Graphics 和 Graphics3D.
- 在图形中,点 pmin 和 pmax 可以是 Scaled、ImageScaled、Offset 和 Dynamic 表达式.
- 图形渲染受诸如 FaceForm、EdgeForm、Opacity 和颜色等指令影响.
范例
打开所有单元 关闭所有单元基本范例 (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]}]]范围 (21)
图形 (11)
规范 (3)
样式化 (5)
Table[Graphics3D[{c, Cuboid[]}], {c, {Red, Green, Blue, Yellow}}]FaceForm 和 EdgeForm 可用于指定表面和边的样式:
Graphics3D[{FaceForm[Pink], EdgeForm[Directive[Dashed, Thick, Blue]], Cuboid[]}]可以通过使用 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}}]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 指定表面不透明度:
Table[Graphics3D[{Opacity[o], Cuboid[]}, Boxed -> False], {o, {0.1, 0.5, 0.9}}]坐标 (3)
使用 Scaled 坐标:
Graphics3D[Cuboid[Scaled[{0, .2, .4}], Scaled[{1, .8, .6}]], PlotRange -> {{0, 10}, {0, 10}, {0, 10}}, Axes -> True]Graphics3D[Cuboid[Scaled[{0, 0, 0.5}, {0, 0, 1}]], PlotRange -> {{0, 5}, {0, 5}, {0, 5}}, Axes -> True]点可以是 Dynamic:
DynamicModule[{x}, {Slider[Dynamic[x], {0, 0.5}], Graphics3D[{Cuboid[Dynamic[{x, 0, 0}], {1, 1, 1}]}]}]区域 (10)
RegionEmbeddingDimension[Cuboid[{Subscript[l, 1], Subscript[l, 2], Subscript[l, 3]}, {Subscript[u, 1], Subscript[u, 2], Subscript[u, 3]}]]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}]}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}]}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}]}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[ℛ]ℛ = 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}∈ℛ]ℛ = Cuboid[{0, 0, 0}, {1, 1, 1}];MinValue[{x y z - x y, {x, y, z}∈ℛ}, {x, y, z}]ℛ = 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}]应用 (8)
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]}ℛ = Cuboid[{0, 0, 0}, {l, w, h}];Integrate[x y z, {x, y, z}∈ℛ, Assumptions -> l > 0 && w > 0 && h > 0]ℛ = Cuboid[{0, 0, 0}, Quantity[{4, 3, 2}, "Centimeters"]];d = ChemicalData["Ethanol", "Density"]v = Volume[ℛ]FormulaData["MassDensity", {"ρ" -> d, "V" -> v}]从 RegionBounds 创建一个定界框:
ℛ = Cone[{{0, 0, 0}, {0, 0, 3}}, 1];bounds = RegionBounds[ℛ];boundingBox = Cuboid@@Transpose[bounds];计算 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"]Graphics3D[Cuboid /@ Position[#, 1], ImageSize -> Tiny, Boxed -> False]& /@ Take[CellularAutomaton[{14, {2, 1}, {1, 1, 1}}, {{{{1}}}, 0}, 10], {1, -1, 2}]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}}}}]属性和关系 (8)
使用 Transpose 将 Cuboid 转换为范围规范:
Transpose[List@@Cuboid[{0, 0, 0}, {1, 2, 3}]]相反地,将范围规范转换为 Cuboid 规范:
RegionBounds[Ball[]]Cuboid@@Transpose[%]使用 Rotate 得到 Graphics3D 中所有可能的长方体:
Graphics3D[Rotate[Cuboid[{0, 0, 0}, {1, 2, 1}], -30 Degree, {0, 0, 1}], Axes -> True]Subscript[ℛ, 1] = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}];
Subscript[ℛ, 2] = Cuboid[{0, 0}, {1, 1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = Rectangle[{0, 0}, {1, 1}];
Subscript[ℛ, 2] = Cuboid[{0, 0}, {1, 1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]Hexahedron 是 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 可以表示任何 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 可以表示任何 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 是
-范数的范数球:
ℛ = 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]巧妙范例 (3)
Graphics3D[Table[{EdgeForm[Opacity[.3]], Hue[RandomReal[]], Cuboid[RandomReal[4, 3]]}, {40}]]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}]}]Graphics3D[{EdgeForm[Opacity[.3]], Table[{Hue[RandomReal[], .8], Cuboid[{#[[1]], #[[2]], -n}]}& /@ Tuples[Range[-n, n], 2], {n, 0, 10}]}, Lighting -> "Neutral", Boxed -> False]参见
Cube Hexahedron Parallelogram Rectangle Simplex Polyhedron CanonicalizePolyhedron BoundingRegion
格式: VTK
Function Repository: RoundedCuboid
技术笔记
-
▪
- 三维图形基元
历史
1991年引入 (2.0) | 在以下年份被更新:2014 (10.0) ▪ 2019 (12.0)
文本
Wolfram Research (1991),Cuboid,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Cuboid.html (更新于 2019 年).
CMS
Wolfram 语言. 1991. "Cuboid." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2019. https://reference.wolfram.com/language/ref/Cuboid.html.
APA
Wolfram 语言. (1991). Cuboid. Wolfram 语言与系统参考资料中心. 追溯自 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: 17-August-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: 17-August-2026]}