예제 #1
0
def cell_to_basis(cell):
    if cell is None:
        raise Exception("cell_to_basis: bad cell specification.")

    try:
        return cell.basis
    except AttributeError:
        pass

    if isinstance(cell, dict):
        if 'niggli_matrix' in cell:
            niggli_matrix = FracVector.use(cell['niggli_matrix'])
            if 'orientation' in cell:
                orientation = cell['orientation']
            else:
                orientation = 1
            basis = FracVector.use(
                niggli_to_basis(niggli_matrix, orientation=orientation))
        elif 'a' in cell:
            lengths = FracVector.create((cell['a'], cell['b'], cell['c']))
            cosangles = FracVector.create_cos(
                (cell['a'], cell['b'], cell['c']), degrees=True)
            basis = lengths_and_cosangles_to_conventional_basis(
                lengths, cosangles)
            #niggli_matrix = lengths_cosangles_to_niggli(lengths,cosangles)
            #basis = FracVector.use(niggli_to_basis(niggli_matrix, orientation=1))
    else:
        basis = FracVector.use(cell)

    return basis
예제 #2
0
def angles_to_cosangles(angles):
    return FracVector.create_cos(angles, degrees=True)