def _get_rgb_index_for_spi3d_output(line_index, grid_num):
    """
    3DLUT Data の行番号から、当該行に該当する r_idx, g_idx, b_idx を
    算出する。

    Parameters
    ----------
    line_index : int
        line number.
    grid_num : int
        grid number.

    Returns
    -------
    int, int, int
        grid index of each color.
    """

    r_idx = (line_index // (grid_num ** 2)) % grid_num
    g_idx = (line_index // (grid_num ** 1)) % grid_num
    b_idx = (line_index // (grid_num ** 0)) % grid_num

    return r_idx, g_idx, b_idx