Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Added tips and some more methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jplab committed Mar 20, 2017
1 parent 81d71bc commit a1ad1af
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/doc/en/thematic_tutorials/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ So far, the tutorials cover mostly things related to polyhedral computations.
geometry/new_from_old
geometry/related_objects
geometry/is_this_polyhedron
geometry/tips
geometry/visualization
geometry/polytope_tikz
68 changes: 68 additions & 0 deletions src/doc/en/thematic_tutorials/geometry/related_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,44 @@ several methods:
... geometric objects and properties
==============================================================

Base ring
--------------------------------------------------------------

The first important object related to a polyhedron is its base ring.

::

sage: P1.base_ring()
Integer Ring

.. end of output
Bounded edges
--------------------------------------------------------------

The bounded edges are edges between two vertices of the polyhedron. This
function returns an iterator.

::

sage: list(P1.bounded_edges())
[(A vertex at (0, 1), A vertex at (1, 0))]

.. end of output
Bounding box
--------------------------------------------------------------

The bounding box returns the two corners (the ones with minimal and maximal
coordinates) of a box with integer coordinates that contains the polyhedron.

::

sage: Cube.bounding_box()
((-1, -1, -1), (1, 1, 1))

.. end of output
Center and Representative point
--------------------------------------------------------------

Expand Down Expand Up @@ -433,6 +471,36 @@ There are two ways to get it.

.. end of output
Automorphic groups
--------------------------------------------------------------

The first one gives the automorphism group of the vertex graph of the polyhedron.

::

sage: S.combinatorial_automorphism_group()
Permutation Group with generators [(3,4), (2,3), (1,2)]

sage: Octa = polytopes.octahedron()
sage: Octa.combinatorial_automorphism_group()
Permutation Group with generators [(3,4), (2,3)(4,5), (1,2)(5,6)]

.. end of output
The second automorphism group is the restricted automorphism group which
contains the affine transformations that preserve the :math:`V`-representation.

::

sage: P2 = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1], [0, 1]])
sage: P2.combinatorial_automorphism_group()
Permutation Group with generators [(2,3)]
sage: P2.restricted_automorphism_group()
Permutation Group with generators [()]

.. end of output
??

Incidence matrix
--------------------------------------------------------------
Expand Down
66 changes: 66 additions & 0 deletions src/doc/en/thematic_tutorials/geometry/tips.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.. -*- coding: utf-8 -*-
.. linkall
.. _tips:

==============================================================
Tips, Tricks and Good Things to Know
==============================================================

.. MODULEAUTHOR:: Jean-Philippe Labbé <[email protected]>


Sage input function
==============================================================

If you are working with a polyhedron that was difficult to construct
and you would like to get back the proper Sage input code to reproduce this
object, you can!

::

sage: Cube = polytopes.cube()
sage: TCube = Cube.truncation()
sage: sage_input(TCube)
Polyhedron(base_ring=QQ, vertices=[(-QQ(1), -QQ(1), -1/3), (-QQ(1), -QQ(1),
1/3), (-QQ(1), -1/3, -QQ(1)), (-QQ(1), -1/3, QQ(1)), (-QQ(1), 1/3, -QQ(1)),
(-QQ(1), 1/3, QQ(1)), (-QQ(1), QQ(1), -1/3), (-QQ(1), QQ(1), 1/3), (-1/3,
-QQ(1), -QQ(1)), (-1/3, -QQ(1), QQ(1)), (-1/3, QQ(1), -QQ(1)), (-1/3,
QQ(1), QQ(1)), (1/3, -QQ(1), -QQ(1)), (1/3, -QQ(1), QQ(1)), (1/3, QQ(1),
-QQ(1)), (1/3, QQ(1), QQ(1)), (QQ(1), -QQ(1), -1/3), (QQ(1), -QQ(1), 1/3),
(QQ(1), -1/3, -QQ(1)), (QQ(1), -1/3, QQ(1)), (QQ(1), 1/3, -QQ(1)), (QQ(1),
1/3, QQ(1)), (QQ(1), QQ(1), -1/3), (QQ(1), QQ(1), 1/3)])

.. end of output
:code:`repr_pretty_Hrepresentation`
==============================================================

If you would like to visualize the :math:`H`-representation nicely and even get
the latex presentation, there is a method for that!

::

sage: Nice_repr = TCube.repr_pretty_Hrepresentation(separator='\n')
sage: print Nice_repr
1 >= x0
1 >= x1
3*x1 + 7 >= 3*x0 + 3*x2
x0 + 1 >= 0
x1 + 1 >= 0
3*x0 + 7 >= 3*x1 + 3*x2
3*x0 + 3*x1 + 7 >= 3*x2
3*x0 + 3*x2 + 7 >= 3*x1
3*x0 + 3*x1 + 3*x2 + 7 >= 0
x2 + 1 >= 0
1 >= x2
3*x1 + 3*x2 + 7 >= 3*x0
3*x2 + 7 >= 3*x0 + 3*x1
7 >= 3*x0 + 3*x1 + 3*x2

sage: Latex_repr = LatexExpr(TCube.repr_pretty_Hrepresentation(separator=",\\\\", latex=True))
sage: view(Latex_repr) # not tested

.. end of output

0 comments on commit a1ad1af

Please sign in to comment.