コード例 #1
0
ファイル: test_vector.py プロジェクト: shmakins/triangulation
 def test_clockwise(self):
     start = Vertex(2,1)
     base_vector = Vector(start, Vertex(3,1))
     clockwise = ((3,2),(2,2),(1,2))
     not_clockwise = ((1,1),(1,0),(2,0),(3,0),(3,1))
     self.assertListEqual([base_vector.is_clockwise(Vector(start, Vertex(v[0],v[1]))) for v in clockwise], [True for x in range(len(clockwise))])
     self.assertListEqual([base_vector.is_clockwise(Vector(start, Vertex(v[0],v[1]))) for v in not_clockwise], [False for x in range(len(not_clockwise))])
コード例 #2
0
ファイル: mesh_graph.py プロジェクト: shmakins/triangulation
    def left_iter(self, around, right):
        base_vec = Vector(around, right)
        start_index, i, max_cos = None, 0, -2
        edges = []
        for edge in filter(lambda x: base_vec.is_clockwise(x), self.vertices[around]):
            edges.append(edge)
            angle_cos = base_vec.cos_angle(edge)
            if angle_cos > max_cos:
                start_index, max_cos = i, angle_cos
            i = i + 1

        i = start_index - len(edges)
        while ( start_index > i):
            yield edges[i].end
            i = i + 1