import math


def moments_get_orientation(m):
    """Returns the orientation in radians from moments.

    Theta is the angle of the principal axis nearest to the X axis
    and is in the range -pi/4 <= theta <= pi/4. [1]

    1. Simon Xinmeng Liao. Image analysis by moments. (1993).
    """
    theta = 0.5 * math.atan( (2 * m['mu11']) / (m['mu20'] - m['mu02']) )
    return theta