-- returns angle' closest to referenceAngle or 0 such that rotation(angle') == rotation(angle)

function MathUtils:AngleNormalize(angle, referenceAngle)
    referenceAngle = referenceAngle or 0
    return (angle - referenceAngle + PI)%TAU - PI + referenceAngle
end

function MathUtils:AngleShortest(a0, a1)
    return self:AngleNormalize(a1 - a0)
end

function MathUtils:LerpAngle(a0, a1, frac)
    return a0 + self:AngleShortest(a0, a1) * frac
end
