def local_coordinates(self, position: Tuple[float, float]) -> Tuple[float, float]:
        """Compute the local coordinates (longitude, lateral) of the given position in this circular lane.

        Args:
            position: floats in 2D

        Returns:
            longtidue in float
            lateral in float
        """
        delta_x = position[0] - self.center[0]
        delta_y = position[1] - self.center[1]
        abs_phase = math.atan2(delta_y, delta_x)
        abs_phase = wrap_to_pi(abs_phase)

        # Processing the relative phase (angle) is extremely complex.
        start_phase = wrap_to_pi(self.start_phase)
        end_phase = wrap_to_pi(self.end_phase)

        diff_to_start_phase = abs(wrap_to_pi(abs_phase - start_phase))
        diff_to_end_phase = abs(wrap_to_pi(abs_phase - end_phase))

        if diff_to_start_phase > np.pi and diff_to_end_phase > np.pi:
            raise ValueError(
                f"Undetermined position. Relative phase of the given point to the start phase is"
                f" {wrap_to_pi(abs_phase - start_phase)} while the phase to the end phase is "
                f"{wrap_to_pi(abs_phase - end_phase)}. Both of them are > 180deg. "
                f"We don't know how to compute the longitudinal in this case."
            )

        # If the point is closer to the end point
        if diff_to_start_phase > diff_to_end_phase:
            if self.is_clockwise():
                diff = self.end_phase - abs_phase
            else:
                diff = abs_phase - self.end_phase
            relative_phase = wrap_to_pi(diff)
            longitudinal = relative_phase * self.radius + self.length
        else:
            if self.is_clockwise():
                diff = self.start_phase - abs_phase
            else:
                diff = abs_phase - self.start_phase
            relative_phase = wrap_to_pi(diff)
            longitudinal = relative_phase * self.radius

        # Compute the lateral
        distance_to_center = norm(delta_x, delta_y)
        lateral = self.direction * (distance_to_center - self.radius)

        return longitudinal, lateral
Compute the local coordinates (longitude, lateral) of the given position in this circular lane.

        Args:
            position: floats in 2D

        Returns:
            longtidue in float
            lateral in float
        
metadrive/component/lane/circular_lane.py