pythagoras.curve module¶
- class pythagoras.curve.Arc(o: tuple[float, float], p: tuple[float, float], theta: float, zord: int = 0)[source]¶
Bases:
PObjectAn arc of a circle.
- Variables:
o (tuple[float, float]) – Center of the circle in which the arc is contained.
p (tuple[float, float]) – Starting point of the arc.
theta (float) – Angle spanned by the arc.
- property end_point: tuple[float, float]¶
Compute the end point of the arc.
- 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_three_points(p1: tuple[float, float], p2: tuple[float, float], p3: tuple[float, float], zord: int = 0) Self[source]¶
Construct the arc that passes through three points.
- Parameters:
p1 – First point.
p2 – Second point.
p3 – Third point.
zord – Rendering priority (see
PObject._zord).
- Returns:
An instance of
Arc.
- classmethod from_two_points_and_angle(p1: tuple[float, float], p2: tuple[float, float], theta: float, zord: int = 0) Self[source]¶
Construct the arc that passes through two points and spans a given angle.
- Parameters:
p1 – First point.
p2 – Second point.
theta – Angle spanned.
zord – Rendering priority (see
PObject._zord).
- Returns:
An instance of
Arc.
- o: tuple[float, float]¶
- p: tuple[float, float]¶
- property radius: float¶
Gives the radius of the circle in which the arc is contained.
- svg(ctx: RenderingContext, *args: POProperty) str[source]¶
Compiles the object into SVG commands.
- Parameters:
ctx – Context associated with the
Canvasinstance.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
Canvasinstance.args – Properties of the object.
- Returns:
The resulting TikZ code.
- class pythagoras.curve.Parametric(f: Callable[[float], tuple[float, float]], a: float, b: float, dt: float = 0, zord: int = 0)[source]¶
Bases:
PObjectCurve traced by a parametric function.
- Variables:
f (collections.abc.Callable[[float], tuple[float, float]]) – The function which determines the shape.
a (float) – Start of the time domain.
b (float) – End of the time domain.
dt (float) – Increment in time between each point. If it is less than or equal to zero, the time domain will be split into 100 intervals.
- a: float¶
- b: float¶
- dt: float¶
- extrema() list[tuple[float, float]][source]¶
Computes the furthermost points of the figure.
- Returns:
A list with the bounding points of the object.
- f: Callable[[float], tuple[float, float]]¶
- make_points() list[tuple[float, float]][source]¶
Compute the positions of each of the samples of the curve.
- Returns:
List containing the sampled points.
- svg(ctx: RenderingContext, *args: POProperty) str[source]¶
Compiles the object into SVG commands.
- Parameters:
ctx – Context associated with the
Canvasinstance.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
Canvasinstance.args – Properties of the object.
- Returns:
The resulting TikZ code.