def tube_inertia(l, m, ro, ri):
    """Calculate the moment of inertia for a tube (or rod) where the x axis is
    aligned with the tube's axis.

    Parameters
    ----------
    l : float
        The length of the tube.
    m : float
        The mass of the tube.
    ro : float
        The outer radius of the tube.
    ri : float
        The inner radius of the tube. Set this to zero if it is a rod instead
        of a tube.

    Returns
    -------
    Ix : float
        Moment of inertia about tube axis.
    Iy, Iz : float
        Moment of inertia about normal axis.

    """
    Ix = m / 2.0 * (ro ** 2 + ri ** 2)
    Iy = m / 12.0 * (3 * ro ** 2 + 3 * ri ** 2 + l ** 2)
    Iz = Iy
    return Ix, Iy, Iz
