Example #1
0
 def test_qdelaunay(self):
     data = [[0,0], [-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
     self.assertEqual(['4', '3 0 1', '0 2 1', '4 0 3', '0 4 2'],
                      qdelaunay("i", data))
     self.assertEqual(qdelaunay("n", data),
                      ['4', '4',
                       '-0 -0.8944271909999159 -0.4472135954999579      0',
                       '-0.8944271909999159      0 -0.4472135954999579     -0',
                       '0.8944271909999159      0 -0.4472135954999579     -0',
                       '-0 0.8944271909999159 -0.4472135954999579     -0']
     )
     self.assertEqual(qdelaunay("i n", data),
                      ['4', '3 0 1', '0 2 1', '4 0 3', '0 4 2',
                       '4', '4',
                       '-0 -0.8944271909999159 -0.4472135954999579      0',
                       '-0.8944271909999159      0 -0.4472135954999579     -0',
                       '0.8944271909999159      0 -0.4472135954999579     -0',
                       '-0 0.8944271909999159 -0.4472135954999579     -0']
     )
Example #2
0
    def __init__(self, points, joggle=False):
        """
        Initializes a DelaunayTri from points.

        Args:
            points ([[float]]): All the points as a sequence of sequences.
                e.g., [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
            joggle (bool): Use qhull option to joggle inputs until simplical
                result is obtained instead of merging facets.
        """
        self.points = points
        dim = [len(i) for i in self.points]
        if max(dim) != min(dim):
            raise ValueError("Input points must all have the same dimension!")
        self.dim = dim[0]
        if joggle:
            options = "i QJ"
        else:
            options = "i Qt"
        output = qdelaunay(options, points)
        output.pop(0)
        self.vertices = [[int(i)for i in row.strip().split()] for row in output]
Example #3
0
 def __init__(self, points, joggle=False):
     """
     Args:
         points:
             All the points as a sequence of sequences. e.g., [[-0.5, -0.5],
             [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
         joggle:
             Use qhull option to joggle inputs until simplical result is 
             obtained instead of merging facets.
     """
     self.points = points
     dim = map(len, self.points)
     if max(dim) != min(dim):
         raise ValueError("Input points must all have the same dimension!")
     self.dim = dim[0]
     if joggle:
         options = "i QJ"
     else:
         options = "i Qt"
     output = qdelaunay(options, points)
     output.pop(0)
     self.vertices = [map(int, row.strip().split()) for row in output]