def sqdist2(x1, y1, x2, y2, ist, rotmat, anis):
    """Calculate the 2D square distance based on geometric ani
    :param x1: x coordinate of first point
    :param y1: y coordinate of first point
    :param x2: x coordinate of second point
    :param y2: y coordinate of second point
    :param ist: structure index 
    :param rotmat: 2d rotation matrix 
    :param anis: 2D anisotropy ratio
    :return: TODO
    """
    dx = x1 - x2
    dy = y1 - y2
    dx1 = dx * rotmat[0, ist] + dy * rotmat[1, ist]
    dy1 = (dx * rotmat[2, ist] + dy * rotmat[3, ist]) / anis[ist]
    sqdist_ = dx1 * dx1 + dy1 * dy1
    return sqdist_
