```"""Left- and RightCircularArc."""

import functools
import math
from dataclasses import dataclass
from typing import Tuple

from simulation.utils.geometry import Line, Point, Pose

[docs]@dataclass
"""Road section representing a part of a circle."""

angle: float = None
"""Define the portion of the circle [radian]."""

def __post_init__(self):
assert self.angle is not None, "Missing argument angle for circular arc."

super().__post_init__()

@functools.cached_property
def middle_line(self) -> Line:
points = []
current_angle = 0
-1 if self.__class__.TYPE == road_section_type.RIGHT_CIRCULAR_ARC else 1
while current_angle <= self.angle + RADIAN_STEP / 2:
points.append(
Point(
math.cos(current_angle - math.pi / 2) * abs(radius),
)
)

return self.transform * Line(points)

[docs]    def get_ending(self) -> Tuple[Pose, float]:
"""Get the ending of the section as a pose and the curvature.

Returns:
A tuple consisting of the last point on the middle line together with \
the direction facing along the middle line as a pose and the curvature \
at the ending of the middle line.
"""
_, curvature = super().get_ending()

-1 if self.__class__.TYPE == road_section_type.RIGHT_CIRCULAR_ARC else 1
pose = self.transform * Pose(
Point(
math.cos(self.angle - math.pi / 2) * abs(radius),
),
-self.angle
else self.angle,
)
return (pose, curvature)

[docs]@dataclass
class LeftCircularArc(CircularArc):
"""Part of a circle with a positive curvature.

Args:
angle (float): Part of the circle [radian].
"""