StadiumShape[{{x1,y1},{x2,y2}},r]
代表一个半径为 r 的在点 {x1,y1} 和 {x2,y2} 之间的体育场形.
StadiumShape
StadiumShape[{{x1,y1},{x2,y2}},r]
代表一个半径为 r 的在点 {x1,y1} 和 {x2,y2} 之间的体育场形.
更多信息和选项
- StadiumShape 可被用作几何区域和图形基元.
- StadiumShape[] 等价于 StadiumShape[{{-1,0},{1,0}},1].
- StadiumShape[r] 等价于 StadiumShape[{{-1,0},{1,0}},r].
- StadiumShape[{p1,p2},r] 代表区域 {p|RegionDistance[Line[p1,p2],p]≤r}.
- StadiumShape 可用在 Graphics 中.
- 在图形中,点 {xi,yi} 可以是 Dynamic 表达式.
- 有些指令,比如 FaceForm、 EdgeForm 和着色会影响图形渲染.
范例
打开所有单元 关闭所有单元基本范例 (5)
StadiumShape[]Graphics[%]Graphics[{Orange, StadiumShape[3]}]Graphics[{Orange, StadiumShape[{{0, 0}, {2, 3}}, 2]}]{Graphics[{Pink, StadiumShape[]}], Graphics[{EdgeForm[Thick], Pink, StadiumShape[]}], Graphics[{EdgeForm[Dashed], Pink, StadiumShape[]}], Graphics[{EdgeForm[Directive[Thick, Dashed, Blue]], Pink, StadiumShape[]}]}获取一个体育场形的 Area:
Area[StadiumShape[]]Area[StadiumShape[{{0, 0}, {x, y}}, 3]]范围 (16)
图形 (6)
规范 (3)
Graphics[{Red, StadiumShape[3], Green, StadiumShape[2], Blue, StadiumShape[1]}]Graphics[{Red, StadiumShape[{{0, 0}, {2, 2}}, 1], Green, StadiumShape[{{-2, 2}, {0, 0}}, 1], Blue, StadiumShape[{{0, 0}, {0, -Sqrt[4]}}, 1]}]Graphics[StadiumShape[], Frame -> True]样式 (2)
Table[Graphics[{c, StadiumShape[]}], {c, {Red, Green, Blue, Yellow}}]FaceForm 和 EdgeForm 可用于指定内部和边界的风格:
Graphics[{FaceForm[Pink], EdgeForm[Directive[Dashed, Thick, Blue]], StadiumShape[]}]Graphics[{Yellow, EdgeForm[Directive[Thick, Blue]], StadiumShape[{{0, 0}, {3, 2}}, 1 / 2]}]坐标 (1)
点可以是 Dynamic:
DynamicModule[{x}, {Slider[Dynamic[x], {0, 2}], Graphics[{StadiumShape[{Dynamic[{x, x}], {-1, -1}}, 1]}, PlotRange -> 3]}]区域 (10)
RegionEmbeddingDimension[StadiumShape[{{Subscript[x, 1], Subscript[y, 1]}, {Subscript[x, 2], Subscript[y, 2]}}, r]]RegionDimension[StadiumShape[{{Subscript[x, 1], Subscript[y, 1]}, {Subscript[x, 2], Subscript[y, 2]}}, r]]{RegionMember[StadiumShape[], {0, 0}], RegionMember[StadiumShape[], {0, 2}]}RegionMember[StadiumShape[{{Subscript[x, 1], Subscript[y, 1]}, {Subscript[x, 2], Subscript[y, 2]}}, r], {x, y}]ℛ = StadiumShape[];{Area[ℛ], RegionMeasure[ℛ]}c = RegionCentroid[ℛ]Graphics[{{Pink, ℛ}, {Black, Point[c]}}]ℛ = StadiumShape[];{RegionDistance[ℛ, {1, 2}], RegionDistance[ℛ, {0, 0}]}{Plot3D[RegionDistance[ℛ, {x, y}], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3&}, Mesh -> 5, Exclusions -> Norm[{x, y}] == 1], ContourPlot[RegionDistance[ℛ, {x, y}], {x, -3, 3}, {y, -3, 3}, Contours -> {{0.5, Red}, {1, Green}, {1.5, Blue}}]}ℛ = StadiumShape[];{SignedRegionDistance[ℛ, {1, 2}], SignedRegionDistance[ℛ, {0, 0}]}Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3&}, Mesh -> {{0}}, MeshShading -> {Red, Green}, Exclusions -> Norm[{x, y}] == 1]ℛ = StadiumShape[{{0, 0}, {2, 2}}, 2];RegionNearest[ℛ, {0, 6}]pts = Table[{1, 2} + 5{Cos[k 2 π / 16], Sin[k 2π / 16]}, {k, 0., 15}];
nst = RegionNearest[ℛ, #]& /@ pts;Legended[Graphics[{{Gray, ℛ}, {Thin, Gray, Line[Transpose[{pts, nst}]]}, {Red, Point[pts]}, {Blue, Point[nst]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]ℛ = StadiumShape[{{0, 0}, {2, 1}}, 1];BoundedRegionQ[ℛ]rr = RegionBounds[ℛ]//QuietGraphics[{Black, ℛ, {EdgeForm[{Dashed, Red}], Opacity[0.1, Yellow], Cuboid@@Transpose[rr]}}]ℛ = StadiumShape[{{0, 0}, {1, 1}}, 1];Integrate[x y, {x, y}∈ℛ]ℛ = StadiumShape[];{MinValue[{x y - x, {x, y}∈ℛ}, {x, y}], ArgMin[{x y - x, {x, y}∈ℛ}, {x, y}]}ℛ = StadiumShape[2];Solve[x^2 + y^2 == 7 && x y == 1 && {x, y}∈ℛ, {x, y}]Show[{Graphics[{{Green, ℛ}, {Blue, Circle[{0, 0}, Sqrt[7]]}}], Plot[1 / x, {x, -3, 5}, PlotRange -> {{-3, 5}, {-3, 6}}], Graphics[{PointSize[Large], Red, Point[{x, y}] /. %}]}, Axes -> True]应用 (4)
Plot3D[Sin[x + Cos[y]], {x, y}∈StadiumShape[]]用 RegionProduct 创建一个三维体育场形的压成品:
ℛ = RegionProduct[StadiumShape[], Line[{{0}, {1}}]];Region[ℛ]p0 = {0, 0};p1 = {-6, -6};p2 = {-5, -15};p3 = {-1, -8};
p4 = {1, -16};p5 = {0, 20};p6 = {0, 28};
p7 = {-5, 17};p8 = {-15, 15};p9 = {-7, 22};
p10 = {-14, 21};leg1 = {StadiumShape[{p0, p1}, 1], StadiumShape[{p1, p2}, 1]};
leg2 = {StadiumShape[{p0, p3}, 1], StadiumShape[{p3, p4}, 1]};
back = StadiumShape[{p0, p5}, 1];
neck = {StadiumShape[{p5, p6}, 1], Disk[p6, 5]};
arm1 = {StadiumShape[{p5, p7}, 1], StadiumShape[{p7, p8}, 1]};
arm2 = {StadiumShape[{p5, p9}, 1], StadiumShape[{p9, p10}, 1]};Graphics[{back, leg1, leg2, neck, arm1, arm2}, ImageSize -> {Automatic, 150}]用 RotationTransform 转动火柴人的四肢:
r[region_, point_, angle_] := GeometricTransformation[region, RotationTransform[angle, point]]Manipulate[Graphics[{back, r[leg1, p0, a1], r[leg2, p0, a2], r[neck, p5, a5], r[arm1, p5, a3], r[arm2, p5, a4]}], {{a1, 0, "Left Leg"}, -Pi, Pi}, {{a2, 0, "Right Leg"}, -Pi, Pi}, {{a3, 0, "Lower Arm"}, -Pi, Pi}, {{a4, 0, "Higher Arm"}, -Pi, Pi}, {{a5, 0, "Neck"}, -Pi, Pi}, SaveDefinitions -> True]利用一组体育场形组成一个弹簧. 假定各个体育场形有水平分量
,做出一个生成弹簧正面部分的体育场形集合的函数,再做出一个生成弹簧后面部分的体育场形集合的函数:
topstadiums[x_] := Table[StadiumShape[{{(i - 1) * x, -Sqrt[4 - x ^ 2 / 4]}, {(i - 1 / 2) * x, Sqrt[4 - x ^ 2 / 4]}}, .5], {i, 5}];bottomstadiums[x_] = Table[StadiumShape[{{(i - 1 / 2) * x, Sqrt[4 - x ^ 2 / 4]}, {i * x, -Sqrt[4 - x ^ 2 / 4]}}, .5], {i, 5}];设定弹簧的正面为比后面浅的灰色,并利用 Manipulate 使其可以交互式伸缩:
Manipulate[Graphics[{GrayLevel[.5], bottomstadiums[x], GrayLevel[.7], topstadiums[x]}, PlotRange -> {{-1, 21}, {-3, 3}}, ImageSize -> Medium], {{x, 2, "Push/Pull:"}, 1, 4}, SaveDefinitions -> True]属性和关系 (6)
Disk 是 StadiumShape 的 p1 靠近 p2 的极限:
Manipulate[Graphics[{Disk[], StadiumShape[{{2, 0}, {2 + n, 0}}, 1]}, PlotRange -> {{-1, 5}, {-1, 1}}, ImageSize -> Small], {{n, 2}, 2, .00001}]StadiumShape 的三维版本是 CapsuleShape:
Graphics3D[CapsuleShape[]]StadiumShape 形成于圆盘和矩形的 RegionUnion:
stadium = RegionUnion[Disk[{0, 0}, 1], Rectangle[{0, -1}, {2, 1}], Disk[{2, 0}, 1]];Region[stadium]Area[stadium]Area[Disk[{0, 0}, 1]] + Area[Rectangle[{0, -1}, {2, 1}]]StadiumShape 是到 Line 距离不超过
的所有点:
Subscript[ℛ, 1] = Line[{{-1, 0}, {1, 0}}];
Subscript[ℛ, 2] = StadiumShape[];Reduce[RegionDistance[Subscript[ℛ, 1], {x, y}] ≤ 1⧦RegionMember[Subscript[ℛ, 2], {x, y}], {x, y}, Reals]ImplicitRegion 可以表示任意 StadiumShape:
Subscript[ℛ, 1] = ImplicitRegion[(x | y)∈Reals && r > 0 && ((1 + x)^2 + y^2 ≤ r^2 || (-1 + x)^2 + y^2 ≤ r^2 || (-2 (-1 + x) ≥ 0 && -2 (1 + x) ≤ 0 && -2 r ≤ -2 y ≤ 2 r)), {x, y}];Subscript[ℛ, 2] = StadiumShape[r];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]一个粗的圆的 Line 看起来就像一个 StadiumShape:
Graphics[{CapForm["Round"], Thickness[1], Line[{{-1, 0}, {1, 0}}]}]巧妙范例 (3)
Graphics[Table[{EdgeForm[Black], Hue[RandomReal[]], StadiumShape[RandomReal[10, {2, 2}], RandomReal[1]]}, {40}]]Graphics[Table[{Hue[t / 30, 1, .9, .3], StadiumShape[{{0, 0}, {3Cos[2Pi t / 30], 3Sin[2Pi t / 30]}}, 1]}, {t, 30}]]Graphics[Table[{EdgeForm[Opacity[.6]], Hue[(-11 + q + 10 r) / 72], StadiumShape[{{0, 0}, (8 - r){Cos[2Pi q / 12], Sin[2Pi q / 12]}}, (8 - r) / 3]}, {r, 6}, {q, 12}]]相关指南
文本
Wolfram Research (2015),StadiumShape,Wolfram 语言函数,https://reference.wolfram.com/language/ref/StadiumShape.html.
CMS
Wolfram 语言. 2015. "StadiumShape." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/StadiumShape.html.
APA
Wolfram 语言. (2015). StadiumShape. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/StadiumShape.html 年
BibTeX
@misc{reference.wolfram_2026_stadiumshape, author="Wolfram Research", title="{StadiumShape}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/StadiumShape.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_stadiumshape, organization={Wolfram Research}, title={StadiumShape}, year={2015}, url={https://reference.wolfram.com/language/ref/StadiumShape.html}, note=[Accessed: 03-November-2026]}