# Substitutions over unit cube faces (Rauzy fractals)#

This module implements the $$E_1^*(\sigma)$$ substitution associated with a one-dimensional substitution $$\sigma$$, that acts on unit faces of dimension $$(d-1)$$ in $$\RR^d$$.

This module defines the following classes and functions:

• Face – a class to model a face

• Patch – a class to model a finite set of faces

• E1Star – a class to model the $$E_1^*(\sigma)$$ application defined by the substitution sigma

The convention for the choice of the unit faces and the definition of $$E_1^*(\sigma)$$ varies from article to article. Here, unit faces are defined by

$\begin{split}\begin{array}{ccc} \,[x, 1]^* & = & \{x + \lambda e_2 + \mu e_3 : \lambda, \mu \in [0,1]\} \\ \,[x, 2]^* & = & \{x + \lambda e_1 + \mu e_3 : \lambda, \mu \in [0,1]\} \\ \,[x, 3]^* & = & \{x + \lambda e_1 + \mu e_2 : \lambda, \mu \in [0,1]\} \end{array}\end{split}$

and the dual substitution $$E_1^*(\sigma)$$ is defined by

$E_1^*(\sigma)([x,i]^*) = \bigcup_{k = 1,2,3} \; \bigcup_{s | \sigma(k) = pis} [M^{-1}(x + \ell(s)), k]^*,$

where $$\ell(s)$$ is the abelianized of $$s$$, and $$M$$ is the matrix of $$\sigma$$.

AUTHORS:

• Franco Saliola (2009): initial version

• Vincent Delecroix, Timo Jolivet, Stepan Starosta, Sebastien Labbe (2010-05): redesign

• Timo Jolivet (2010-08, 2010-09, 2011): redesign

REFERENCES:

[AI]

P. Arnoux, S. Ito, Pisot substitutions and Rauzy fractals, Bull. Belg. Math. Soc. 8 (2), 2001, pp. 181–207

[SAI]

Y. Sano, P. Arnoux, S. Ito, Higher dimensional extensions of substitutions and their dual maps, J. Anal. Math. 83, 2001, pp. 183–206

EXAMPLES:

We start by drawing a simple three-face patch:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: x = [Face((0,0,0),1), Face((0,0,0),2), Face((0,0,0),3)]
sage: P = Patch(x)
sage: P
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*]
sage: P.plot()                   #not tested

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> x = [Face((Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(0),Integer(0),Integer(0)),Integer(2)), Face((Integer(0),Integer(0),Integer(0)),Integer(3))]
>>> P = Patch(x)
>>> P
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*]
>>> P.plot()                   #not tested


We apply a substitution to this patch, and draw the result:

sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 1, -1), 2]*, [(1, 0, -1), 1]*]
sage: E(P).plot()                #not tested

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 1, -1), 2]*, [(1, 0, -1), 1]*]
>>> E(P).plot()                #not tested


Note

• The type of a face is given by an integer in [1, ..., d] where d is the length of the vector of the face.

• The alphabet of the domain and the codomain of $$\sigma$$ must be equal, and they must be of the form [1, ..., d], where d is a positive integer corresponding to the length of the vectors of the faces on which $$E_1^*(\sigma)$$ will act.

sage: P = Patch([Face((0,0,0),1), Face((0,0,0),2), Face((0,0,0),3)])
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 1, -1), 2]*, [(1, 0, -1), 1]*]

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(0),Integer(0),Integer(0)),Integer(2)), Face((Integer(0),Integer(0),Integer(0)),Integer(3))])
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 1, -1), 2]*, [(1, 0, -1), 1]*]


The application of an E1Star substitution assigns to each new face the color of its preimage. The repaint method allows us to repaint the faces of a patch. A single color can also be assigned to every face, by specifying a list of a single color:

sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P = E(P, 5)
sage: P.repaint(['green'])
sage: P.plot()                   #not tested

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P = E(P, Integer(5))
>>> P.repaint(['green'])
>>> P.plot()                   #not tested


A list of colors allows us to color the faces sequentially:

sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P = E(P)
sage: P.repaint(['red', 'yellow', 'green', 'blue', 'black'])
sage: P = E(P, 3)
sage: P.plot()                   #not tested

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P = E(P)
>>> P.repaint(['red', 'yellow', 'green', 'blue', 'black'])
>>> P = E(P, Integer(3))
>>> P.plot()                   #not tested


All the color schemes from list(matplotlib.cm.datad) can be used:

sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P.repaint(cmap='summer')
sage: P = E(P, 3)
sage: P.plot()                   #not tested
sage: P.repaint(cmap='hsv')
sage: P = E(P, 2)
sage: P.plot()                   #not tested

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.repaint(cmap='summer')
>>> P = E(P, Integer(3))
>>> P.plot()                   #not tested
>>> P.repaint(cmap='hsv')
>>> P = E(P, Integer(2))
>>> P.plot()                   #not tested


It is also possible to specify a dictionary to color the faces according to their type:

sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P = E(P, 5)
sage: P.repaint({1:(0.7, 0.7, 0.7), 2:(0.5,0.5,0.5), 3:(0.3,0.3,0.3)})
sage: P.plot()                   #not tested
sage: P.repaint({1:'red', 2:'yellow', 3:'green'})
sage: P.plot()                   #not tested

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P = E(P, Integer(5))
>>> P.repaint({Integer(1):(RealNumber('0.7'), RealNumber('0.7'), RealNumber('0.7')), Integer(2):(RealNumber('0.5'),RealNumber('0.5'),RealNumber('0.5')), Integer(3):(RealNumber('0.3'),RealNumber('0.3'),RealNumber('0.3'))})
>>> P.plot()                   #not tested
>>> P.repaint({Integer(1):'red', Integer(2):'yellow', Integer(3):'green'})
>>> P.plot()                   #not tested


Let us look at a nice big patch in 3D:

sage: sigma = WordMorphism({1:[1,2], 2:[3], 3:[1]})
sage: E = E1Star(sigma)
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P = P + P.translate([-1,1,0])
sage: P = E(P, 11)
sage: P.plot3d()                 #not tested

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P = P + P.translate([-Integer(1),Integer(1),Integer(0)])
>>> P = E(P, Integer(11))
>>> P.plot3d()                 #not tested


Plotting with TikZ pictures is possible:

sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: s = P.plot_tikz()
sage: print(s)                    #not tested
\begin{tikzpicture}
[x={(-0.216506cm,-0.125000cm)}, y={(0.216506cm,-0.125000cm)}, z={(0.000000cm,0.250000cm)}]
\definecolor{facecolor}{rgb}{0.000,1.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 0, 1) -- (1, 0, 1) -- (1, 0, 0) -- cycle;
\definecolor{facecolor}{rgb}{1.000,0.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 1, 0) -- (0, 1, 1) -- (0, 0, 1) -- cycle;
\definecolor{facecolor}{rgb}{0.000,0.000,1.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (1, 0, 0) -- (1, 1, 0) -- (0, 1, 0) -- cycle;
\end{tikzpicture}

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> s = P.plot_tikz()
>>> print(s)                    #not tested
\begin{tikzpicture}
[x={(-0.216506cm,-0.125000cm)}, y={(0.216506cm,-0.125000cm)}, z={(0.000000cm,0.250000cm)}]
\definecolor{facecolor}{rgb}{0.000,1.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 0, 1) -- (1, 0, 1) -- (1, 0, 0) -- cycle;
\definecolor{facecolor}{rgb}{1.000,0.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 1, 0) -- (0, 1, 1) -- (0, 0, 1) -- cycle;
\definecolor{facecolor}{rgb}{0.000,0.000,1.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (1, 0, 0) -- (1, 1, 0) -- (0, 1, 0) -- cycle;
\end{tikzpicture}


sage: P = Patch([Face([0,0], 1), Face([0,0], 2)])
sage: E = E1Star(WordMorphism({1:[1,2],2:[1]}))
sage: F = E1Star(WordMorphism({1:[1,1,2],2:[2,1]}))
sage: E(P,5).plot()                                                                 # needs sage.plot
Graphics object consisting of 21 graphics primitives
sage: F(P,3).plot()                                                                 # needs sage.plot
Graphics object consisting of 34 graphics primitives

>>> from sage.all import *
>>> P = Patch([Face([Integer(0),Integer(0)], Integer(1)), Face([Integer(0),Integer(0)], Integer(2))])
>>> E = E1Star(WordMorphism({Integer(1):[Integer(1),Integer(2)],Integer(2):[Integer(1)]}))
>>> F = E1Star(WordMorphism({Integer(1):[Integer(1),Integer(1),Integer(2)],Integer(2):[Integer(2),Integer(1)]}))
>>> E(P,Integer(5)).plot()                                                                 # needs sage.plot
Graphics object consisting of 21 graphics primitives
>>> F(P,Integer(3)).plot()                                                                 # needs sage.plot
Graphics object consisting of 34 graphics primitives


Everything works in any dimension (except for the plotting features which only work in dimension two or three):

sage: P = Patch([Face((0,0,0,0),1), Face((0,0,0,0),4)])
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1,4], 4:[1]})
sage: E = E1Star(sigma)
sage: E(P)
Patch: [[(0, 0, 0, 0), 3]*, [(0, 0, 0, 0), 4]*, [(0, 0, 1, -1), 3]*, [(0, 1, 0, -1), 2]*, [(1, 0, 0, -1), 1]*]

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(0),Integer(0),Integer(0),Integer(0)),Integer(4))])
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1),Integer(4)], Integer(4):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E(P)
Patch: [[(0, 0, 0, 0), 3]*, [(0, 0, 0, 0), 4]*, [(0, 0, 1, -1), 3]*, [(0, 1, 0, -1), 2]*, [(1, 0, 0, -1), 1]*]

sage: sigma = WordMorphism({1:[1,2],2:[1,3],3:[1,4],4:[1,5],5:[1,6],6:[1,7],7:[1,8],8:[1,9],9:[1,10],10:[1,11],11:[1,12],12:[1]})
sage: E = E1Star(sigma)
sage: E
E_1^*(1->12, 10->1,11, 11->1,12, 12->1, 2->13, 3->14, 4->15, 5->16, 6->17, 7->18, 8->19, 9->1,10)
sage: P = Patch([Face((0,0,0,0,0,0,0,0,0,0,0,0),t) for t in [1,2,3]])
sage: for x in sorted(E(P), key=lambda x : (x.vector(),x.type())): print(x)
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 2]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 12]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1), 11]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1), 10]*
[(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1), 9]*
[(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1), 8]*
[(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1), 7]*
[(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1), 6]*
[(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1), 5]*
[(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1), 4]*
[(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1), 3]*
[(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1), 2]*
[(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1), 1]*

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)],Integer(2):[Integer(1),Integer(3)],Integer(3):[Integer(1),Integer(4)],Integer(4):[Integer(1),Integer(5)],Integer(5):[Integer(1),Integer(6)],Integer(6):[Integer(1),Integer(7)],Integer(7):[Integer(1),Integer(8)],Integer(8):[Integer(1),Integer(9)],Integer(9):[Integer(1),Integer(10)],Integer(10):[Integer(1),Integer(11)],Integer(11):[Integer(1),Integer(12)],Integer(12):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E
E_1^*(1->12, 10->1,11, 11->1,12, 12->1, 2->13, 3->14, 4->15, 5->16, 6->17, 7->18, 8->19, 9->1,10)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0),Integer(0),Integer(0),Integer(0),Integer(0),Integer(0),Integer(0),Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> for x in sorted(E(P), key=lambda x : (x.vector(),x.type())): print(x)
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 2]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 12]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1), 11]*
[(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1), 10]*
[(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1), 9]*
[(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1), 8]*
[(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1), 7]*
[(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1), 6]*
[(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1), 5]*
[(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1), 4]*
[(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1), 3]*
[(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1), 2]*
[(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1), 1]*

class sage.combinat.e_one_star.E1Star(sigma, method='suffix')[source]#

Bases: SageObject

A class to model the $$E_1^*(\sigma)$$ map associated with a unimodular substitution $$\sigma$$.

INPUT:

• sigma – unimodular WordMorphism, i.e. such that its incidence matrix has determinant $$\pm 1$$.

• method – ‘prefix’ or ‘suffix’ (default: ‘suffix’) Enables to use an alternative definition $$E_1^*(\sigma)$$ substitutions, where the abelianized of the prefix is used instead of the suffix.

Note

The alphabet of the domain and the codomain of $$\sigma$$ must be equal, and they must be of the form [1, ..., d], where d is a positive integer corresponding to the length of the vectors of the faces on which $$E_1^*(\sigma)$$ will act.

EXAMPLES:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 1, -1), 2]*, [(1, 0, -1), 1]*]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 1, -1), 2]*, [(1, 0, -1), 1]*]

sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma, method='prefix')
sage: E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 0, 1), 1]*, [(0, 0, 1), 2]*]

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma, method='prefix')
>>> E(P)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*, [(0, 0, 1), 1]*, [(0, 0, 1), 2]*]

sage: x = [Face((0,0,0,0),1), Face((0,0,0,0),4)]
sage: P = Patch(x)
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1,4], 4:[1]})
sage: E = E1Star(sigma)
sage: E(P)
Patch: [[(0, 0, 0, 0), 3]*, [(0, 0, 0, 0), 4]*, [(0, 0, 1, -1), 3]*, [(0, 1, 0, -1), 2]*, [(1, 0, 0, -1), 1]*]

>>> from sage.all import *
>>> x = [Face((Integer(0),Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(0),Integer(0),Integer(0),Integer(0)),Integer(4))]
>>> P = Patch(x)
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1),Integer(4)], Integer(4):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E(P)
Patch: [[(0, 0, 0, 0), 3]*, [(0, 0, 0, 0), 4]*, [(0, 0, 1, -1), 3]*, [(0, 1, 0, -1), 2]*, [(1, 0, 0, -1), 1]*]

inverse_matrix()[source]#

Return the inverse of the matrix associated with self.

EXAMPLES:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: E.inverse_matrix()
[ 0  1  0]
[ 0  0  1]
[ 1 -1 -1]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E.inverse_matrix()
[ 0  1  0]
[ 0  0  1]
[ 1 -1 -1]

matrix()[source]#

Return the matrix associated with self.

EXAMPLES:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: E.matrix()
[1 1 1]
[1 0 0]
[0 1 0]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E.matrix()
[1 1 1]
[1 0 0]
[0 1 0]

sigma()[source]#

Return the WordMorphism associated with self.

EXAMPLES:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: E.sigma()
WordMorphism: 1->12, 2->13, 3->1

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> E.sigma()
WordMorphism: 1->12, 2->13, 3->1

class sage.combinat.e_one_star.Face(v, t, color=None)[source]#

Bases: SageObject

A class to model a unit face of arbitrary dimension.

A unit face in dimension $$d$$ is represented by a $$d$$-dimensional vector v and a type t in $$\{1, \ldots, d\}$$. The type of the face corresponds to the canonical unit vector to which the face is orthogonal. The optional color argument is used in plotting functions.

INPUT:

• v – tuple of integers

• t – integer in [1, ..., len(v)], type of the face. The face of type $$i$$ is orthogonal to the canonical vector $$e_i$$.

• color – color (default: None) color of the face, used for plotting only. If None, its value is guessed from the face type.

EXAMPLES:

sage: from sage.combinat.e_one_star import Face
sage: f = Face((0,2,0), 3)
sage: f.vector()
(0, 2, 0)
sage: f.type()
3

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face
>>> f = Face((Integer(0),Integer(2),Integer(0)), Integer(3))
>>> f.vector()
(0, 2, 0)
>>> f.type()
3

sage: f = Face((0,2,0), 3, color=(0.5, 0.5, 0.5))
sage: f.color()
RGB color (0.5, 0.5, 0.5)

>>> from sage.all import *
>>> f = Face((Integer(0),Integer(2),Integer(0)), Integer(3), color=(RealNumber('0.5'), RealNumber('0.5'), RealNumber('0.5')))
>>> f.color()
RGB color (0.5, 0.5, 0.5)

color(color=None)[source]#

Return or change the color of the face.

INPUT:

• color – string, rgb tuple, color (default: None) the new color to assign to the face. If None, it returns the color of the face.

OUTPUT:

color or None

EXAMPLES:

sage: from sage.combinat.e_one_star import Face
sage: f = Face((0,2,0), 3)
sage: f.color()
RGB color (0.0, 0.0, 1.0)
sage: f.color('red')
sage: f.color()
RGB color (1.0, 0.0, 0.0)

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face
>>> f = Face((Integer(0),Integer(2),Integer(0)), Integer(3))
>>> f.color()
RGB color (0.0, 0.0, 1.0)
>>> f.color('red')
>>> f.color()
RGB color (1.0, 0.0, 0.0)

type()[source]#

Return the type of the face.

EXAMPLES:

sage: from sage.combinat.e_one_star import Face
sage: f = Face((0,2,0), 3)
sage: f.type()
3

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face
>>> f = Face((Integer(0),Integer(2),Integer(0)), Integer(3))
>>> f.type()
3

sage: f = Face((0,2,0), 3)
sage: f.type()
3

>>> from sage.all import *
>>> f = Face((Integer(0),Integer(2),Integer(0)), Integer(3))
>>> f.type()
3

vector()[source]#

Return the vector of the face.

EXAMPLES:

sage: from sage.combinat.e_one_star import Face
sage: f = Face((0,2,0), 3)
sage: f.vector()
(0, 2, 0)

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face
>>> f = Face((Integer(0),Integer(2),Integer(0)), Integer(3))
>>> f.vector()
(0, 2, 0)

class sage.combinat.e_one_star.Patch(faces, face_contour=None)[source]#

Bases: SageObject

A class to model a collection of faces. A patch is represented by an immutable set of Faces.

Note

The dimension of a patch is the length of the vectors of the faces in the patch, which is assumed to be the same for every face in the patch.

Note

Since version 4.7.1, Patches are immutable, except for the colors of the faces, which are not taken into account for equality tests and hash functions.

INPUT:

• faces – finite iterable of faces

• face_contour – dict (default:None) maps the face type to vectors describing the contour of unit faces. If None, defaults contour are assumed for faces of type 1, 2, 3 or 1, 2, 3. Used in plotting methods only.

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*]

sage: face_contour = {}
sage: face_contour[1] = map(vector, [(0,0,0),(0,1,0),(0,1,1),(0,0,1)])
sage: face_contour[2] = map(vector, [(0,0,0),(0,0,1),(1,0,1),(1,0,0)])
sage: face_contour[3] = map(vector, [(0,0,0),(1,0,0),(1,1,0),(0,1,0)])
sage: Patch([Face((0,0,0),t) for t in [1,2,3]], face_contour=face_contour)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*]

>>> from sage.all import *
>>> face_contour = {}
>>> face_contour[Integer(1)] = map(vector, [(Integer(0),Integer(0),Integer(0)),(Integer(0),Integer(1),Integer(0)),(Integer(0),Integer(1),Integer(1)),(Integer(0),Integer(0),Integer(1))])
>>> face_contour[Integer(2)] = map(vector, [(Integer(0),Integer(0),Integer(0)),(Integer(0),Integer(0),Integer(1)),(Integer(1),Integer(0),Integer(1)),(Integer(1),Integer(0),Integer(0))])
>>> face_contour[Integer(3)] = map(vector, [(Integer(0),Integer(0),Integer(0)),(Integer(1),Integer(0),Integer(0)),(Integer(1),Integer(1),Integer(0)),(Integer(0),Integer(1),Integer(0))])
>>> Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]], face_contour=face_contour)
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(0, 0, 0), 3]*]

difference(other)[source]#

Return the difference of self and other.

INPUT:

• other – a finite iterable of faces or a single face

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P.difference(Face([0,0,0],2))
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 3]*]
sage: P.difference(P)
Patch: []

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.difference(Face([Integer(0),Integer(0),Integer(0)],Integer(2)))
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 3]*]
>>> P.difference(P)
Patch: []

dimension()[source]#

Return the dimension of the vectors of the faces of self

It returns None if self is the empty patch.

The dimension of a patch is the length of the vectors of the faces in the patch, which is assumed to be the same for every face in the patch.

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P.dimension()
3

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.dimension()
3

faces_of_color(color)[source]#

Return a list of the faces that have the given color.

INPUT:

• color – color

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),1, 'red'), Face((1,2,0),3, 'blue'), Face((1,2,0),1, 'red')])
sage: sorted(P.faces_of_color('red'))
[[(0, 0, 0), 1]*, [(1, 2, 0), 1]*]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),Integer(1), 'red'), Face((Integer(1),Integer(2),Integer(0)),Integer(3), 'blue'), Face((Integer(1),Integer(2),Integer(0)),Integer(1), 'red')])
>>> sorted(P.faces_of_color('red'))
[[(0, 0, 0), 1]*, [(1, 2, 0), 1]*]

faces_of_type(t)[source]#

Return a list of the faces that have type t.

INPUT:

• t – integer or any other type

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),1), Face((1,2,0),3), Face((1,2,0),1)])
sage: sorted(P.faces_of_type(1))
[[(0, 0, 0), 1]*, [(1, 2, 0), 1]*]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(1),Integer(2),Integer(0)),Integer(3)), Face((Integer(1),Integer(2),Integer(0)),Integer(1))])
>>> sorted(P.faces_of_type(Integer(1)))
[[(0, 0, 0), 1]*, [(1, 2, 0), 1]*]

faces_of_vector(v)[source]#

Return a list of the faces whose vector is v.

INPUT:

• v – a vector

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),1), Face((1,2,0),3), Face((1,2,0),1)])
sage: sorted(P.faces_of_vector([1,2,0]))
[[(1, 2, 0), 1]*, [(1, 2, 0), 3]*]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(1),Integer(2),Integer(0)),Integer(3)), Face((Integer(1),Integer(2),Integer(0)),Integer(1))])
>>> sorted(P.faces_of_vector([Integer(1),Integer(2),Integer(0)]))
[[(1, 2, 0), 1]*, [(1, 2, 0), 3]*]

occurrences_of(other)[source]#

Return all positions at which other appears in self, that is, all vectors v such that set(other.translate(v)) <= set(self).

INPUT:

• other – a Patch

OUTPUT:

a list of vectors

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch, E1Star
sage: P = Patch([Face([0,0,0], 1), Face([0,0,0], 2), Face([0,0,0], 3)])
sage: Q = Patch([Face([0,0,0], 1), Face([0,0,0], 2)])
sage: P.occurrences_of(Q)
[(0, 0, 0)]
sage: Q = Q.translate([1,2,3])
sage: P.occurrences_of(Q)
[(-1, -2, -3)]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch, E1Star
>>> P = Patch([Face([Integer(0),Integer(0),Integer(0)], Integer(1)), Face([Integer(0),Integer(0),Integer(0)], Integer(2)), Face([Integer(0),Integer(0),Integer(0)], Integer(3))])
>>> Q = Patch([Face([Integer(0),Integer(0),Integer(0)], Integer(1)), Face([Integer(0),Integer(0),Integer(0)], Integer(2))])
>>> P.occurrences_of(Q)
[(0, 0, 0)]
>>> Q = Q.translate([Integer(1),Integer(2),Integer(3)])
>>> P.occurrences_of(Q)
[(-1, -2, -3)]

sage: E = E1Star(WordMorphism({1:[1,2], 2:[1,3], 3:[1]}))
sage: P = Patch([Face([0,0,0], 1), Face([0,0,0], 2), Face([0,0,0], 3)])
sage: P = E(P,4)
sage: Q = Patch([Face([0,0,0], 1), Face([0,0,0], 2)])
sage: L = P.occurrences_of(Q)
sage: sorted(L)
[(0, 0, 0), (0, 0, 1), (0, 1, -1), (1, 0, -1), (1, 1, -3), (1, 1, -2)]

>>> from sage.all import *
>>> E = E1Star(WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]}))
>>> P = Patch([Face([Integer(0),Integer(0),Integer(0)], Integer(1)), Face([Integer(0),Integer(0),Integer(0)], Integer(2)), Face([Integer(0),Integer(0),Integer(0)], Integer(3))])
>>> P = E(P,Integer(4))
>>> Q = Patch([Face([Integer(0),Integer(0),Integer(0)], Integer(1)), Face([Integer(0),Integer(0),Integer(0)], Integer(2))])
>>> L = P.occurrences_of(Q)
>>> sorted(L)
[(0, 0, 0), (0, 0, 1), (0, 1, -1), (1, 0, -1), (1, 1, -3), (1, 1, -2)]

plot(projmat=None, opacity=0.75)[source]#

Return a 2D graphic object depicting the patch.

INPUT:

• projmat – matrix (default: None) the projection matrix. Its number of lines must be two. Its number of columns must equal the dimension of the ambient space of the faces. If None, the isometric projection is used by default.

• opacity – float between 0 and 1 (default: 0.75) opacity of the face

Warning

Plotting is implemented only for patches in two or three dimensions.

EXAMPLES:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P.plot()                                                              # needs sage.plot
Graphics object consisting of 3 graphics primitives

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.plot()                                                              # needs sage.plot
Graphics object consisting of 3 graphics primitives

sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P = E(P, 5)
sage: P.plot()                                                              # needs sage.plot
Graphics object consisting of 57 graphics primitives

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P = E(P, Integer(5))
>>> P.plot()                                                              # needs sage.plot
Graphics object consisting of 57 graphics primitives


Plot with a different projection matrix:

sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: M = matrix(2, 3, [1,0,-1,0.3,1,-3])
sage: P = E(P, 3)
sage: P.plot(projmat=M)                                                     # needs sage.plot
Graphics object consisting of 17 graphics primitives

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> M = matrix(Integer(2), Integer(3), [Integer(1),Integer(0),-Integer(1),RealNumber('0.3'),Integer(1),-Integer(3)])
>>> P = E(P, Integer(3))
>>> P.plot(projmat=M)                                                     # needs sage.plot
Graphics object consisting of 17 graphics primitives


Plot patches made of unit segments:

sage: P = Patch([Face([0,0], 1), Face([0,0], 2)])
sage: E = E1Star(WordMorphism({1:[1,2],2:[1]}))
sage: F = E1Star(WordMorphism({1:[1,1,2],2:[2,1]}))
sage: E(P,5).plot()                                                         # needs sage.plot
Graphics object consisting of 21 graphics primitives
sage: F(P,3).plot()                                                         # needs sage.plot
Graphics object consisting of 34 graphics primitives

>>> from sage.all import *
>>> P = Patch([Face([Integer(0),Integer(0)], Integer(1)), Face([Integer(0),Integer(0)], Integer(2))])
>>> E = E1Star(WordMorphism({Integer(1):[Integer(1),Integer(2)],Integer(2):[Integer(1)]}))
>>> F = E1Star(WordMorphism({Integer(1):[Integer(1),Integer(1),Integer(2)],Integer(2):[Integer(2),Integer(1)]}))
>>> E(P,Integer(5)).plot()                                                         # needs sage.plot
Graphics object consisting of 21 graphics primitives
>>> F(P,Integer(3)).plot()                                                         # needs sage.plot
Graphics object consisting of 34 graphics primitives

plot3d()[source]#

Return a 3D graphics object depicting the patch.

Warning

3D plotting is implemented only for patches in three dimensions.

EXAMPLES:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P.plot3d()                #not tested

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.plot3d()                #not tested

sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P = E(P, 5)
sage: P.repaint()
sage: P.plot3d()                #not tested

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P = E(P, Integer(5))
>>> P.repaint()
>>> P.plot3d()                #not tested

plot_tikz(projmat=None, print_tikz_env=True, edgecolor='black', scale=0.25, drawzero=False, extra_code_before='', extra_code_after='')[source]#

Return a string containing some TikZ code to be included into a LaTeX document, depicting the patch.

Warning

Tikz Plotting is implemented only for patches in three dimensions.

INPUT:

• projmat – matrix (default: None) the projection matrix. Its number of lines must be two. Its number of columns must equal the dimension of the ambient space of the faces. If None, the isometric projection is used by default.

• print_tikz_env – bool (default: True) if True, the tikzpicture environment are printed

• edgecolor – string (default: 'black') either 'black' or 'facecolor' (color of unit face edges)

• scale – real number (default: 0.25) scaling constant for the whole figure

• drawzero – bool (default: False) if True, mark the origin by a black dot

• extra_code_before – string (default: '') extra code to include in the tikz picture

• extra_code_after – string (default: '') extra code to include in the tikz picture

EXAMPLES:

sage: from sage.combinat.e_one_star import E1Star, Face, Patch
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: s = P.plot_tikz()
sage: len(s)
602
sage: print(s)       #not tested
\begin{tikzpicture}
[x={(-0.216506cm,-0.125000cm)}, y={(0.216506cm,-0.125000cm)}, z={(0.000000cm,0.250000cm)}]
\definecolor{facecolor}{rgb}{0.000,1.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 0, 1) -- (1, 0, 1) -- (1, 0, 0) -- cycle;
\definecolor{facecolor}{rgb}{1.000,0.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 1, 0) -- (0, 1, 1) -- (0, 0, 1) -- cycle;
\definecolor{facecolor}{rgb}{0.000,0.000,1.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (1, 0, 0) -- (1, 1, 0) -- (0, 1, 0) -- cycle;
\end{tikzpicture}

>>> from sage.all import *
>>> from sage.combinat.e_one_star import E1Star, Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> s = P.plot_tikz()
>>> len(s)
602
>>> print(s)       #not tested
\begin{tikzpicture}
[x={(-0.216506cm,-0.125000cm)}, y={(0.216506cm,-0.125000cm)}, z={(0.000000cm,0.250000cm)}]
\definecolor{facecolor}{rgb}{0.000,1.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 0, 1) -- (1, 0, 1) -- (1, 0, 0) -- cycle;
\definecolor{facecolor}{rgb}{1.000,0.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 1, 0) -- (0, 1, 1) -- (0, 0, 1) -- cycle;
\definecolor{facecolor}{rgb}{0.000,0.000,1.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (1, 0, 0) -- (1, 1, 0) -- (0, 1, 0) -- cycle;
\end{tikzpicture}

sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P = E(P, 4)
sage: from sage.misc.latex import latex             #not tested
sage: view(P)                       #not tested

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P = E(P, Integer(4))
>>> from sage.misc.latex import latex             #not tested
>>> view(P)                       #not tested


Plot using shades of gray (useful for article figures):

sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P.repaint([(0.9, 0.9, 0.9), (0.65,0.65,0.65), (0.4,0.4,0.4)])
sage: P = E(P, 4)
sage: s = P.plot_tikz()

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.repaint([(RealNumber('0.9'), RealNumber('0.9'), RealNumber('0.9')), (RealNumber('0.65'),RealNumber('0.65'),RealNumber('0.65')), (RealNumber('0.4'),RealNumber('0.4'),RealNumber('0.4'))])
>>> P = E(P, Integer(4))
>>> s = P.plot_tikz()


Plotting with various options:

sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
sage: E = E1Star(sigma)
sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: M = matrix(2,3,[float(u) for u in [1,0,-0.7071,0,1,-0.7071]])
sage: P = E(P, 3)
sage: s = P.plot_tikz(projmat=M, edgecolor='facecolor', scale=0.6, drawzero=True)

>>> from sage.all import *
>>> sigma = WordMorphism({Integer(1):[Integer(1),Integer(2)], Integer(2):[Integer(1),Integer(3)], Integer(3):[Integer(1)]})
>>> E = E1Star(sigma)
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> M = matrix(Integer(2),Integer(3),[float(u) for u in [Integer(1),Integer(0),-RealNumber('0.7071'),Integer(0),Integer(1),-RealNumber('0.7071')]])
>>> P = E(P, Integer(3))
>>> s = P.plot_tikz(projmat=M, edgecolor='facecolor', scale=RealNumber('0.6'), drawzero=True)


Adding X, Y, Z axes using the extra code feature:

sage: length = 1.5
sage: space = 0.3
sage: axes = ''
sage: axes += "\\draw[->, thick, black] (0,0,0) -- (%s, 0, 0);\n" % length
sage: axes += "\\draw[->, thick, black] (0,0,0) -- (0, %s, 0);\n" % length
sage: axes += "\\node at (%s,0,0) {$x$};\n" % (length + space)
sage: axes += "\\node at (0,%s,0) {$y$};\n" % (length + space)
sage: axes += "\\node at (0,0,%s) {$z$};\n" % (length + space)
sage: axes += "\\draw[->, thick, black] (0,0,0) -- (0, 0, %s);\n" % length
sage: cube = Patch([Face((0,0,0),1), Face((0,0,0),2), Face((0,0,0),3)])
sage: options = dict(scale=0.5,drawzero=True,extra_code_before=axes)
sage: s = cube.plot_tikz(**options)
sage: len(s)
986
sage: print(s)   #not tested
\begin{tikzpicture}
[x={(-0.433013cm,-0.250000cm)}, y={(0.433013cm,-0.250000cm)}, z={(0.000000cm,0.500000cm)}]
\draw[->, thick, black] (0,0,0) -- (1.50000000000000, 0, 0);
\draw[->, thick, black] (0,0,0) -- (0, 1.50000000000000, 0);
\node at (1.80000000000000,0,0) {$x$};
\node at (0,1.80000000000000,0) {$y$};
\node at (0,0,1.80000000000000) {$z$};
\draw[->, thick, black] (0,0,0) -- (0, 0, 1.50000000000000);
\definecolor{facecolor}{rgb}{0.000,1.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 0, 1) -- (1, 0, 1) -- (1, 0, 0) -- cycle;
\definecolor{facecolor}{rgb}{1.000,0.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 1, 0) -- (0, 1, 1) -- (0, 0, 1) -- cycle;
\definecolor{facecolor}{rgb}{0.000,0.000,1.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (1, 0, 0) -- (1, 1, 0) -- (0, 1, 0) -- cycle;
\node[circle,fill=black,draw=black,minimum size=1.5mm,inner sep=0pt] at (0,0,0) {};
\end{tikzpicture}

>>> from sage.all import *
>>> length = RealNumber('1.5')
>>> space = RealNumber('0.3')
>>> axes = ''
>>> axes += "\\draw[->, thick, black] (0,0,0) -- (%s, 0, 0);\n" % length
>>> axes += "\\draw[->, thick, black] (0,0,0) -- (0, %s, 0);\n" % length
>>> axes += "\\node at (%s,0,0) {$x$};\n" % (length + space)
>>> axes += "\\node at (0,%s,0) {$y$};\n" % (length + space)
>>> axes += "\\node at (0,0,%s) {$z$};\n" % (length + space)
>>> axes += "\\draw[->, thick, black] (0,0,0) -- (0, 0, %s);\n" % length
>>> cube = Patch([Face((Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(0),Integer(0),Integer(0)),Integer(2)), Face((Integer(0),Integer(0),Integer(0)),Integer(3))])
>>> options = dict(scale=RealNumber('0.5'),drawzero=True,extra_code_before=axes)
>>> s = cube.plot_tikz(**options)
>>> len(s)
986
>>> print(s)   #not tested
\begin{tikzpicture}
[x={(-0.433013cm,-0.250000cm)}, y={(0.433013cm,-0.250000cm)}, z={(0.000000cm,0.500000cm)}]
\draw[->, thick, black] (0,0,0) -- (1.50000000000000, 0, 0);
\draw[->, thick, black] (0,0,0) -- (0, 1.50000000000000, 0);
\node at (1.80000000000000,0,0) {$x$};
\node at (0,1.80000000000000,0) {$y$};
\node at (0,0,1.80000000000000) {$z$};
\draw[->, thick, black] (0,0,0) -- (0, 0, 1.50000000000000);
\definecolor{facecolor}{rgb}{0.000,1.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 0, 1) -- (1, 0, 1) -- (1, 0, 0) -- cycle;
\definecolor{facecolor}{rgb}{1.000,0.000,0.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (0, 1, 0) -- (0, 1, 1) -- (0, 0, 1) -- cycle;
\definecolor{facecolor}{rgb}{0.000,0.000,1.000}
\fill[fill=facecolor, draw=black, shift={(0,0,0)}]
(0, 0, 0) -- (1, 0, 0) -- (1, 1, 0) -- (0, 1, 0) -- cycle;
\node[circle,fill=black,draw=black,minimum size=1.5mm,inner sep=0pt] at (0,0,0) {};
\end{tikzpicture}

repaint(cmap='Set1')[source]#

Repaint all the faces of self from the given color map.

This only changes the colors of the faces of self.

INPUT:

• cmap – color map (default: 'Set1'). It can be one of the following:

• string – A coloring map. For available coloring map names type: sorted(colormaps)

• list – a list of colors to assign cyclically to the faces. A list of a single color colors all the faces with the same color.

• dict – a dict of face types mapped to colors, to color the faces according to their type.

• {}, the empty dict – shortcut for {1:'red', 2:'green', 3:'blue'}.

EXAMPLES:

Using a color map:

sage: from sage.combinat.e_one_star import Face, Patch
sage: color = (0, 0, 0)
sage: P = Patch([Face((0,0,0),t,color) for t in [1,2,3]])
sage: for f in P: f.color()
RGB color (0.0, 0.0, 0.0)
RGB color (0.0, 0.0, 0.0)
RGB color (0.0, 0.0, 0.0)
sage: P.repaint()
sage: next(iter(P)).color()    #random
RGB color (0.498..., 0.432..., 0.522...)

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> color = (Integer(0), Integer(0), Integer(0))
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t,color) for t in [Integer(1),Integer(2),Integer(3)]])
>>> for f in P: f.color()
RGB color (0.0, 0.0, 0.0)
RGB color (0.0, 0.0, 0.0)
RGB color (0.0, 0.0, 0.0)
>>> P.repaint()
>>> next(iter(P)).color()    #random
RGB color (0.498..., 0.432..., 0.522...)


Using a list of colors:

sage: P = Patch([Face((0,0,0),t,color) for t in [1,2,3]])
sage: P.repaint([(0.9, 0.9, 0.9), (0.65,0.65,0.65), (0.4,0.4,0.4)])
sage: for f in P: f.color()
RGB color (0.9, 0.9, 0.9)
RGB color (0.65, 0.65, 0.65)
RGB color (0.4, 0.4, 0.4)

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t,color) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.repaint([(RealNumber('0.9'), RealNumber('0.9'), RealNumber('0.9')), (RealNumber('0.65'),RealNumber('0.65'),RealNumber('0.65')), (RealNumber('0.4'),RealNumber('0.4'),RealNumber('0.4'))])
>>> for f in P: f.color()
RGB color (0.9, 0.9, 0.9)
RGB color (0.65, 0.65, 0.65)
RGB color (0.4, 0.4, 0.4)


Using a dictionary to color faces according to their type:

sage: P = Patch([Face((0,0,0),t) for t in [1,2,3]])
sage: P.repaint({1:'black', 2:'yellow', 3:'green'})
sage: P.plot()                   #not tested
sage: P.repaint({})
sage: P.plot()                   #not tested

>>> from sage.all import *
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),t) for t in [Integer(1),Integer(2),Integer(3)]])
>>> P.repaint({Integer(1):'black', Integer(2):'yellow', Integer(3):'green'})
>>> P.plot()                   #not tested
>>> P.repaint({})
>>> P.plot()                   #not tested

translate(v)[source]#

Return a translated copy of self by vector v.

INPUT:

• v – vector or tuple

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),1), Face((1,2,0),3), Face((1,2,0),1)])
sage: P.translate([-1,-2,0])
Patch: [[(-1, -2, 0), 1]*, [(0, 0, 0), 1]*, [(0, 0, 0), 3]*]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(1),Integer(2),Integer(0)),Integer(3)), Face((Integer(1),Integer(2),Integer(0)),Integer(1))])
>>> P.translate([-Integer(1),-Integer(2),Integer(0)])
Patch: [[(-1, -2, 0), 1]*, [(0, 0, 0), 1]*, [(0, 0, 0), 3]*]

union(other)[source]#

Return a Patch consisting of the union of self and other.

INPUT:

• other – a Patch or a Face or a finite iterable of faces

EXAMPLES:

sage: from sage.combinat.e_one_star import Face, Patch
sage: P = Patch([Face((0,0,0),1), Face((0,0,0),2)])
sage: P.union(Face((1,2,3), 3))
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(1, 2, 3), 3]*]
sage: P.union([Face((1,2,3), 3), Face((2,3,3), 2)])
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(1, 2, 3), 3]*, [(2, 3, 3), 2]*]

>>> from sage.all import *
>>> from sage.combinat.e_one_star import Face, Patch
>>> P = Patch([Face((Integer(0),Integer(0),Integer(0)),Integer(1)), Face((Integer(0),Integer(0),Integer(0)),Integer(2))])
>>> P.union(Face((Integer(1),Integer(2),Integer(3)), Integer(3)))
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(1, 2, 3), 3]*]
>>> P.union([Face((Integer(1),Integer(2),Integer(3)), Integer(3)), Face((Integer(2),Integer(3),Integer(3)), Integer(2))])
Patch: [[(0, 0, 0), 1]*, [(0, 0, 0), 2]*, [(1, 2, 3), 3]*, [(2, 3, 3), 2]*]
`