Polygons and triangles in hyperbolic geometry

AUTHORS:

  • Hartmut Monien (2011-08)

  • Vincent Delecroix (2014-11)

class sage.plot.hyperbolic_polygon.HyperbolicPolygon(pts, model, options)[source]

Bases: HyperbolicArcCore

Primitive class for hyperbolic polygon type.

See hyperbolic_polygon? for information about plotting a hyperbolic polygon in the complex plane.

INPUT:

  • pts – coordinates of the polygon (as complex numbers)

  • options – dictionary of valid plot options to pass to constructor

EXAMPLES:

Note that constructions should use hyperbolic_polygon() or hyperbolic_triangle():

sage: from sage.plot.hyperbolic_polygon import HyperbolicPolygon
sage: print(HyperbolicPolygon([0, 1/2, I], "UHP", {}))
Hyperbolic polygon (0.000000000000000, 0.500000000000000, 1.00000000000000*I)
>>> from sage.all import *
>>> from sage.plot.hyperbolic_polygon import HyperbolicPolygon
>>> print(HyperbolicPolygon([Integer(0), Integer(1)/Integer(2), I], "UHP", {}))
Hyperbolic polygon (0.000000000000000, 0.500000000000000, 1.00000000000000*I)
from sage.plot.hyperbolic_polygon import HyperbolicPolygon
print(HyperbolicPolygon([0, 1/2, I], "UHP", {}))
sage.plot.hyperbolic_polygon.hyperbolic_polygon(pts, model='UHP', resolution=200, alpha=1, fill=False, thickness=1, rgbcolor='blue', zorder=2, linestyle='solid', **options)[source]

Return a hyperbolic polygon in the hyperbolic plane with vertices pts.

Type ?hyperbolic_polygon to see all options.

INPUT:

  • pts – list or tuple of complex numbers

OPTIONS:

  • model – (default: UHP) Model used for hyperbolic plane

  • alpha – (default: 1)

  • fill – (default: False)

  • thickness – (default: 1)

  • rgbcolor – (default: 'blue')

  • linestyle – (default: 'solid') the style of the line, which is one of 'dashed', 'dotted', 'solid', 'dashdot', or '--', ':', '-', '-.', respectively

EXAMPLES:

Show a hyperbolic polygon with coordinates \(-1\), \(3i\), \(2+2i\), \(1+i\):

sage: hyperbolic_polygon([-1,3*I,2+2*I,1+I])
Graphics object consisting of 1 graphics primitive
>>> from sage.all import *
>>> hyperbolic_polygon([-Integer(1),Integer(3)*I,Integer(2)+Integer(2)*I,Integer(1)+I])
Graphics object consisting of 1 graphics primitive
hyperbolic_polygon([-1,3*I,2+2*I,1+I])
../../_images/hyperbolic_polygon-1.svg

With more options:

sage: hyperbolic_polygon([-1,3*I,2+2*I,1+I], fill=True, color='red')
Graphics object consisting of 1 graphics primitive
>>> from sage.all import *
>>> hyperbolic_polygon([-Integer(1),Integer(3)*I,Integer(2)+Integer(2)*I,Integer(1)+I], fill=True, color='red')
Graphics object consisting of 1 graphics primitive
hyperbolic_polygon([-1,3*I,2+2*I,1+I], fill=True, color='red')
../../_images/hyperbolic_polygon-2.svg

With a vertex at \(\infty\):

sage: hyperbolic_polygon([-1,0,1,Infinity], color='green')
Graphics object consisting of 1 graphics primitive
>>> from sage.all import *
>>> hyperbolic_polygon([-Integer(1),Integer(0),Integer(1),Infinity], color='green')
Graphics object consisting of 1 graphics primitive
hyperbolic_polygon([-1,0,1,Infinity], color='green')
../../_images/hyperbolic_polygon-3.svg

Poincare disc model is supported via the parameter model. Show a hyperbolic polygon in the Poincare disc model with coordinates \(1\), \(i\), \(-1\), \(-i\):

sage: hyperbolic_polygon([1,I,-1,-I], model='PD', color='green')
Graphics object consisting of 2 graphics primitives
>>> from sage.all import *
>>> hyperbolic_polygon([Integer(1),I,-Integer(1),-I], model='PD', color='green')
Graphics object consisting of 2 graphics primitives
hyperbolic_polygon([1,I,-1,-I], model='PD', color='green')
../../_images/hyperbolic_polygon-4.svg

With more options:

sage: hyperbolic_polygon([1,I,-1,-I], model='PD', color='green', fill=True, linestyle='-')
Graphics object consisting of 2 graphics primitives
>>> from sage.all import *
>>> hyperbolic_polygon([Integer(1),I,-Integer(1),-I], model='PD', color='green', fill=True, linestyle='-')
Graphics object consisting of 2 graphics primitives
hyperbolic_polygon([1,I,-1,-I], model='PD', color='green', fill=True, linestyle='-')
../../_images/hyperbolic_polygon-5.svg

Klein model is also supported via the parameter model. Show a hyperbolic polygon in the Klein model with coordinates \(1\), \(e^{i\pi/3}\), \(e^{i2\pi/3}\), \(-1\), \(e^{i4\pi/3}\), \(e^{i5\pi/3}\):

sage: p1 = 1
sage: p2 = (cos(pi/3), sin(pi/3))
sage: p3 = (cos(2*pi/3), sin(2*pi/3))
sage: p4 = -1
sage: p5 = (cos(4*pi/3), sin(4*pi/3))
sage: p6 = (cos(5*pi/3), sin(5*pi/3))
sage: hyperbolic_polygon([p1,p2,p3,p4,p5,p6], model='KM', fill=True, color='purple')
Graphics object consisting of 2 graphics primitives
>>> from sage.all import *
>>> p1 = Integer(1)
>>> p2 = (cos(pi/Integer(3)), sin(pi/Integer(3)))
>>> p3 = (cos(Integer(2)*pi/Integer(3)), sin(Integer(2)*pi/Integer(3)))
>>> p4 = -Integer(1)
>>> p5 = (cos(Integer(4)*pi/Integer(3)), sin(Integer(4)*pi/Integer(3)))
>>> p6 = (cos(Integer(5)*pi/Integer(3)), sin(Integer(5)*pi/Integer(3)))
>>> hyperbolic_polygon([p1,p2,p3,p4,p5,p6], model='KM', fill=True, color='purple')
Graphics object consisting of 2 graphics primitives
p1 = 1
p2 = (cos(pi/3), sin(pi/3))
p3 = (cos(2*pi/3), sin(2*pi/3))
p4 = -1
p5 = (cos(4*pi/3), sin(4*pi/3))
p6 = (cos(5*pi/3), sin(5*pi/3))
hyperbolic_polygon([p1,p2,p3,p4,p5,p6], model='KM', fill=True, color='purple')
../../_images/hyperbolic_polygon-6.svg

Hyperboloid model is supported partially, via the parameter model. Show a hyperbolic polygon in the hyperboloid model with coordinates \((3,3,\sqrt(19))\), \((3,-3,\sqrt(19))\), \((-3,-3,\sqrt(19))\), \((-3,3,\sqrt(19))\):

sage: pts = [(3,3,sqrt(19)),(3,-3,sqrt(19)),(-3,-3,sqrt(19)),(-3,3,sqrt(19))]
sage: hyperbolic_polygon(pts, model='HM')
Graphics3d Object
>>> from sage.all import *
>>> pts = [(Integer(3),Integer(3),sqrt(Integer(19))),(Integer(3),-Integer(3),sqrt(Integer(19))),(-Integer(3),-Integer(3),sqrt(Integer(19))),(-Integer(3),Integer(3),sqrt(Integer(19)))]
>>> hyperbolic_polygon(pts, model='HM')
Graphics3d Object
pts = [(3,3,sqrt(19)),(3,-3,sqrt(19)),(-3,-3,sqrt(19)),(-3,3,sqrt(19))]
hyperbolic_polygon(pts, model='HM')
../../_images/hyperbolic_polygon-7.svg

Filling a hyperbolic_polygon in hyperboloid model is possible although jaggy. We show a filled hyperbolic polygon in the hyperboloid model with coordinates \((1,1,\sqrt(3))\), \((0,2,\sqrt(5))\), \((2,0,\sqrt(5))\). (The doctest is done at lower resolution than the picture below to give a faster result.)

sage: pts = [(1,1,sqrt(3)), (0,2,sqrt(5)), (2,0,sqrt(5))]
sage: hyperbolic_polygon(pts, model='HM', resolution=50,
....:                    color='yellow', fill=True)
Graphics3d Object
>>> from sage.all import *
>>> pts = [(Integer(1),Integer(1),sqrt(Integer(3))), (Integer(0),Integer(2),sqrt(Integer(5))), (Integer(2),Integer(0),sqrt(Integer(5)))]
>>> hyperbolic_polygon(pts, model='HM', resolution=Integer(50),
...                    color='yellow', fill=True)
Graphics3d Object
pts = [(1,1,sqrt(3)), (0,2,sqrt(5)), (2,0,sqrt(5))]
hyperbolic_polygon(pts, model='HM', resolution=50,
                   color='yellow', fill=True)
../../_images/hyperbolic_polygon-8.svg
sage.plot.hyperbolic_polygon.hyperbolic_triangle(a, b, c, model='UHP', **options)[source]

Return a hyperbolic triangle in the hyperbolic plane with vertices (a,b,c).

Type ?hyperbolic_polygon to see all options.

INPUT:

  • a, b, c – complex numbers in the upper half complex plane

OPTIONS:

  • alpha – (default: 1)

  • fill – (default: False)

  • thickness – (default: 1)

  • rgbcolor – (default: 'blue')

  • linestyle – (default: 'solid') the style of the line, which is one of 'dashed', 'dotted', 'solid', 'dashdot', or '--', ':', '-', '-.', respectively

EXAMPLES:

Show a hyperbolic triangle with coordinates \(0\), \(1/2 + i\sqrt{3}/2\) and \(-1/2 + i\sqrt{3}/2\):

sage: hyperbolic_triangle(0, -1/2+I*sqrt(3)/2, 1/2+I*sqrt(3)/2)
Graphics object consisting of 1 graphics primitive
>>> from sage.all import *
>>> hyperbolic_triangle(Integer(0), -Integer(1)/Integer(2)+I*sqrt(Integer(3))/Integer(2), Integer(1)/Integer(2)+I*sqrt(Integer(3))/Integer(2))
Graphics object consisting of 1 graphics primitive
hyperbolic_triangle(0, -1/2+I*sqrt(3)/2, 1/2+I*sqrt(3)/2)
../../_images/hyperbolic_polygon-9.svg

A hyperbolic triangle with coordinates \(0\), \(1\) and \(2+i\) and a dashed line:

sage: hyperbolic_triangle(0, 1, 2+i, fill=true, rgbcolor='red', linestyle='--')
Graphics object consisting of 1 graphics primitive
>>> from sage.all import *
>>> hyperbolic_triangle(Integer(0), Integer(1), Integer(2)+i, fill=true, rgbcolor='red', linestyle='--')
Graphics object consisting of 1 graphics primitive
hyperbolic_triangle(0, 1, 2+i, fill=true, rgbcolor='red', linestyle='--')
../../_images/hyperbolic_polygon-10.svg

A hyperbolic triangle with a vertex at \(\infty\):

sage: hyperbolic_triangle(-5,Infinity,5)
Graphics object consisting of 1 graphics primitive
>>> from sage.all import *
>>> hyperbolic_triangle(-Integer(5),Infinity,Integer(5))
Graphics object consisting of 1 graphics primitive
hyperbolic_triangle(-5,Infinity,5)
../../_images/hyperbolic_polygon-11.svg

It can also plot a hyperbolic triangle in the Poincaré disk model:

sage: z1 = CC((cos(pi/3),sin(pi/3)))
sage: z2 = CC((0.6*cos(3*pi/4),0.6*sin(3*pi/4)))
sage: z3 = 1
sage: hyperbolic_triangle(z1, z2, z3, model='PD', color='red')
Graphics object consisting of 2 graphics primitives
>>> from sage.all import *
>>> z1 = CC((cos(pi/Integer(3)),sin(pi/Integer(3))))
>>> z2 = CC((RealNumber('0.6')*cos(Integer(3)*pi/Integer(4)),RealNumber('0.6')*sin(Integer(3)*pi/Integer(4))))
>>> z3 = Integer(1)
>>> hyperbolic_triangle(z1, z2, z3, model='PD', color='red')
Graphics object consisting of 2 graphics primitives
z1 = CC((cos(pi/3),sin(pi/3)))
z2 = CC((0.6*cos(3*pi/4),0.6*sin(3*pi/4)))
z3 = 1
hyperbolic_triangle(z1, z2, z3, model='PD', color='red')
../../_images/hyperbolic_polygon-12.svg
sage: hyperbolic_triangle(0.3+0.3*I, 0.8*I, -0.5-0.5*I, model='PD', color='magenta')
Graphics object consisting of 2 graphics primitives
>>> from sage.all import *
>>> hyperbolic_triangle(RealNumber('0.3')+RealNumber('0.3')*I, RealNumber('0.8')*I, -RealNumber('0.5')-RealNumber('0.5')*I, model='PD', color='magenta')
Graphics object consisting of 2 graphics primitives
hyperbolic_triangle(0.3+0.3*I, 0.8*I, -0.5-0.5*I, model='PD', color='magenta')
../../_images/hyperbolic_polygon-13.svg