circular_midpoint

Function
circular_midpoint(a1: float, a2: float) -> float

Calculate the midpoint between two angles on a circle.

Uses vector averaging to find the true angular midpoint, which correctly handles cases where angles span across 0°/360°. This is geometrically correct for circular interpolation, unlike simple arithmetic mean.

Parameters

a1
First angle in degrees (0-360)
a2
Second angle in degrees (0-360)

Returns

Midpoint angle in degrees (normalized to 0-360 range)

Examples

circular_midpoint(0, 90)
    45.0
    circular_midpoint(350, 10)  # Spans 0°
    0.0
    circular_midpoint(270, 90)  # Opposite sides
    0.0

Notes

This differs from simple averaging: (350 + 10) / 2 = 180, but circular_midpoint(350, 10) = 0, which is geometrically correct.