Sphere
更多信息和选项
背景
- Sphere 是一个图形和几何图元,表示在
维空间中的球体. 特别地,Sphere[p,r] 表示在
中的球体
,其圆心和半径分别为 p 和 r,其中 r 可以是任意非负实数,p 可以是任意正长度
. 简写形式 Sphere[p] 等价于 Sphere[p,1], Sphere[n] 等价于 Sphere[ConstantArray[0, n],1],而 Sphere[] 自动运算为 Sphere[{0,0,0}]. - 半径同为
的球体对象(多球体)集合可以使用 Sphere[{p1,…,pk},r] 有效表示,而半径不同的球可以使用 Sphere[{p1,…,pk},{r1,…,rk}] 有效表示. - Sphere 对象可以使用 Graphics 和 Graphics3D 分别在二维和三维上直观地进行格式化. 图形中 Sphere 对象的外观可以通过面部指令 FaceForm(三维),色彩指令如 Red,透明度和高光指令 Opacity 和 Specularity 以及样式选项 Antialiasing 进行修改.
- Sphere 也可以用作执行计算的区域规范. 例如 Integrate[1,{x,y,z}∈Sphere[{0,0,0},r]] 和 Area[Sphere[{0,0,0},r]] 均返回半径为
的球体的表面积
. - Sphere 与许多其他符号相关. Sphere 表示球的边界,可以用 RegionBoundary[Ball[{x,y,z},r]] 计算. 椭球面(不要与由Ellipsoid 表示的固体椭球混淆)可以通过对 Sphere 使用 Scaled 获得. 通过一组给定点的球体可以使用 Circumsphere 获得. Sphere 对象可以表示为 ImplicitRegion[(x-u)2+(y-v)2+(z-w)2r2,{u,v,w}] 或 ParametricRegion[{x,y,z}+r{Cos[θ]Sin[ϕ],Sin[θ]Sin[ϕ],Cos[ϕ]},{{θ,0,2π},{ϕ,0,π}}]. 标准位置的球体的预计算属性可使用 SurfaceData["Sphere",property] 或 Entity["Surface","Sphere"][property] 得到.
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (22)
图形 (12)
规范 (4)
Graphics3D[Sphere[{1, 1, 1}]]Graphics3D[{Sphere[{0, 0, 0}, 1], Sphere[{3, 3, 0}, 2]}]Graphics3D[Sphere[], Axes -> True]s = {0, 0, 0};Graphics3D[Sphere[{s, s + 2}]]样式 (4)
Table[Graphics3D[{c, Sphere[]}], {c, {Red, Green, Blue, Yellow}}]不同属性可以使用 FaceForm 对前面和后面指定:
Graphics3D[{FaceForm[Yellow, Blue], Sphere[]}, PlotRange -> {{-1, 1}, {-.8, 1}, {-1, 1}}]Table[Graphics3D[{Orange, Specularity[White, n], Sphere[]}], {n, {5, 20, 100}}]Graphics3D[{Glow[Red], Black, Sphere[]}]Opacity 指定面透明度:
Table[Graphics3D[{Opacity[o], Sphere[]}], {o, {0.3, 0.5, 0.9}}]坐标 (4)
使用 Scaled 坐标:
Graphics3D[{Sphere[Scaled[{.5, .8, .5}], 1]}, PlotRange -> {{0, 10}, {0, 10}, {0, 10}}, Axes -> True]使用 Scaled 半径:
Graphics3D[Sphere[{0, 0, 0}, Scaled[0.25]], Axes -> True, PlotRange -> 1]Graphics3D[Sphere[Scaled[{0, 0, 0.5}, {2, 2, 2}], 2], PlotRange -> {{0, 10}, {0, 10}, {0, 10}}, Axes -> True]点可以是 Dynamic:
DynamicModule[{x}, {Slider[Dynamic[x], {-0.5, 0.5}], Graphics3D[{Sphere[], Sphere[Dynamic[{x, 1, 1}], 1 / 4]}]}]区域 (10)
RegionEmbeddingDimension[Sphere[{Subscript[c, 1], Subscript[c, 2], Subscript[c, 3]}, r]]RegionDimension[Sphere[{Subscript[c, 1], Subscript[c, 2], Subscript[c, 3]}, r]]ℛ = Sphere[{0, 0, 0}, 1];{RegionMember[ℛ, {1, 0, 0}], RegionMember[ℛ, {0, 0, 0}], RegionMember[ℛ, {1, 1, 1}]}RegionMember[Sphere[{Subscript[c, 1], Subscript[c, 2], Subscript[c, 3]}, r], {x, y, z}]ℛ = Sphere[{0, 0, 0}, 1];{Area[ℛ], RegionMeasure[ℛ]}c = RegionCentroid[ℛ]Graphics3D[{{Opacity[0.5], LightBlue, ℛ}, {PointSize[Large], Red, Point[c]}}]ℛ = Sphere[{0, 0, 0}, 1];{RegionDistance[ℛ, {1, 0, 0}], RegionDistance[ℛ, {0, 0, 0}], RegionDistance[ℛ, {1, 1, 1}]}ContourPlot3D[Evaluate@RegionDistance[ℛ, {x, y, z}], {x, -2, 2}, {y, 0, 2}, {z, -2, 2}, Mesh -> None, Contours -> {0.25, 0.5, 1}, BoxRatios -> Automatic]ℛ = Sphere[{0, 0, 0}, 1];{SignedRegionDistance[ℛ, {1, 0, 0}], SignedRegionDistance[ℛ, {1 / 2, 1 / 2, 1 / 2}], SignedRegionDistance[ℛ, {1, 1, 1}]}ℛ = Sphere[{0, 0, 0}, 1];{RegionNearest[ℛ, {1, 0, 0}], RegionNearest[ℛ, {1 / 2, 1 / 2, 1 / 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[ℛ], 2];
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[Sphere[{Subscript[c, 1], Subscript[c, 2], Subscript[c, 3]}, r]]RegionBounds[Sphere[{0, 0, 0}, r]]ℛ = Sphere[{0, 0, 0}, 1];BoundedRegionQ[ℛ]b = RegionBounds[ℛ]Graphics3D[{{EdgeForm[White], Opacity[0.2, Yellow], Cuboid@@Transpose[b]}, ℛ}, Boxed -> False]ℛ = Sphere[{Subscript[c, 1], Subscript[c, 2], Subscript[c, 3]}, r];Integrate[x y z, {x, y, z}∈ℛ]ℛ = Ball[{1, 2, 3}, 4];MinValue[{x y z - x y, {x, y, z}∈ℛ}, {x, y, z}]//RootReduceℛ = Sphere[{1, 2, 3}, 3];Reduce[x^2 + y^2 + z^2 == 1 && x - y - z == -(1/2) && {x, y, z}∈ℛ, {x, y, z}]应用 (5)
vc = PolyhedronData[#, "Vertices"]& /@ PolyhedronData["Platonic"];Row[Graphics3D[{Specularity[White, 30], Orange, GraphicsComplex[#, Table[Sphere[i], {i, Length[#]}]]}, Boxed -> False]& /@ vc]Graphics3D[{Specularity[White, 30], Table[With[{x = 2Cos[t], y = 2Sin[t], p = 2Sin[t + Pi], q = 2Sin[t + Pi]}, {Hue[t / (5Pi)], Sphere[{x, y, t}, .3], Sphere[{p, q, t}, .3], Cylinder[{{x, y, t}, {p, q, t}}, .1]}], {t, 0, 5Pi, .3}]}, Boxed -> False, Background -> GrayLevel[.2]]Graphics3D[With[{c = ColorData["SouthwestColors"]}, {Opacity[.7], Specularity[White, 20], c[0], Sphere[], Table[{c[i / 7], Sphere[{Cos[2 Pi i / 6], 0, Sin[2Pi i / 6]}, 1]}, {i, 6}]}], Lighting -> "Neutral", Boxed -> False, ViewPoint -> Front]使用 Sphere 在 GraphPlot3D 中渲染节点:
GraphPlot3D[Table[i -> Mod[i ^ 2, 50], {i, 0, 50}], SelfLoopStyle -> None, EdgeShapeFunction -> ({Cylinder[#1, 0.1]}&), VertexShapeFunction -> ({Sphere[#, 0.3]}&)]在 BubbleChart3D 中使用 Sphere:
BubbleChart3D[RandomInteger[100, {2, 20, 4}]]属性和关系 (8)
使用 Scale 获得椭球体:
Graphics3D[Scale[Sphere[], {2, 4, 3}, {0, 0, 0}], Axes -> True]Graphics[Circle[]]ContourPlot3D 产生的球体的隐式指定:
ContourPlot3D[x ^ 2 + y ^ 2 + z ^ 2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> None]ParametricPlot3D 产生的球体的参数指定:
ParametricPlot3D[{Cos[ϕ]Sin[θ], Sin[ϕ]Sin[θ], Cos[θ]}, {ϕ, 0, 2π}, {θ, 0, π}, Mesh -> None]ChemicalData 使用球体和圆柱体表示分子:
ChemicalData["Caffeine", "MoleculePlot"]一些 Import 格式使用球体表示分子:
Import["ExampleData/1PPT.pdb", "Rendering" -> "Spacefilling"]Circumsphere 指定从曲面上的点的 Sphere:
Subscript[ℛ, 1] = Circumsphere[{{0, 0, 1}, {0, 1, 0}, {1, 0, 0}, {0, 0, -1}}];
Subscript[ℛ, 2] = Sphere[{0, 0, 0}, 1];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]ImplicitRegion 可以表示任何 Sphere:
Subscript[ℛ, 1] = ImplicitRegion[(Subscript[t, 1] - Subscript[c, 1])^2 + (Subscript[t, 2] - Subscript[c, 2])^2 + (Subscript[t, 3] - Subscript[c, 3])^2 == 1, {Subscript[t, 1], Subscript[t, 2], Subscript[t, 3]}];
Subscript[ℛ, 2] = Sphere[{Subscript[c, 1], Subscript[c, 2], Subscript[c, 3]}, 1];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]巧妙范例 (4)
Graphics3D[Table[{Hue[RandomReal[]], Sphere[RandomReal[1, {3}], RandomReal[0.1]]}, {200}]]Graphics3D[Sphere[#, 1 / 2]& /@ Tuples[Range[-2, 2], 3]]Graphics3D[Sphere[#, 1 / Sqrt[2]]& /@ Select[Tuples[Range[-3, 3], 3], Mod[Total[#], 2] == 0&]]NIntegrate 所用的样本点:
{val, {data}} = Reap@NIntegrate[Boole[x ^ 2 + y ^ 2 + z ^ 2 < 1], {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, EvaluationMonitor :> Sow[{x, y, z}], MaxRecursion -> 2];Graphics3D[Sphere[#, .05]& /@ data]技术笔记
-
▪
- 三维图形基元
文本
Wolfram Research (2007),Sphere,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Sphere.html (更新于 2014 年).
CMS
Wolfram 语言. 2007. "Sphere." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2014. https://reference.wolfram.com/language/ref/Sphere.html.
APA
Wolfram 语言. (2007). Sphere. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Sphere.html 年
BibTeX
@misc{reference.wolfram_2026_sphere, author="Wolfram Research", title="{Sphere}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Sphere.html}", note=[Accessed: 12-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_sphere, organization={Wolfram Research}, title={Sphere}, year={2014}, url={https://reference.wolfram.com/language/ref/Sphere.html}, note=[Accessed: 12-September-2026]}