polygons

The category of polyogons

This module provides shared functionality for all polygons in sage-flatsurf.

See flatsurf.geometry.categories for a general description of the category framework in sage-flatsurf.

Normally, you won’t create this (or any other) category directly. The correct category of a polygon is automatically determined.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: C = Polygons(QQ)

sage: from flatsurf import polygons
sage: polygons.square() in C
True
class flatsurf.geometry.categories.polygons.Polygons(base, name=None)[source]

The category of polygons defined over a base ring.

This comprises arbitrary base ring, e.g., this category contains Euclidean polygons and hyperbolic polygons.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: Polygons(QQ)
Category of polygons over Rational Field
class Convex(base_category)[source]

The axiom satisfied by convex polygons.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: C = Polygons(QQ)
sage: C.Convex()
Category of convex polygons over Rational Field
class ParentMethods[source]

Provides methods available to all convex polygons.

If you want to add functionality to all such polygons, you probably want to put it here.

is_convex(strict=False)[source]

Return whether this is a convex polygon, which it is.

EXAMPLES:

sage: from flatsurf import polygons
sage: P = polygons.square()
sage: P.is_convex()
True
class ParentMethods[source]

Provides methods available to all polygons.

If you want to add functionality to all polygons, independent of implementation, you probably want to put it here.

base_ring()[source]

Return the ring over which this polygon is defined.

EXAMPLES:

sage: from flatsurf import polygons
sage: S = polygons.square()
sage: S.base_ring()
Rational Field
change_ring(ring)[source]

Return a copy of this polygon which is defined over ring.

EXAMPLES:

sage: from flatsurf import polygons
sage: S = polygons.square()
sage: K.<sqrt2> = NumberField(x^2 - 2, embedding=AA(2)**(1/2))
sage: S.change_ring(K)
Polygon(vertices=[(0, 0), (1, 0), (1, 1), (0, 1)])
describe_polygon()[source]

Return a textual description of this polygon for generating human-readable messages.

The description is returned as a triple (indeterminate article, singular, plural).

EXAMPLES:

sage: from flatsurf import polygons
sage: s = polygons.square()
sage: s.describe_polygon()
('a', 'square', 'squares')
is_convex(strict=False)[source]

Return whether this is a convex polygon.

INPUT:

  • strict – whether to check for strict convexity, i.e., a polygon with a π angle is not considered convex.

EXAMPLES:

sage: from flatsurf import polygons
sage: S = polygons.square()
sage: S.is_convex()
True
sage: S.is_convex(strict=True)
True
is_degenerate()[source]

Return whether this polygon is considered degenerate.

EXAMPLES:

Polygons with zero area are considered degenerate:

sage: from flatsurf import Polygon
sage: p = Polygon(vertices=[(0, 0), (2, 0), (1, 0)], check=False)
sage: p.is_degenerate()
True

Polygons with marked vertices are considered degenerate:

sage: from flatsurf import Polygon
sage: p = Polygon(vertices=[(0, 0), (2, 0), (4, 0), (2, 2)])
sage: p.is_degenerate()
True
is_simple()[source]

Return whether this polygon is not self-intersecting.

EXAMPLES:

sage: from flatsurf import polygons
sage: s = polygons.square()
sage: s.is_simple()
True
class Rational(base_category)[source]

The axiom satisfied by polygons whose inner angles are rational multiples of π.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: C = Polygons(QQ)
sage: C.Rational()
Category of rational polygons over Rational Field
class ParentMethods[source]

Provides methods available to all rational polygons.

If you want to add functionality to all such polygons, you probably want to put it here.

is_rational()[source]

Return whether all inner angles of this polygon are rational multiples of π, i.e., return True.

EXAMPLES:

sage: from flatsurf import polygons
sage: s = polygons.square()
sage: s.is_rational()
True
class Simple(base_category)[source]

The axiom satisfied by polygons that are not self-intersecting.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: C = Polygons(QQ)
sage: C.Simple()
Category of simple polygons over Rational Field
class ParentMethods[source]

Provides methods available to all simple polygons.

If you want to add functionality to all such polygons, you probably want to put it here.

is_simple()[source]

Return whether this polygon is not self-intersecting, i.e., return True.

EXAMPLES:

sage: from flatsurf import polygons
sage: s = polygons.square()
sage: s.is_simple()
True
class SubcategoryMethods[source]
Convex()[source]

Return the subcategory of convex polygons.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: Polygons(QQ).Convex()
Category of convex polygons over Rational Field
Rational()[source]

Return the subcategory of polygons with rational angles.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: Polygons(QQ).Rational()
Category of rational polygons over Rational Field
Simple()[source]

Return the subcategyr of simple polygons.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: Polygons(QQ).Simple()
Category of simple polygons over Rational Field
base_ring()[source]

Return the ring over which the polygons in this category are defined.

sage: from flatsurf.geometry.categories import Polygons sage: C = Polygons(QQ).Rational().Simple().Convex()

sage: C.base_ring() Rational Field

change_ring(ring)[source]

Return this category but defined over the ring ring.

EXAMPLES:

sage: from flatsurf import polygons
sage: s = polygons.square()
sage: C = s.category()
sage: C
Category of convex simple euclidean rectangles over Rational Field
sage: C.change_ring(AA)
Category of convex simple euclidean rectangles over Algebraic Real Field
field()[source]

Return the field over which these polygons are defined.

EXAMPLES:

sage: from flatsurf import Polygon
sage: P = Polygon(vertices=[(0,0),(1,0),(2,1),(-1,1)])
sage: P.category().field()
doctest:warning
...
UserWarning: field() has been deprecated and will be removed from a future version of sage-flatsurf; use base_ring() or base_ring().fraction_field() instead
Rational Field
super_categories()[source]

Return the categories polygons automatically belong to.

EXAMPLES:

sage: from flatsurf.geometry.categories import Polygons
sage: C = Polygons(QQ)
sage: C.super_categories()
[Category of sets]