# 计算几何中心

 In[1]:= XRegionCentroid[Point[{{0}, {1}, {3}}]]
 Out[1]=
 In[2]:= XRegionCentroid[Line[{{0}, {1}, {3}}]]
 Out[2]=

 In[3]:= XRegionCentroid[Disk[{x, y}, r]]
 Out[3]=
 In[4]:= XRegionCentroid[Rectangle[{xmin, ymin}, {xmax, ymax}]]
 Out[4]=
 In[5]:= XRegionCentroid[Polygon[{{0, 0}, {3, -1}, {1, 0}, {3, 1}}]]
 Out[5]=
 In[6]:= XRegionCentroid[Polygon[{{0, 0}, {3, -1}, {1, 0}, {3, 1}}]]; Graphics[{LightBlue, Polygon[{{0, 0}, {3, -1}, {1, 0}, {3, 1}}], Red, Point[%]}]
 Out[6]=
 In[7]:= X\[ScriptCapitalR] = DelaunayMesh[RandomReal[1, {25, 2}]]
 Out[7]=
 In[8]:= XShow[\[ScriptCapitalR], Graphics[{Red, PointSize[Medium], Point@RegionCentroid[\[ScriptCapitalR]]}]]
 Out[8]=

 In[9]:= XRegionCentroid[Ball[{x, y, z}, r]]
 Out[9]=
 In[10]:= XRegionCentroid[Tetrahedron[]]
 Out[10]=
 In[11]:= X\[ScriptCapitalR] = Polygon[{{0, 0, 0}, {5/3, 2/3, -(4/3)}, {2/3, 2/3, -(1/3)}, {1, 2, 0}}];
 In[12]:= XGraphics3D[{LightBlue, \[ScriptCapitalR], Red, PointSize[Large], Point[RegionCentroid[\[ScriptCapitalR]]]}]
 Out[12]=
 In[13]:= X\[ScriptCapitalR] = HighlightMesh[ DiscretizeGraphics[ ExampleData[{"Geometry3D", "StanfordBunny"}]], {Style[1, None], Style[2, Opacity[0.5]]}]
 Out[13]=
 In[14]:= XRegionCentroid[\[ScriptCapitalR]]
 Out[14]=
 In[15]:= XRegionCentroid[\[ScriptCapitalR]]; Show[\[ScriptCapitalR], Graphics3D[{Red, Point[%]}]]
 Out[15]=

 In[16]:= XRegionCentroid[Ball[{x, y, z, w}, r]]
 Out[16]=
 In[17]:= XRegionCentroid[Simplex[10]]
 Out[17]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »