Module pavpen.geometry_calculator.circle_calculator

class pavpen.geometry_calculator.circle_calculator.CircleCalculator[Vector](vector_field_operations: FloatVectorFieldOperations, center: Vector, radius: float, x_hat: Vector | None = None, y_hat: Vector | None = None)[source]

Bases: Generic

Calculates the location of points on a circle (or an ellipse, if the norms of x_hat, and y_hat are different)

Example:

>>> import math
>>> from pavpen.geometry_calculator import CircleCalculator
>>> from pavpen.geometry_calculator.vector_field_implementations import (
...     TupleFloatVectorFieldOperations,
... )
>>>
>>> (x, y) = CircleCalculator(
...     vector_field_operations=TupleFloatVectorFieldOperations.for_2d(),
...     center=(0, 0),
...     radius=1,
...     x_hat=(1, 0),
...     y_hat=(0, 1),
... ).point_at_angle_rad(math.pi / 4)
>>> print(f"({x:.4f}, {y:.4f})")
(0.7071, 0.7071)
point_at_angle_rad(angle_rad: float) Vector[source]

Location of the point at angle angle_rad in the right direction from x_hat the on this circle

The value of the x_hat argument is defined when calling the constructor.