import math


def get_distance(structure_array, i, j):
    """
    Calculates and returns the distances between to atoms i and j in the given structure_array

    :param structure_array: input numpy array of the cell containing all the atoms ((# of atoms) x 6-matrix)
    :params i, j: indices of the atoms for which the distance should be calculated (indices again start at 0)

    :return: distance between atoms i and j in units of alat

    :note:
    """

    #import math package for square root calculation

    #calculate x-, y-, z-components of distance of i and j
    del_x = structure_array[i][0] - structure_array[j][0]
    del_y = structure_array[i][1] - structure_array[j][1]
    del_z = structure_array[i][2] - structure_array[j][2]

    #return absolute value of the distance of atom i and j
    return math.sqrt(del_x*del_x + del_y*del_y + del_z*del_z)