atlas.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:kingfisher 作者: peixian 项目源码 文件源码
def relax_points(self, times=1):
        """
        Relaxes the points after an initial Voronoi is created to refine the graph.
        See: https://stackoverflow.com/questions/17637244/voronoi-and-lloyd-relaxation-using-python-scipy

        :param times: Number of times to relax, default is 1
        :type times: int

        :return: the final voronoi diagrama
        :rtype: scipy.spatial.Voronoi
        """
        for i in range(times):
            centroids = []
            for region in self.filtered_regions:
                vertices = self.vor.vertices[region + [region[0]], :]
                centroid = self._region_centroid(vertices)
                centroids.append(list(centroid[0, :]))
            self.points = centroids
            self.generate_voronoi()
        return self.vor
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号