({{, (RefLink[Triangle, paclet:ref/Triangle])[{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3])}] 
represents a filled triangle with corner points (Subscript[p, 1]), (Subscript[p, 2]), and (Subscript[p, 3]).}, {, (RefLink[Triangle, paclet:ref/Triangle])[{{(Subscript[p, 11]),(Subscript[p, 12]),(Subscript[p, 13])},…}]
represents a collection of triangles. }})

OpenersNotesSection(Spacer1)Details and Options

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

(RefLink[Triangle, paclet:ref/Triangle]) represents a planar region consisting of all convex combinations of corner points (Subscript[p, i]), {(Subscript[λ, 1]) (Subscript[p, 1])+(Subscript[λ, 2]) (Subscript[p, 2])+(Subscript[λ, 3]) (Subscript[p, 3])|(Subscript[λ, i])≥0∧(Subscript[λ, 1])+(Subscript[λ, 2])+(Subscript[λ, 3])==1}.

(RefLink[Triangle, paclet:ref/Triangle])[] is equivalent to (RefLink[Triangle, paclet:ref/Triangle])[{{0,0},{1,0},{0,1}}].

(RefLink[CanonicalizePolygon, paclet:ref/CanonicalizePolygon]) can be used to convert a triangle to an explicit (RefLink[Polygon, paclet:ref/Polygon]) object.

As a geometric region, the points (Subscript[p, i]) can have any length.

(RefLink[Triangle, paclet:ref/Triangle]) can be used in (RefLink[Graphics, paclet:ref/Graphics]) and (RefLink[Graphics3D, paclet:ref/Graphics3D]).

In graphics, the points (Subscript[p, i]) can be (RefLink[Scaled, paclet:ref/Scaled]), (RefLink[Offset, paclet:ref/Offset]), (RefLink[ImageScaled, paclet:ref/ImageScaled]), 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[Texture, paclet:ref/Texture]), and color.

The following options and settings can be used in graphics:

(RefLink[Triangle, paclet:ref/Triangle]) can be used with symbolic points in (RefLink[GeometricScene, paclet:ref/GeometricScene]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (34)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

A standard triangle in 2D:

Graphics[Triangle[]]

A triangle in 3D:

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

Different styles applied to (RefLink[Triangle, paclet:ref/Triangle]):

ℛ=Triangle[{{0,0},{1,1},{2,0}}];
{Graphics[{Pink,ℛ}],Graphics[{EdgeForm[Thick],Pink,ℛ}],Graphics[{EdgeForm[Dashed],Pink,ℛ}],Graphics[{EdgeForm[Directive[Thick,Dashed,Blue]],Pink,ℛ}]}

Area and centroid:

Area[Triangle[{{0,0},{1,0},{1,1}}]]

RegionCentroid[Triangle[{{0,0},{1,0},{1,1}}]]

OpenersExampleSection1(Spacer1)Scope  (18)

OpenersExampleSubsection0(Spacer1)Graphics  (8)

OpenersExampleSubsubsection0(Spacer1)Specification  (3)

A standard triangle in 2D:

Graphics[Triangle[]]

A triangle in 3D:

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

Multiple triangles:

t1={{0,0},{1,1},{2,0}};
t2=t1+3/2;

Graphics[Triangle[{t1,t2}]]

OpenersExampleSubsubsection1(Spacer1)Styling  (2)

Color directives specify the face color:

Table[Graphics[{c,Triangle[]}],{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 interior and boundary:

Graphics[{FaceForm[Pink],EdgeForm[Directive[Thick,Dashed,Blue]],Triangle[]}]

OpenersExampleSubsubsection2(Spacer1)Coordinates  (3)

Use (RefLink[Scaled, paclet:ref/Scaled]) coordinates:

Graphics[Triangle[{Scaled[{0.1,0.1}],Scaled[{0.9,0.1}],Scaled[{0.1,0.9}]}],Frame->True,PlotRange->{{0,10},{0,10}}]

Use (RefLink[ImageScaled, paclet:ref/ImageScaled]) coordinates:

Graphics[Triangle[{ImageScaled[{0,0}],ImageScaled[{1,0}],ImageScaled[{0,1}]}],Frame->True,PlotRange->{{0,10},{0,10}}]

Use (RefLink[Offset, paclet:ref/Offset]) coordinates:

Graphics[Triangle[{Offset[{10,10},{0,0}],Offset[{-10,10},{1,0}],Offset[{10,-10},{0,1}]}],Frame->True]

OpenersExampleSubsection1(Spacer1)Regions  (10)

Embedding dimension is the length of the coordinates:

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

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

Geometric dimension refers to the region it specifies:

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

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

Membership testing:

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

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

Conditions for point membership:

RegionMember[ℛ,{x,y}]

(RefLink[Area, paclet:ref/Area]):

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

{Area[ℛ],RegionMeasure[ℛ]}

Centroid:

c=RegionCentroid[ℛ]

Graphics[{{Pink,ℛ},{Black,Point[c]}}]

Distance from a point to a (RefLink[Triangle, paclet:ref/Triangle]):

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

RegionDistance[ℛ,{1,1}]

Plot it:

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

Signed distance from a point to the triangle:

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

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

Plot it:

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

Nearest point:

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

RegionNearest[ℛ,{1,1}]

Visualize it:

pts=Table[{1/3,1/3}+{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 triangle is bounded:

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

BoundedRegionQ[ℛ]

The bounding range:

rr=RegionBounds[ℛ]

Graphics[{Black,ℛ,{EdgeForm[{Dashed,Red}],Opacity[0.1,Yellow],Cuboid@@Transpose[rr]}}]

Integrate over a triangle:

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

Integrate[1,{x,y}∈ℛ]

Integrate[x y,{x,y}∈ℛ]

Optimize over a triangle:

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

Minimize[{(((x-1/2))^2)(((y-1/4))^2)+1,{x,y}∈ℛ},{x,y}]

Plot the function over the region:

Plot3D[(((x-1/2))^2)(((y-1/4))^2)+1,{x,y}∈ℛ]

Solve equations with triangle constraints:

ℛ=Triangle[{{0,0},{2,0},{0,2}}];

Reduce[(x^2)+(y^2)==1&&{x,y}∈ℛ,{x,y}]

OpenersExampleSection3(Spacer1)Applications  (6)

The standard simplex and Kuhn simplex in 2D are triangles:

standard=Triangle[{{0,0},{1,0},{0,1}}];
kuhn=Triangle[{{0,0},{1,0},{1,1}}];
{Graphics[standard,PlotLabel->"Standard"],Graphics[kuhn,PlotLabel->"Kuhn"]}

Define an equilateral triangle by side length:

EquilateralTriangle[s_]:=Triangle[{{0,0},{s,0},{(s/2),(((Sqrt[3]) s)/2)}}]

t=EquilateralTriangle[2]

Visualize it:

Graphics[t]

Compute its (RefLink[Area, paclet:ref/Area]):

Area[EquilateralTriangle[s]]

Equivalently use (RefLink[SSSTriangle, paclet:ref/SSSTriangle]):

SSSTriangle[s,s,s]

Define an isosceles triangle by base length and height:

IsoscelesTriangle[b_,h_]:=Triangle[{{0,0},{b,0},{(b/2),h}}]

t=IsoscelesTriangle[2,3]

Visualize it:

Graphics[t]

Compute its (RefLink[Area, paclet:ref/Area]):

Area[IsoscelesTriangle[b,h]]

Find a perpendicular bisector of a triangle:

pts={a,b,c}={{1,2},{0,0},{3,0}};

circumCenter=RegionCentroid[Circumsphere[pts]];

bisector=Line[{circumCenter,RegionCentroid[Line[{a,b}]]}];

Visualize circumcenter and bisectors in red:

Graphics[{{LightGray,Circumsphere[pts]},{LightBlue,Triangle[pts]},{Dashed,Red,bisector},{Black,Point[pts]},{Red,PointSize[Large],Point[circumCenter]}}]

One way of measuring the quality of a triangle is the radius/edge ratio:

RadiusEdgeRatio[Triangle[pl_]]:=Last[Circumsphere[pl]]/Min[Norm/@Subsets[pl,{2}]]

RadiusEdgeRatio[Triangle[{{0,0},{1,0},{1,1}}]]

A lower ratio indicates that the triangle will not be unusually thin:

t1=Triangle[{{0,0},{1,0},{1,1}}];
t2=Triangle[{{0,0},{10,0},{1,1}}];
{Graphics[t1,PlotLabel->N@RadiusEdgeRatio[t1]],Graphics[t2,PlotLabel->N@RadiusEdgeRatio[t2]]}

A triangle can be subdivided into four sub-triangles:

SymmetricSubdivision[Triangle[pl_],k_]/;0≤k<2^Length[pl]:=
Module[{n=Length[pl]-1,i0,bl,pos},
i0=DigitCount[k,2,1]; bl=IntegerDigits[k,2,n];
pos=FoldList[If[#2==0,#1+{0,1},#1+{1,0}]&,{0,i0},Reverse[bl]];
Triangle@Map[Mean,Extract[pl,#]&/@Map[{#}&,pos+1,{2}]] 
]

Graphics[SymmetricSubdivision[Triangle[{{0,0},{1,0},{1,1}}],#]&/@Range[0,3],BaseStyle->Directive[LightBlue,EdgeForm[Gray]]]

This can be done recursively:

NestedSymmetricSubdivision[Triangle[pl_],level_Integer]/;level==0:=Triangle[pl]
NestedSymmetricSubdivision[Triangle[pl_],level_Integer]/;level>0:=Flatten[NestedSymmetricSubdivision[SymmetricSubdivision[Triangle[pl],#],level-1]&/@Range[0,3],1]

Graphics[NestedSymmetricSubdivision[Triangle[{{0,0},{1,0},{1,1}}],3],BaseStyle->Directive[LightBlue,EdgeForm[Gray]]]

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

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

(Subscript[ℛ, 1])=Triangle[{{0,0},{1,0},{0,1}}];
(Subscript[ℛ, 2])=Polygon[{{0,0},{1,0},{0,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},{1,0},{0,1}}];
(Subscript[ℛ, 2])=Simplex[{{0,0},{1,0},{0,1}}];

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

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

(Subscript[ℛ, 1])=ImplicitRegion[0≤x≤1&&0≤y≤1-x,{x,y}];
(Subscript[ℛ, 2])=Triangle[{{0,0},{1,0},{0,1}}];

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

(RefLink[ParametricRegion, paclet:ref/ParametricRegion]) can represent any (RefLink[Triangle, paclet:ref/Triangle]) region:

(Subscript[ℛ, 1])=ParametricRegion[{u,v},{{u,0,1},{v,0,1-u}}];
(Subscript[ℛ, 2])=Triangle[{{0,0},{1,0},{0,1}}];

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

(RefLink[BoundaryMeshRegion, paclet:ref/BoundaryMeshRegion]) can represent any (RefLink[Triangle, paclet:ref/Triangle]) region:

BoundaryMeshRegion[{{0,0},{1,0},{0,1}},Line[{1,2,3,1}]]

OpenersExampleSection5(Spacer1)Neat Examples  (1)

A collection of random triangles:

Graphics[{EdgeForm[Black],Table[{Hue[RandomReal[]],Triangle[RandomReal[2,{3,2}]]},{20}]}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Polygon, paclet:ref/Polygon])  ▪  (RefLink[AASTriangle, paclet:ref/AASTriangle])  ▪  (RefLink[SSSTriangle, paclet:ref/SSSTriangle])  ▪  (RefLink[ASATriangle, paclet:ref/ASATriangle])  ▪  (RefLink[SASTriangle, paclet:ref/SASTriangle])  ▪  (RefLink[Tetrahedron, paclet:ref/Tetrahedron])  ▪  (RefLink[Simplex, paclet:ref/Simplex])  ▪  (RefLink[GeometricScene, paclet:ref/GeometricScene])}})}})

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