pythagoras.circle module

class pythagoras.circle.Circle(x: float, y: float, radius: float, zord: int = 0)[source]

Bases: PObject

Circle PObject. As its name suggests, renders into a cirlce when drawn.

Variables:
  • x (float) – \(x\)-coordinate of the center.

  • y (float) – \(y\)-coordinate of the center.

  • radius (float) – Radius.

extrema() list[tuple[float, float]][source]

Computes the furthermost points of the figure.

Returns:

A list with the bounding points of the object.

radius: float
svg(ctx: RenderingContext, *args: POProperty) str[source]

Compiles the object into SVG commands.

Parameters:
  • ctx – Context associated with the Canvas instance.

  • args – Properties of the object.

Returns:

The corresponding SVG code.

tikz(ctx: RenderingContext, *args: POProperty) str[source]

Compiles the object into a sequence of TikZ instructions.

Parameters:
  • ctx – Context associated with the Canvas instance.

  • args – Properties of the object.

Returns:

The resulting TikZ code.

classmethod triangle_circumcircle(p1: tuple[float, float], p2: tuple[float, float], p3: tuple[float, float], zord: int = 0) Self[source]

Generate the circle that passes through three given points. Recall that the circumcircle of a triangle is the intersection of the side bisectors; this is the way it is found.

Parameters:
  • p1 – First point of the triangle.

  • p2 – Second point of the triangle.

  • p3 – Third point of the triangle.

  • zord – Rendering priority of the circle.

Returns:

A circle that passes through p1, p2 and p3.

classmethod triangle_incircle(p1: tuple[float, float], p2: tuple[float, float], p3: tuple[float, float], zord: int = 0) tuple[Self, tuple[float, float], tuple[float, float], tuple[float, float]][source]

Computes the points of tangency and the center of the incircle of the triangle delimited by three points. The incircle of a triangle is computed as the intersection of its angle bisectors.

Parameters:
  • p1 – First point of the triangle.

  • p2 – Second point of the triangle.

  • p3 – Third point of the triangle.

  • zord – Rendering priority of the circle.

Returns:

The incircle together with the three points of tangency.

x: float
y: float
class pythagoras.circle.Ellipse(x: float, y: float, rx: float, ry: float, zord: int = 0)[source]

Bases: PObject

An ellipse.

Variables:
  • x (float) – \(x\)-coordinate of its center.

  • y (float) – \(y\)-coordinate of its center.

  • rx (float) – Length of the semi axis corresponding to the \(x\) axis.

  • ry (float) – Length of the semi axis corresponding to the \(y\) axis.

  • theta (float) – Angle of rotation with respect to the positive \(x\) axis.

extrema() list[tuple[float, float]][source]

Computes the furthermost points of the figure.

Returns:

A list with the bounding points of the object.

classmethod from_foci(f1: tuple[float, float], f2: tuple[float, float], p: tuple[float, float], zord: int = 0) Self[source]

Creates an ellipse from its center and foci.

Parameters:
  • f1 – First focus point.

  • f2 – Second focus point.

  • p – Center of the ellipse.

Returns:

Ellipse with the given foci and center.

rx: float
ry: float
svg(ctx: RenderingContext, *args: POProperty) str[source]

Compiles the object into SVG commands.

Parameters:
  • ctx – Context associated with the Canvas instance.

  • args – Properties of the object.

Returns:

The corresponding SVG code.

theta: float
tikz(ctx: RenderingContext, *args: POProperty) str[source]

Compiles the object into a sequence of TikZ instructions.

Parameters:
  • ctx – Context associated with the Canvas instance.

  • args – Properties of the object.

Returns:

The resulting TikZ code.

x: float
y: float
class pythagoras.circle.Point(x: float, y: float, radius: float = 1, zord: int = 0)[source]

Bases: Circle

A circle small enough to represent a point.

svg(ctx: RenderingContext, *args: POProperty) str[source]

Compiles the object into SVG commands.

Parameters:
  • ctx – Context associated with the Canvas instance.

  • args – Properties of the object.

Returns:

The corresponding SVG code.

tikz(ctx: RenderingContext, *args: POProperty) str[source]

Compiles the object into a sequence of TikZ instructions.

Parameters:
  • ctx – Context associated with the Canvas instance.

  • args – Properties of the object.

Returns:

The resulting TikZ code.