Discrete Lines¶
Billiard words
EXAMPLES:
sage: from slabbe import BilliardCube
sage: b = BilliardCube((1,pi,sqrt(2)))
sage: b
Cubic billiard of direction (1, pi, sqrt(2))
TODO:
Rewrite some parts in cython because it is slow
Should handle any direction
Should use Forest structure for enumeration
Should use +e_i only for children
Fix documentation of class
Fix issue with the assertion error in the step iterator
not robust for non integral start point
- class slabbe.billiard.BilliardCube(v, start=(0, 0, 0))¶
Bases:
slabbe.discrete_subset.Intersection
If \(v=(a,b,c)\) and the starting point is (0,0,0), this is the set of point \(p\) such that:
\[\begin{split}\begin{array}{l} -(b+c)/2 \leq p \cdot (0,c,-b) < (b+c)/2\\ -(a+c)/2 \leq p \cdot (c,0,-a) < (a+c)/2\\ -(a+b)/2 \leq p \cdot (b,-a,0) < (a+b)/2 \end{array}\end{split}\]INPUT:
v
- directive vectorstart
- initial point (default = (0,0,0))
EXAMPLES:
sage: from slabbe import BilliardCube sage: b = BilliardCube((1,pi,sqrt(2))) sage: b Cubic billiard of direction (1, pi, sqrt(2))
sage: b = BilliardCube((1,pi,sqrt(2))) sage: it = iter(b) sage: [next(it) for _ in range(20)] [(0, 0, 0), (0, 1, 0), (0, 1, 1), (0, 2, 1), (1, 2, 1), (1, 3, 1), (1, 3, 2), (1, 4, 2), (1, 5, 2), (2, 5, 2), (2, 6, 2), (2, 6, 3), (2, 7, 3), (2, 8, 3), (2, 8, 4), (3, 8, 4), (3, 9, 4), (3, 10, 4), (3, 10, 5), (3, 11, 5)] :: sage: b = BilliardCube((1,sqrt(2),pi), start=(11,13,14)) sage: b.to_word() word: 3231323313233213323132331233321332313233...
- an_element()¶
Returns an element in self.
EXAMPLES:
sage: from slabbe import BilliardCube sage: b = BilliardCube((1,pi,sqrt(2))) sage: b.an_element() (0, 0, 0)
- children(p)¶
Return the children of a point.
This method overwrites the methods
slabbe.discrete_subset.DiscreteSubset.children()
, because for billiard words, we go only in one direction in each axis.EXAMPLES:
sage: from slabbe import BilliardCube sage: b = BilliardCube((1,pi,sqrt(2))) sage: list(b.children(vector((0,0,0)))) [(0, 1, 0)]
- connected_component_iterator(roots=None)¶
Return an iterator over the connected component of the root.
This method overwrites the methods
slabbe.discrete_subset.DiscreteSubset.connected_component_iterator()
, because for billiard words, we go only in one direction in each axis which allows to use a forest structure for the enumeration.INPUT:
roots
- list of some elements immutable in self
EXAMPLES:
sage: from slabbe import BilliardCube sage: p = BilliardCube([1,pi,sqrt(7)]) sage: root = vector((0,0,0)) sage: root.set_immutable() sage: it = p.connected_component_iterator(roots=[root]) sage: [next(it) for _ in range(5)] [(0, 0, 0), (0, 1, 0), (0, 1, 1), (0, 2, 1), (1, 2, 1)]
sage: p = BilliardCube([1,pi,7.45], start=(10.2,20.4,30.8)) sage: it = p.connected_component_iterator() sage: [next(it) for _ in range(5)] [(10.2000000000000, 20.4000000000000, 30.8000000000000), (10.2000000000000, 20.4000000000000, 31.8000000000000), (10.2000000000000, 21.4000000000000, 31.8000000000000), (10.2000000000000, 21.4000000000000, 32.8000000000000), (10.2000000000000, 21.4000000000000, 33.8000000000000)]
- step_iterator()¶
Return an iterator coding the steps of the discrete line.
EXAMPLES:
sage: from slabbe import BilliardCube sage: b = BilliardCube((1,pi,sqrt(2))) sage: it = b.step_iterator() sage: [next(it) for _ in range(5)] [(0, 1, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 0)]
TESTS:
Fix this:
sage: from slabbe import BilliardCube sage: B = BilliardCube((1.1,2.2,3.3)) sage: B.to_word() Traceback (most recent call last): ... AssertionError: step(=(-1, 0, 1)) is not a canonical basis vector.
- to_word(alphabet=[1, 2, 3])¶
Return the billiard word.
INPUT:
alphabet
- list
EXAMPLES:
sage: from slabbe import BilliardCube sage: b = BilliardCube((1,pi,sqrt(2))) sage: b.to_word() word: 2321232212322312232123221322231223212322...
sage: B = BilliardCube((sqrt(3),sqrt(5),sqrt(7))) sage: B.to_word() word: 3213213231232133213213231232132313231232...