This finds the scaling factor between the (distorted) set of points "points_distorted" and the
    (perfect) set of points "points_perfect" in a least-square sense.
    :param points_distorted: List of points describing a given (distorted) polyhedron for which the scaling factor has
                             to be obtained.
    :param points_perfect: List of "perfect" points describing a given model polyhedron.
    :param rot: The rotation matrix
    :return: The scaling factor between the two structures and the rotated set of (distorted) points.

def find_scaling_factor(points_distorted, points_perfect, rot):
    """
    This finds the scaling factor between the (distorted) set of points "points_distorted" and the
    (perfect) set of points "points_perfect" in a least-square sense.
    :param points_distorted: List of points describing a given (distorted) polyhedron for which the scaling factor has
                             to be obtained.
    :param points_perfect: List of "perfect" points describing a given model polyhedron.
    :param rot: The rotation matrix
    :return: The scaling factor between the two structures and the rotated set of (distorted) points.
    """
    rotated_coords = np.matmul(rot, points_distorted.T).T
    num = np.tensordot(rotated_coords, points_perfect)
    denom = np.tensordot(rotated_coords, rotated_coords)
    return num / denom, rotated_coords, points_perfect