def permutation_to_cosine(permutation, flip):
    """Get mhd direction cosine for this dimension permutation"""
    dir_cosine = [0, 0, 0, 0, 0, 0, 0, 0, 0]
    dir_cosine[permutation[0] * 3] = -1 if flip[0] else 1
    dir_cosine[permutation[1] * 3 + 1] = -1 if flip[1] else 1
    dir_cosine[permutation[2] * 3 + 2] = -1 if flip[2] else 1
    return dir_cosine
