({{, (RefLink[Simplex, paclet:ref/Simplex])[{(Subscript[p, 1]),…,(Subscript[p, k])}] 
represents the simplex spanned by points (Subscript[p, i]).}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[Simplex, paclet:ref/Simplex]) is also known as point, line segment, triangle, tetrahedron, pentachoron, hexateron, etc.

(RefLink[Simplex, paclet:ref/Simplex]) represents all convex combinations of the given points {(Subscript[λ, 1]) (Subscript[p, 1])+⋯+(Subscript[λ, k]) (Subscript[p, k])|(Subscript[λ, i])≥0∧(Subscript[λ, 1])+⋯+(Subscript[λ, k])==1}. The region is k-1 dimensional when (Subscript[p, i])∈(ℝ^n) are affinely independent and n≥k-1.

Example simplices where rows correspond to embedding dimension:

(RefLink[Simplex, paclet:ref/Simplex])[n] for integer n is equivalent to (RefLink[Simplex, paclet:ref/Simplex])[{{0,…,0},{1,0,…,0},…,{0,…,0,1}}], the unit standard simplex in (ℝ^n).

(RefLink[Simplex, paclet:ref/Simplex]) can be used as a geometric region and graphics primitive.

In graphics, the points (Subscript[p, i]) can be (RefLink[Scaled, paclet:ref/Scaled]) and (RefLink[Dynamic, paclet:ref/Dynamic]) expressions.

Graphics rendering is affected by directives such as (RefLink[FaceForm, paclet:ref/FaceForm]), (RefLink[EdgeForm, paclet:ref/EdgeForm]), (RefLink[Opacity, paclet:ref/Opacity]), and color.

OpenersPrimaryExamplesSection(Spacer1)Examples  (33)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

A (RefLink[Simplex, paclet:ref/Simplex]) in 3D:

Graphics3D[Simplex[{{0,0,1},{1,0,0},{1,0,1},{1,1,1}}]]

And in 2D:

Graphics[Simplex[{{0,0},{1,1},{2,0}}]]

Different styles applied to a simplex:

ℛ=Simplex[3];

{Graphics3D[{Pink,ℛ}],Graphics3D[{EdgeForm[Thick],ℛ}],Graphics3D[{Opacity[0.25],Blue,ℛ}],Graphics3D[{EdgeForm[Directive[Thick,Dotted]],FaceForm[None],ℛ}]}

Volume and centroid:

ℛ=Simplex[{{1,0,0},{1,0,1},{1,1,1},{0,0,1}}];

Volume[ℛ]

RegionCentroid[ℛ]

OpenersExampleSection1(Spacer1)Scope  (20)

OpenersExampleSubsection0(Spacer1)Graphics  (9)

OpenersExampleSubsubsection0(Spacer1)Specification  (3)

A standard unit (RefLink[Simplex, paclet:ref/Simplex]) in 3D:

Graphics3D[Simplex[3]]

A 2D simplex spanning three points:

Graphics[Simplex[{{0,0},{1,1},{2,0}}]]

A simplex in n dimensions is specified by at most n+1 points:

pts={{0,0,1},{1,0,0},{1,0,1},{1,1,1}};

Table[Graphics3D[Simplex[Take[pts,n]]],{n,4}]

OpenersExampleSubsubsection1(Spacer1)Styling  (3)

Different styles applied to a simplex:

ℛ=Simplex[3];

{Graphics3D[{Pink,ℛ}],Graphics3D[{EdgeForm[Thick],ℛ}],Graphics3D[{Opacity[0.25],Blue,ℛ}],Graphics3D[{EdgeForm[Directive[Thick,Dotted]],FaceForm[None],ℛ}]}

Color directives specify the face color:

Table[Graphics3D[{c,Simplex[3]}],{c,{Red,Green,Blue,Yellow}}]

(RefLink[FaceForm, paclet:ref/FaceForm]) and (RefLink[EdgeForm, paclet:ref/EdgeForm]) can be used to specify the styles of the faces and edges:

Graphics3D[{FaceForm[Pink],EdgeForm[Directive[Thick,Dashed,Blue]],Simplex[3]}]

OpenersExampleSubsubsection2(Spacer1)Coordinates  (3)

Specify coordinates by fractions of the plot range:

Graphics3D[Simplex[{Scaled[{0,0,0}],Scaled[{0.5,0,0}],Scaled[{0,0.5,0}],Scaled[{0,0,0.5}]}],PlotRange->{{0,10},{0,10},{0,10}},Axes->True]

Specify scaled offsets from the ordinary coordinates:

Graphics3D[Simplex[{Scaled[{0,0,0.5},{0,0,0}],Scaled[{0,0,0.5},{1,0,0}],Scaled[{0,0,0.5},{0,1,0}],Scaled[{0,0,0.5},{0,0,1}]}],PlotRange->{{0,2},{0,2},{0,2}},Axes->True]

Points can be (RefLink[Dynamic, paclet:ref/Dynamic]):

DynamicModule[{x},{Slider[Dynamic[x],{0,1}],Graphics3D[Simplex[{Dynamic[{1,1,1}x],{1,0,0},{0,1,0},{0,0,1}}]]}]

OpenersExampleSubsection1(Spacer1)Regions  (11)

Embedding dimension is the dimension of the space in which the simplex lives:

RegionEmbeddingDimension[Simplex[{{0,0},{1,0},{0,1}}]]

RegionEmbeddingDimension[Simplex[{{0,0,0},{1,0,0},{0,1,1}}]]

Table[RegionEmbeddingDimension[Simplex[d]],{d,5}]

Geometric dimension is the dimension of the shape itself:

RegionDimension[Simplex[{{0,0},{1,0},{0,1}}]]

RegionDimension[Simplex[{{0,0,0},{1,0,0},{0,1,1}}]]

Table[RegionDimension[Simplex[d]],{d,5}]

Point membership test:

RegionMember[Simplex[{{0,0},{1,0},{0,1}}],{1/2,1/2}]

RegionMember[Simplex[{{0,0},{1,0},{0,1}}],{1,1}]

Get conditions for point membership:

RegionMember[Simplex[2],{x,y}]

Measure and centroid:

RegionMeasure[Simplex[3]]

RegionCentroid[Simplex[3]]

The measure for a standard simplex in dimension d is 1/d!:

Table[RegionMeasure[Simplex[d]],{d,5}]

Distance from a point:

ℛ=Simplex[{{0,0},{1,1},{2,0}}];

{RegionDistance[ℛ,{2,2}],RegionDistance[ℛ,{1/2,1/2}]}

Visualize it:

{Plot3D[Evaluate@RegionDistance[ℛ,{x,y}],{x,-1,3},{y,-1,2},MeshFunctions->{#3&},Mesh->5],ContourPlot[Evaluate@RegionDistance[ℛ,{x,y}],{x,-2,4},{y,-2,3},Contours->{{0.5,Red},{1,Green},{1.5,Blue}}]}

Signed distance from a point:

ℛ=Simplex[{{0,0},{1,1},{2,0}}];

{SignedRegionDistance[ℛ,{2,2}],SignedRegionDistance[ℛ,{1/2,1/2}]}

Plot3D[SignedRegionDistance[ℛ,{x,y}],{x,-1,3},{y,-1,2},MeshFunctions->{#3&},Mesh->{{0}},MeshShading->{Red,Green}]

Nearest point to the region:

ℛ=Simplex[{{0,0},{1,1},{2,0}}];

{RegionNearest[ℛ,{2,2}],RegionNearest[ℛ,{1/3,1/3}]}

Visualize it:

pts=Table[{1,0.25}+1.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"}]]

A simplex is bounded:

ℛ=Simplex[{{0,0,0},{1,0,0},{0,1,0},{0,0,1}}];

BoundedRegionQ[ℛ]

Find its range:

r=RegionBounds[ℛ]

Graphics3D[{{EdgeForm[White],Opacity[0.2,Yellow],Cuboid@@Transpose[r]},ℛ},Boxed->False]

(RefLink[Integrate, paclet:ref/Integrate]) over a simplex:

Integrate[1,{x,y,z}∈Simplex[3]]

Integrate[x y z,{x,y,z}∈Simplex[3]]

Optimize over a simplex:

MinValue[{x y-x,{x,y}∈Simplex[2]},{x,y}]

MaxValue[{Exp[x y],{x,y}∈Simplex[2]},{x,y}]

Solve equations constrained by a simplex:

Reduce[(x-1)(x-2)==0&&{x}∈Simplex[1],{x}]

Reduce[4(x^2)+4(y^2)+4(z^2)==1&&{x,y,z}∈Simplex[3],{x,y,z}]

OpenersExampleSection3(Spacer1)Applications  (1)

Define the Kuhn simplex for dimension n:

KuhnSimplex[n_]:=Simplex@Table[If[j<i,1,0],{i,1,n+1},{j,n}]

The 2D Kuhn simplex:

KuhnSimplex[2]

Graphics[%]

The 3D Kuhn simplex:

KuhnSimplex[3]

Graphics3D[%]

The measure in dimension n is 1/n!:

Table[RegionMeasure[KuhnSimplex[n]],{n,5}]

The centroid in dimension n is {n,n-1,…,1}/(n+1):

Table[RegionCentroid[KuhnSimplex[n]],{n,5}]

OpenersExampleSection4(Spacer1)Properties & Relations  (8)

(RefLink[TriangulateMesh, paclet:ref/TriangulateMesh]) can be used to decompose a volume mesh into simplices:

{ℛ2=DiscretizeGraphics[Rectangle[]],TriangulateMesh[ℛ2]}

{ℛ3=DiscretizeGraphics[Cuboid[]],TriangulateMesh[ℛ3]}

Use options such as (RefLink[MaxCellMeasure, paclet:ref/MaxCellMeasure]) to control the number of simplices:

{TriangulateMesh[ℛ2,MaxCellMeasure->1],TriangulateMesh[ℛ3,MaxCellMeasure->1]}

(RefLink[Point, paclet:ref/Point]) is a special case of (RefLink[Simplex, paclet:ref/Simplex]):

RegionMember[Point[{{0,0}}],{x,y}]

RegionMember[Simplex[{{0,0}}],{x,y}]

(RefLink[Line, paclet:ref/Line]) is a special case of (RefLink[Simplex, paclet:ref/Simplex]):

(Subscript[ℛ, 1])=Line[{{0,0},{1,1}}];
(Subscript[ℛ, 2])=Simplex[{{0,0},{1,1}}];

RegionEqual[(Subscript[ℛ, 1]),(Subscript[ℛ, 2])]

(RefLink[Triangle, paclet:ref/Triangle]) is a special case of (RefLink[Simplex, paclet:ref/Simplex]):

(Subscript[ℛ, 1])=Triangle[{{0,0},{0,1},{1,0}}];
(Subscript[ℛ, 2])=Simplex[{{0,0},{0,1},{1,0}}];

RegionEqual[(Subscript[ℛ, 1]),(Subscript[ℛ, 2])]

(RefLink[Tetrahedron, paclet:ref/Tetrahedron]) is a special case of (RefLink[Simplex, paclet:ref/Simplex]):

(Subscript[ℛ, 1])=Tetrahedron[{{0,0,0},{1,0,0},{0,1,0},{0,0,1}}];
(Subscript[ℛ, 2])=Simplex[{{0,0,0},{1,0,0},{0,1,0},{0,0,1}}];

RegionEqual[(Subscript[ℛ, 1]),(Subscript[ℛ, 2])]

(RefLink[Polygon, paclet:ref/Polygon]) is a generalization of (RefLink[Simplex, paclet:ref/Simplex]) in dimension 2:

(Subscript[ℛ, 1])=Polygon[{{0,0},{0,1},{1,0}}];
(Subscript[ℛ, 2])=Simplex[{{0,0},{0,1},{1,0}}];

RegionEqual[(Subscript[ℛ, 1]),(Subscript[ℛ, 2])]

(RefLink[ImplicitRegion, paclet:ref/ImplicitRegion]) can represent any (RefLink[Simplex, paclet:ref/Simplex]):

(Subscript[ℛ, 1])=ImplicitRegion[(Subscript[t, 1])≥0&&(Subscript[t, 2])≥0&&(Subscript[t, 3])≥0&&(Subscript[t, 4])≥0 &&(Subscript[t, 1])+(Subscript[t, 2])+(Subscript[t, 3])+(Subscript[t, 4])≤1,{(Subscript[t, 1]),(Subscript[t, 2]),(Subscript[t, 3]),(Subscript[t, 4])}];
(Subscript[ℛ, 2])=Simplex[{{0,0,0,0},{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}];

RegionEqual[(Subscript[ℛ, 1]),(Subscript[ℛ, 2])]

(RefLink[Simplex, paclet:ref/Simplex]) is the set of convex combinations of its vertices:

{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3]),(Subscript[p, 4])}={{1,2,3},{1,2,4},{1,3,4},{2,3,4}};
(Subscript[ℛ, 1])=ParametricRegion[{(Subscript[t, 1])(Subscript[p, 1])+(Subscript[t, 2])(Subscript[p, 2])+(Subscript[t, 3])(Subscript[p, 3])+(Subscript[t, 4])(Subscript[p, 4]),(Subscript[t, 1])≥0&&(Subscript[t, 2])≥0&&(Subscript[t, 3])≥0&&(Subscript[t, 4])≥0 &&(Subscript[t, 1])+(Subscript[t, 2])+(Subscript[t, 3])+(Subscript[t, 4])==1},{(Subscript[t, 1]),(Subscript[t, 2]),(Subscript[t, 3]),(Subscript[t, 4])}];
(Subscript[ℛ, 2])=Simplex[{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3]),(Subscript[p, 4])}];

RegionEqual[(Subscript[ℛ, 1]),(Subscript[ℛ, 2])]

OpenersExampleSection5(Spacer1)Neat Examples  (1)

Random collection of simplices:

Graphics[Table[{Hue[RandomReal[]],Simplex[RandomReal[1,{3,2}]]},{10}]]

Graphics3D[Table[{Hue[RandomReal[]],Simplex[RandomReal[1,{4,3}]]},{10}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Point, paclet:ref/Point])  ▪  (RefLink[Line, paclet:ref/Line])  ▪  (RefLink[Triangle, paclet:ref/Triangle])  ▪  (RefLink[Polygon, paclet:ref/Polygon])  ▪  (RefLink[Tetrahedron, paclet:ref/Tetrahedron])  ▪  (RefLink[Polyhedron, paclet:ref/Polyhedron])  ▪  (RefLink[MeshRegion, paclet:ref/MeshRegion])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graphics Objects, paclet:guide/GraphicsObjects])}, {▪(RefLinkPlain[Basic Geometric Regions, paclet:guide/GeometricSpecialRegions])}, {▪(RefLinkPlain[Geometric Computation, paclet:guide/GeometricComputation])}, {▪(RefLinkPlain[Polygons, paclet:guide/Polygons])}, {▪(RefLinkPlain[Solid Geometry, paclet:guide/SolidGeometry])}, {▪(RefLinkPlain[Polyhedra, paclet:guide/Polyhedra])}})}})