Function Repository Resource:

SimplexOrientation

Source Notebook

Get the orientation of a simplex

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["SimplexOrientation"][simplex]

returns the orientation of simplex.

ResourceFunction["SimplexOrientation"][{simplex1,simplex2,}]

returns the orientation of simplices in the given complex.

Details and Options

A simplex can be specified by any of the following:
Point[v] a point
Line[{v1,v2}] a line segment
Triangle[{v1,v2,v3}] or Polygon[{v1,v2,v3}]a filled triangle
Tetrahedron[{v1,v2,v3,v4}] a filled tetrahedron
Simplex[{v1,v2,,vn}] an n-1 dimensional simplex

Examples

Basic Examples (3) 

Get the orientation of a simplex:

In[1]:=
ResourceFunction["SimplexOrientation"][Simplex[{a, b}]]
Out[1]=
In[2]:=
ResourceFunction["SimplexOrientation"][Simplex[{b, a}]]
Out[2]=

Find the permutations of the vertices of a simplex that are equivalent to the original simplex:

In[3]:=
s = Simplex[{a, b, c}]
Out[3]=
In[4]:=
p = Simplex /@ Permutations @@ s
Out[4]=
In[5]:=
Select[p, ResourceFunction["SimplexOrientation"][#] === ResourceFunction["SimplexOrientation"][s] &]
Out[5]=

Get orientations for a list of simplices:

In[6]:=
Simplex /@ Permutations[{a, b, c}]
Out[6]=
In[7]:=
ResourceFunction["SimplexOrientation"][%]
Out[7]=

Scope (6) 

SimplexOrientation works with Point:

In[8]:=
ResourceFunction["SimplexOrientation"][Point[{1}]]
Out[8]=

SimplexOrientation works with Line:

In[9]:=
ResourceFunction["SimplexOrientation"][Line[{a, b}]]
Out[9]=
In[10]:=
ResourceFunction["SimplexOrientation"][Line[{b, a}]]
Out[10]=

SimplexOrientation works with Triangle:

In[11]:=
ResourceFunction["SimplexOrientation"][Triangle[{a, b, c}]]
Out[11]=
In[12]:=
ResourceFunction["SimplexOrientation"][Triangle[{a, c, b}]]
Out[12]=

SimplexOrientation works with Tetrahedron:

In[13]:=
ResourceFunction["SimplexOrientation"][Tetrahedron[{a, b, c, d}]]
Out[13]=
In[14]:=
ResourceFunction["SimplexOrientation"][Tetrahedron[{a, c, b, d}]]
Out[14]=

Visualize orientation using Graphics3D and FaceForm:

In[15]:=
s = Simplex /@ Permutations[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}];
In[16]:=
Labeled[Graphics3D[{FaceForm[Red, Blue], #}, ImageSize -> Tiny], ResourceFunction["SimplexOrientation"][#]] & /@ s
Out[16]=

Simplices can have arbitrary expressions as vertices:

In[17]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/6202f2fd-25b8-4993-9366-139107d2a40c"]
Out[17]=

We can see that the cat-dog-bird simplex has the opposite orientation to the cat-bird-dog simplex:

In[18]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/559ac6a2-e3b3-4206-8b74-89398ad5c4be"]
Out[18]=

Properties and Relations (1) 

Check the output of the three argument form of StandardSimplex:

In[19]:=
Table[orientation === ResourceFunction["SimplexOrientation"][
   ResourceFunction["StandardSimplex"][dim, Automatic, orientation]], {dim, 10}, {orientation, -1, 1, 2}]
Out[19]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 11 March 2019

Related Resources

License Information