示例#1
0
 def setUp(self):
     k = KineticTriangle()
     # base
     o = KineticVertex()
     o.origin = (0., 0.)
     o.velocity = (0., 1.)
     #
     d = KineticVertex()
     d.origin = (4., 0.)
     d.velocity = (0, 1.)
     # vertex missing the base
     a = KineticVertex()
     a.origin = (4., 5.)
     a.velocity = (0, -2.)
     k.vertices = [o, d, a]
     k.neighbours = [True, True, None]
     self.tri = k
示例#2
0
 def setUp(self):
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (0.0, 0.0)
     v.velocity = (-2.1889010593167346, -1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.0, 0.0)
     v.velocity = (2.1889010593167346, -1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (1.5, 1.7320508075688772)
     v.velocity = (0.0, 1.5275252316519463)
     V.append(v)
     k.vertices = V
     k.neighbours = [None, None, True]
     self.tri = k
示例#3
0
 def setUp(self):
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (0.0, 0.0)
     v.velocity = (1., 0.)
     V.append(v)
     v = KineticVertex()
     v.origin = (0.0, 10.0)
     v.velocity = (1.0, 0.)
     V.append(v)
     v = KineticVertex()
     v.origin = (-1.0, 5.0)
     v.velocity = (5., 0.)
     V.append(v)
     k.vertices = V
     k.neighbours = [True, True, True]
     self.tri = k
示例#4
0
 def setUp(self):
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (-1.802775637731995, 0.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (-2.0, 8.0)
     v.velocity = (1.0, -1.8685170918213299)
     V.append(v)
     v = KineticVertex()
     v.origin = (-2.0, -8.0)
     v.velocity = (1.0, 1.8685170918213299)
     V.append(v)
     k.vertices = V
     k.neighbours = [True, True, True]
     self.tri = k
示例#5
0
    def setUp(self):
        k = KineticTriangle()

        o = KineticVertex()
        o.origin = (0., 0.)
        o.velocity = (0., 1.)

        d = KineticVertex()
        d.origin = (10., 0.)
        d.velocity = (0, 1.)

        # vertex supposed to crash into base (the apex)
        a = KineticVertex()
        a.origin = (5, 5)
        a.velocity = (0., -1.)

        k.vertices = [o, d, a]
        k.neighbours = [True, True, None]
        self.tri = k
示例#6
0
 def setUp(self):
     """Initialize 3 infinite triangles and 1 finite 3-triangle.
     """
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (0., 0)
     v.velocity = (1., 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (10., 0)
     v.velocity = (-1., 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.,15.)
     v.velocity = (0, -1.)
     V.append(v)
     k.vertices = V
     # mock the neighbours, 
     # to determine correctly the triangle type
     k.neighbours = [True, True, True]
     self.tri = k
示例#7
0
    def setUp(self):
        self.triangle = KineticTriangle(
            KineticVertex((-0.10754127621601216, -0.8518518518525637),
                          (1.1277743405217686, -0.8539125853201076)),
            KineticVertex((-0.10754127621545964, -0.8518518518560583),
                          (1.1227962916920335, -0.8545992124818665)),
            KineticVertex((0.09433524838987582, -0.9500459243279002),
                          (-1.0906702065440808, 0.8568264443105804)), True,
            True, None)
        self.now = 0.01350521350551394522687687072

        for t in [
                0.
        ]:  #, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.0947089087]:
            visualize_collapse(self.triangle, T=t)
示例#8
0
    def setUp(self):
        self.triangle = KineticTriangle(
            KineticVertex((-0.583221775992843, -0.7777777777791053),
                          (0.8502422723435449, 1.1193719054708335),
                          (-0.12933918403800038, 0.9916004111901044),
                          (0.9899494936613725, 0.14142135623586805)),
            KineticVertex((-0.5850066934405151, -0.7608210620269993),
                          (1.1278459170135144, -0.8613604025707853),
                          (0.9906788398454419, 0.1362183404776662),
                          (0.12933918403880518, -0.9916004111899995)),
            KineticVertex((-69008181994845.11, -8996100425594.38),
                          (8097106551877965.0, 1055561552148527.8),
                          (0.12933918403880518, -0.9916004111899995),
                          (-0.12933918403800038, 0.9916004111901044)), None,
            None, True)
        self.now = 0.008522573039234542999209587322

        for t in [
                0.
        ]:  #, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.0947089087]:
            visualize_collapse(self.triangle, T=t)
示例#9
0
    def setUp(self):
        #self.now = 0.134576326
        self.now = 0
        self.triangle = KineticTriangle(
            KineticVertex((-5.586845556126167, 12.264500723992885),
                          (42.96862677742887, -96.56675461024079),
                          (-0.9097484670494593, -0.4151598808906743),
                          (0.9174410515320596, 0.39787173431113276)),
            KineticVertex((0.07562289915966396, -0.792423319327731),
                          (0.892367111503632, 0.45568901541445345),
                          (0.9174410515320596, 0.39787173431113276),
                          (0.8602330667847619, 0.5099010402127879)),
            KineticVertex((1.3619372870019553, -2.9625114016712693),
                          (-8.665884533180343, 16.58102212313996),
                          (0.8602330667847619, 0.5099010402127879),
                          (-0.9097484670494593, -0.4151598808906743)), None,
            None, None)

        for t in [
                0., 0.13
        ]:  #, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.0947089087]:
            visualize_collapse(self.triangle, T=t)
示例#10
0
    def setUp(self):
        self.triangle = KineticTriangle(
            KineticVertex((0.7535965796935182, 0.41537586304902124),
                          (1.20214406777568, -0.6838702949507468),
                          (0.9700438684136995, 0.24292981157730573),
                          (0.28688406971441127, -0.957965307589005)),
            KineticVertex((0.793056201639544, 0.32270148647248165),
                          (-0.13094220113388658, 1.1449829817969648),
                          (0.39524394070149405, 0.9185761957174559),
                          (-0.592426467909283, 0.8056245280032946)),
            KineticVertex((0.7872824597246767, 0.3184556903101898),
                          (0.12436918194296205, 1.3327295257957255),
                          (-0.592426467909283, 0.8056245280032946),
                          (0.731259583557203, 0.682099275366677)), None, True,
            True)

        self.now = 0.04331079000480406865358773416

        for t in [
                0.
        ]:  #, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.0947089087]:
            visualize_collapse(self.triangle, T=t)
示例#11
0
def init_skeleton(dt):
    """Initialize a data structure that can be used for making the straight
    skeleton.
    """
    skel = Skeleton()

    # make skeleton nodes
    # -> every triangulation vertex becomes a skeleton node
    nodes = {}
    avg_x = 0.0
    avg_y = 0.0
    for v in dt.vertices:
        if v.is_finite:
            nodes[v] = SkeletonNode(pos=(v.x, v.y), step=-1, info=v.info)
            avg_x += v.x / len(dt.vertices)
            avg_y += v.y / len(dt.vertices)
    centroid = InfiniteVertex()
    centroid.origin = (avg_x, avg_y)
    # make kinetic triangles, so that for every delaunay triangle we have
    # a kinetic counter part

    ktriangles = []  # all kinetic triangles
    # mapping from delaunay triangle to kinetic triangle

    internal_triangles = set()
    for _, depth, triangle in RegionatedTriangleIterator(dt):
        if depth == 1:
            # FIXME: why not put the depth here as identifier into the triangle
            # holes can then be separated from others (and possibly calculated in parallel)
            internal_triangles.add(triangle)

    triangle2ktriangle = {}
    for idx, t in enumerate(dt.triangles, start=1):
        # skip the external triangle
        # if t is dt.external:
        #    continue
        k = KineticTriangle()
        k.info = idx
        triangle2ktriangle[t] = k
        ktriangles.append(k)
        k.internal = t in internal_triangles  # whether triangle is internal to a polygon
    del idx

    link_around = []
    # set up properly the neighbours of all kinetic triangles
    # blank out the neighbour, if a side is constrained
    unwanted = []
    #it = TriangleIterator(dt)
    # skip the external triangle (which is the first the iterator gives)
    #     next(it)
    for t in dt.triangles:
        k = triangle2ktriangle[t]

        for i in range(3):
            edge = Edge(t, i)
            # k.wavefront_directions[i] = make_unit_vector(edge)
            k.wavefront_support_lines[i] = make_support_line(edge)

        for j, n in enumerate(t.neighbours):
            # set neighbour pointer to None if constrained side
            if t.constrained[j]:
                continue
            # skip linking to non-existing triangle
            if n is None or n.vertices[2] is None:
                #            if n.external:
                unwanted.append(k)
                continue
            k.neighbours[j] = triangle2ktriangle[n]

    # FIXME: duplicate <-> each KTriangle has wavefront!
    # unit_vectors = make_unit_vectors(dt)
    # make kinetic vertices
    # and link them to the kinetic triangles
    # also make sure that every kinetic vertex is related to a skeleton node
    kvertices = []
    #     ktri_no_apex = []
    #     one_ktri_between = {}
    #     with open("/tmp/bisectors.wkt", "w") as bisector_fh:
    #         print >> bisector_fh, "wkt"
    ct = 0
    for v in dt.vertices:
        assert v.is_finite, "infinite vertex found"

        groups = split_star(v)
        if len(groups) == 1:
            raise NotImplementedError(
                "not yet dealing with PSLG in initial conversion")

        for group in groups:
            first, last = group[0], group[-1]

            # compute turn type at vertex
            tail, mid1 = Edge(last.triangle, ccw(last.side)).segment
            # print(tail.x, tail.y, ";", mid1.x, mid1.y)
            mid2, head = Edge(first.triangle, cw(first.side)).segment
            # print(mid2.x, mid2.y, ";", head.x, head.y)
            assert mid1 is mid2
            turn = orient2d((tail.x, tail.y), (mid1.x, mid1.y),
                            (head.x, head.y))
            #    left : + [ = ccw ]
            #     straight : 0.
            #     right : - [ = cw ]

            if turn < 0:
                turn_type = "RIGHT - REFLEX"
            elif turn > 0:
                turn_type = "LEFT - CONVEX"
            else:
                turn_type = "STRAIGHT"
            # print(turn_type)
            # print("--")

            # FIXME: duplicate <-> each KTriangle has wavefront!
            right = triangle2ktriangle[first.triangle].wavefront_support_lines[
                cw(first.side)]
            left = triangle2ktriangle[last.triangle].wavefront_support_lines[
                ccw(last.side)]

            assert left is not None
            assert right is not None
            intersector = WaveFrontIntersector(left, right)

            bi = intersector.get_bisector()
            # print("")
            # print(v, id(v), v.info)
            # print(left)
            # print(right)
            #            print("=-=-=")
            #            print(id(first.triangle))
            #            print(first_line)
            #            print("")
            #            print(id(last.triangle))
            #            print(last_line)
            #            print("=-=-=")
            #            print("")

            #             bi = None
            #             left_translated = left.translated(left.w)
            #             right_translated = right.translated(right.w)
            #             intersect = Intersector(left_translated, right_translated)
            #             #
            #             # == 3 possible outcomes in 2D: ==
            #             #
            #             # 0. overlapping lines - always intersecting in a line
            #             # 1. crossing - point2
            #             # 2. parallel - no intersection
            #             #
            #             if intersect.intersection_type() == IntersectionResult.LINE:
            #                 bi = tuple(left.w)
            #             elif intersect.intersection_type() == IntersectionResult.POINT:
            # #                velocity
            #                 bi = make_vector(end=intersect.result, start=(v.x, v.y))
            #             elif intersect.intersection_type() == IntersectionResult.NO_INTERSECTION:
            #                 # print('no intersection, parallel wavefronts - not overlapping?')
            #                 logging.warning('no intersection, parallel wavefronts - not overlapping?')
            #                 bi = tuple(left.w)
            #             assert bi is not None

            ur = right.line  # unit_vectors[first.triangle][cw(first.side)]
            ul = left.line  # unit_vectors[last.triangle][ccw(last.side)]
            #            bi = bisector(ul, ur)

            #             print v, ul, ur, bi
            #             for edge in group:
            #                 print "", edge.triangle
            ct += 1
            kv = KineticVertex()
            kv.turn = turn_type
            kv.info = ct  ### "{}-{}".format(ct, turn)
            kv.origin = (v.x, v.y)
            kv.velocity = bi
            kv.start_node = nodes[v]
            kv.starts_at = 0
            #            kv.ul = first_line # ul # FIXME: point to original Line2 ?
            #            kv.ur = last_line # ur

            kv.ul = ul
            kv.ur = ur

            kv.wfl = left
            kv.wfr = right

            # print("    {}".format(kv.origin) )
            # print("    {}".format(kv.wfl) )
            # print("    {}".format(kv.wfr) )

            for edge in group:
                ktriangle = triangle2ktriangle[edge.triangle]
                ktriangle.vertices[edge.side] = kv
                kv.internal = ktriangle.internal
            kvertices.append(kv)
            # link vertices to each other in circular list
            link_around.append(
                ((last.triangle, cw(last.side)), kv, (first.triangle,
                                                      ccw(first.side))))

# #             print ""
#         it = StarEdgeIterator(v)
#         around = [e for e in it]
# #             with open("/tmp/vertexit.wkt", "w") as fh:
# #                 output_triangles([e.triangle for e in around], fh)
#
#         constraints = []
#         for i, e in enumerate(around):
#             if e.triangle.constrained[cw(e.side)]:
#                 constraints.append(i)
#
#         # FIXME:
#         # Check here how many constrained edges we have outgoing of
#         # this vertex.
#         #
#         # In case 0: degenerate case, should not happen
#         # In case 1: we should make two kvertices vertices
#         #
#         # We do not handle this properly at this moment.
#         #
#         # In case 2 or more the following is fine.
#         if len(constraints) == 0:
#             raise ValueError("Singular point found")
#         else:
#             # rotate the list of around triangles,
#             # so that we start with a triangle that has a constraint
#             # side
#             if constraints[0] != 0:
#                 shift = -constraints[0]  # how much to rotate
#                 d = deque(around)
#                 d.rotate(shift)
#                 around = list(d)
#                 # also update which triangles have a constraint edge
#                 constraints = [idx + shift for idx in constraints]
#
#             # make two bisectors at a terminal vertex
#             if len(constraints) == 1:
#
#                 assert constraints[0] == 0
#                 edge = around[0]
#                 start, end = v, edge.triangle.vertices[ccw(edge.side)]
#                 vec = normalize((end.x - start.x, end.y - start.y))
#                 # FIXME: Replace perp with rotate90cw / rotate90ccw
#
#                 # from segment over terminal vertex to this kinetic vertex,
#                 # turns right
#                 # (first bisector when going ccw at end)
#                 p2 = tuple(map(add, start, rotate90ccw(vec)))
#                 p1 = v
#                 p0 = tuple(map(add, start, rotate90ccw(rotate90ccw(vec))))
#                 bi = bisector(p0, p1, p2)
# #                 print >> bisector_fh,
# ##"LINESTRING({0[0]} {0[1]}, {1[0]} {1[1]})".format(
# ##p1, map(add, p1, bi))
# #                     print nodes[v]
#
#                 kvA = KineticVertex()
#                 kvA.origin = (p1.x, p1.y)
#                 kvA.velocity = bi
#                 kvA.start_node = nodes[v]
#                 kvA.starts_at = 0
#                 kvertices.append(kvA)
#
#                 # from segment to this vertex, turns left
#                 # second bisector when going ccw at end
#                 p2 = tuple(map(add, start, rotate90ccw(rotate90ccw(vec))))
#                 p1 = v
#                 p0 = tuple(
#                     map(add, start, rotate90ccw(rotate90ccw(rotate90ccw(
#                 bi = bisector(p0, p1, p2)
# #                 print >> bisector_fh,
# "LINESTRING({0[0]} {0[1]}, {1[0]} {1[1]})".format(p1, map(add, p1, bi))
#                 # FIXME insert additional triangle at this side
# #                     print nodes[v]
#
#                 kvB = KineticVertex()
#                 kvB.origin = (p1.x, p1.y)
#                 kvB.velocity = bi
#                 kvB.start_node = nodes[v]
#                 kvB.starts_at = 0
#                 kvertices.append(kvB)
#
#                 groups = [around]
#
#                 split_idx = find_overlapping_triangle(around)
#
# #                     print split_idx
# #                     print len(around)
#                 # determine which triangles get an incidence with the
#                 # first and which with the second kvertices vertex
#
#                 # first go with kvA
#                 # second go with kvB
#                 first, second = around[:split_idx], around[split_idx + 1:]
# #                     print "first ", first
# #                     print "second", second
#                 mid = around[split_idx]
# #                     print "mid   ", mid
#
#                 # go with kvA
#                 for e in first:
#                     ktriangle = triangle2ktriangle[e.triangle]
#                     ktriangle.vertices[e.side] = kvA
#                 # go with kvB
#                 for e in second:
#                     ktriangle = triangle2ktriangle[e.triangle]
#                     ktriangle.vertices[e.side] = kvB
#
#                 # for the mid triangle it depends where it should go
#                 # based on adding an additional kvertices triangle into
#                 # the triangulation here...
#
#                 # FIXME: the placement of points A and B should be
#                 # dependent on the distance between A and L or A and F
#                 # to not get False negatives out of the is_quad
#                 # classification
#                 triangle = mid.triangle
# #                     print "PIVOT POINT INDEX", mid.side
#                 first_leg = ccw(mid.side)
#                 last_leg = cw(mid.side)
#                 L = triangle.vertices[last_leg]
#                 F = triangle.vertices[first_leg]
#
#                 A = map(add, kvA.origin, kvA.velocity)
#                 B = map(add, kvB.origin, kvB.velocity)
#                 O = triangle.vertices[mid.side]
# # print "first", first_leg,"|" , F, "(cw)", "last", last_leg, "|" ,L,
# # "(ccw) around", O
#
#                 first_quad = [O, A, F, B, O]
#                 last_quad = [O, A, L, B, O]
#                 first_ok = is_quad(first_quad)
#                 last_ok = is_quad(last_quad)
#
#                 # if first is True and second False
#                 # assign ktriangles triangle to kvA/kvB and the corner to kvB
#
#                 # if both not ok, probably at convex hull overlapping with
#                 # infinite triangle
#                 # only, so take guess and use the first leg
#                 if first_ok or (not first_ok and not last_ok):
#                     ktriangle = triangle2ktriangle[mid.triangle]
#                     ktriangle.vertices[mid.side] = kvB
#
#                     knew = KineticTriangle()
#                     knew.vertices[0] = kvB
#                     knew.vertices[1] = kvA
#                     knew.vertices[2] = None
#
#                     X, Y = mid.triangle, mid.triangle.neighbours[
#                         ccw(first_leg)]
#                     sideX = X.neighbours.index(Y)
#                     sideY = Y.neighbours.index(X)
#
#                     key = tuple(sorted([X, Y]))
#                     if key not in one_ktri_between:
#                         one_ktri_between[key] = []
#                     one_ktri_between[key].append(
#                         (knew,
#                          triangle2ktriangle[Y],
#                             sideY,
#                             triangle2ktriangle[X],
#                             sideX))
#
#                 # if first is false and second True
#                 # assign ktriangles triangle to kvA/kvB and the corner to kvA
#                 elif last_ok:
#                     ktriangle = triangle2ktriangle[mid.triangle]
#                     ktriangle.vertices[mid.side] = kvA
#
#                     knew = KineticTriangle()
#                     knew.vertices[0] = kvB
#                     knew.vertices[1] = kvA
#                     knew.vertices[2] = None
# #                         ktri_no_apex.append(knew)
#
#                     X = mid.triangle
#                     Y = mid.triangle.neighbours[cw(last_leg)]
#                     sideX = X.neighbours.index(Y)
#                     sideY = Y.neighbours.index(X)
#
#                     key = tuple(sorted([X, Y]))
#                     if key not in one_ktri_between:
#                         one_ktri_between[key] = []
#                     one_ktri_between[key].append(
#                         (knew,
#                          triangle2ktriangle[X],
#                             sideX,
#                             triangle2ktriangle[Y],
#                             sideY))
#
#                 # add 2 entries to link_around list
#                 # one for kvA and one for kvB
#                 # link kvA and kvB to point to each other directly
#                 kvA.left = kvB, 0
#                 link_around.append(
#                     (None, kvA, (first[0].triangle, ccw(first[0].side))))
#                 kvB.right = kvA, 0
#                 link_around.append(
#                     ((second[-1].triangle, cw(second[-1].side)), kvB, None))
#
#             # make bisectors
#             else:
#
#                 assert len(constraints) >= 2
#                 # group the triangles around the vertex
#                 constraints.append(len(around))
#                 groups = []
#                 for lo, hi in zip(constraints[:-1], constraints[1:]):
#                     groups.append(around[lo:hi])
#
#                 # per group make a bisector and KineticVertex
#                 for group in groups:
#                     begin, end = group[0], group[-1]
#                     p2 = begin.triangle.vertices[
#                         ccw(begin.side)]  # the cw vertex
#                     p1 = v
#                     # the ccw vertex
#                     p0 = end.triangle.vertices[cw(end.side)]
#                     bi = bisector(p0, p1, p2)
# #                     print >> bisector_fh,
# "LINESTRING({0[0]} {0[1]}, {1[0]} {1[1]})".format(p1, map(add, p1, bi))
#                     kv = KineticVertex()
#                     kv.origin = (p1.x, p1.y)
#                     kv.velocity = bi
#                     kv.start_node = nodes[v]
#                     kv.starts_at = 0
#                     for edge in group:
#                         ktriangle = triangle2ktriangle[edge.triangle]
#                         ktriangle.vertices[edge.side] = kv
#                     kvertices.append(kv)
#                     # link vertices to each other in circular list
#                     link_around.append(((end.triangle, cw(end.side)),
# kv, (begin.triangle, ccw(begin.side))))

# link vertices in circular list
    for left, kv, right in link_around:  # left is cw, right is ccw
        assert left is not None
        assert right is not None
        # if left is not None:
        # left
        cwv = triangle2ktriangle[left[0]].vertices[left[1]]
        kv.left = cwv, 0

        # if right is not None:
        ccwv = triangle2ktriangle[right[0]].vertices[right[1]]
        kv.right = ccwv, 0

    for left, kv, right in link_around:  # left is cw, right is ccw
        assert kv.left.wfr is kv.wfl, "{} vs\n {}".format(kv.left.wfr, kv.wfl)
        assert kv.wfr is kv.right.wfl
        assert kv.is_stopped == False

    # -- copy infinite vertices into the kinetic triangles
    # make dico of infinite vertices (lookup by coordinate value)
    infinites = {}
    for t in triangle2ktriangle:
        for i, v in enumerate(t.vertices):
            #             print(t, t.vertices)
            if v is not None and not v.is_finite:
                infv = InfiniteVertex()
                infv.origin = (v[0], v[1])
                infinites[(v[0], v[1])] = infv
    assert len(infinites) == 3
    # link infinite triangles to the infinite vertex
    for (t, kt) in triangle2ktriangle.items():
        for i, v in enumerate(t.vertices):
            if v is not None and not v.is_finite:
                kt.vertices[i] = infinites[(v[0], v[1])]


#     # deal with added kinetic triangles at terminal vertices
#     for val in one_ktri_between.itervalues():
#         if len(val) == 1:
#             knew, x, side_x, y, side_y, = val[0]
#             knew.neighbours[0] = x
#             knew.neighbours[1] = y
#             knew.neighbours[2] = None
#             x.neighbours[side_x] = knew
#             y.neighbours[side_y] = knew
#             knew.vertices[2] = x.vertices[ccw(side_x)]
#             ktriangles.append(knew)
#         elif len(val) == 2:
#             for i, v in enumerate(val):
#                 # the other triangle between these 2 terminal vertices
#                 # is the first value of the other tuple
#                 kother = val[(i + 1) % 2][0]
#                 knew, x, side_x, y, side_y, = v
#                 # link to each other and to neighbour x
#                 knew.neighbours[0] = x
#                 knew.neighbours[1] = kother
#                 knew.neighbours[2] = None
#                 x.neighbours[side_x] = knew
#                 y.neighbours[side_y] = kother
#                 # link to vertex
#                 knew.vertices[2] = x.vertices[ccw(side_x)]
#                 ktriangles.append(knew)
#         else:
#             raise ValueError(
#                 "Unexpected # kinetic triangles at terminal vertex")

# there are 3 infinite triangles that are supposed to be removed
# these triangles were already stored in the unwanted list
    remove = []
    for kt in ktriangles:
        if [isinstance(v, InfiniteVertex)
                for v in kt.vertices].count(True) == 2:
            remove.append(kt)
    assert len(remove) == 3
    assert len(unwanted) == 3
    assert remove == unwanted
    # remove the 3 unwanted triangles and link their neighbours together
    link = []
    for kt in unwanted:
        v = kt.vertices[kt.neighbours.index(None)]
        assert isinstance(v, KineticVertex)
        neighbour_cw = rotate_until_not_in_candidates(kt, v, cw, unwanted)
        neighbour_ccw = rotate_until_not_in_candidates(kt, v, ccw, unwanted)
        side_cw = ccw(neighbour_cw.vertices.index(v))
        side_ccw = cw(neighbour_ccw.vertices.index(v))
        link.append((neighbour_cw, side_cw, neighbour_ccw))
        link.append((neighbour_ccw, side_ccw, neighbour_cw))
    for item in link:
        ngb, side, new_ngb, = item
        ngb.neighbours[side] = new_ngb
    for kt in unwanted:
        kt.vertices = [None, None, None]
        kt.neighbours = [None, None, None]
        ktriangles.remove(kt)
    # replace the infinite vertices by one point in the center of the PSLG
    # (this could be the origin (0,0) if we would scale input to [-1,1] range
    for kt in ktriangles:
        for i, v in enumerate(kt.vertices):
            if isinstance(v, InfiniteVertex):
                kt.vertices[i] = centroid
    assert check_ktriangles(ktriangles)
    ktriangles.sort(
        key=lambda t: (t.vertices[0].origin[1], t.vertices[0].origin[0]))
    skel.sk_nodes = list(nodes.values())
    skel.triangles = ktriangles
    skel.vertices = kvertices
    # INITIALIZATION FINISHES HERE

    # with open('/tmp/lines.wkt', 'w') as fh:
    #     xaxis = Line2.from_points( (0, 0), (1, 0) )
    #     yaxis = Line2.from_points( (0, 0), (0, 1) )

    #     fh.write("wkt")
    #     fh.write("\n")

    #     fh.write(as_wkt(*xaxis.visualize()))
    #     fh.write("\n")

    #     fh.write(as_wkt(*yaxis.visualize()))
    #     fh.write("\n")

    #     for kt in skel.triangles:
    #         for line in filter(lambda x: x is not None, kt.wavefront_support_lines):
    #             fh.write(as_wkt(*line.visualize()))
    #             fh.write("\n")

    return skel
示例#12
0
from grassfire.primitives import KineticTriangle, KineticVertex, Event, Skeleton
from grassfire.events import handle_split_event

triangles = {}
### 140003451728400
k = KineticTriangle()
V = []
v = KineticVertex()
v.origin = (6.0, 0.0)
v.velocity = (0.8611874208078342, -0.9999999999999998)
V.append(v)
v = KineticVertex()
v.origin = (4.0, 0.0)
v.velocity = (-0.9049875621120889, -0.9999999999999999)
V.append(v)
v = KineticVertex()
v.origin = (5.061111111111111, 2.5555555555555554)
v.velocity = (0, 0)
V.append(v)
k.vertices = V
triangles[140003451728400] = k
### 140003451728464
k = KineticTriangle()
V = []
v = KineticVertex()
v.origin = (6.0, 0.0)
v.velocity = (-0.8611874208078343, 1.0)
V.append(v)
v = KineticVertex()
v.origin = (3.8, 2.0)
v.velocity = (0.5885834574042905, 4.164041047077979)
示例#13
0
 def setUp(self):
     self.triangles = {}
     triangles = self.triangles
     ### 139643876356304
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (4.0, 0.0)
     v.velocity = (-0.9049875621120889, -0.9999999999999999)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.0, 0.0)
     v.velocity = (0.6770329614269006, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     k.vertices = V
     triangles[139643876356304] = k
     ### 139643876356368
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (3.0, 0.0)
     v.velocity = (0.6770329614269006, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (4.0, 0.0)
     v.velocity = (-0.9049875621120889, -0.9999999999999999)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.8, 2.0)
     v.velocity = (-0.5885834574042905, -4.164041047077979)
     V.append(v)
     k.vertices = V
     triangles[139643876356368] = k
     ### 139643876356432
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (3.8, 2.0)
     v.velocity = (0.5885834574042905, 4.164041047077979)
     V.append(v)
     v = KineticVertex()
     v.origin = (0.0, 0.0)
     v.velocity = (1.0, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.0, 0.0)
     v.velocity = (-0.6770329614269007, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876356432] = k
     ### 139643876356496
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (3.8, 2.0)
     v.velocity = (0.5885834574042905, 4.164041047077979)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (0.0, 0.0)
     v.velocity = (1.0, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876356496] = k
     ### 139643876356560
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (3.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.8, 2.0)
     v.velocity = (0.5885834574042905, 4.164041047077979)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     k.vertices = V
     triangles[139643876356560] = k
     ### 139643876356624
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (6.0, 5.0)
     v.velocity = (-0.7807764064044151, -1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     k.vertices = V
     triangles[139643876356624] = k
     ### 139643876356688
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (3.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.0, 5.0)
     v.velocity = (-0.7807764064044151, -1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (4.0, 5.0)
     v.velocity = (0.7807764064044151, -1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876356688] = k
     ### 139643876356752
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (3.5, 3.0)
     v.velocity = (0.0, 4.1231056256176615)
     V.append(v)
     v = KineticVertex()
     v.origin = (4.0, 5.0)
     v.velocity = (-0.7807764064044151, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.0, 5.0)
     v.velocity = (0.7807764064044151, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876356752] = k
     ### 139643876356816
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (0.0, 5.0)
     v.velocity = (1.0, -1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.0, 5.0)
     v.velocity = (-0.7807764064044151, -1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876356816] = k
     ### 139643876356880
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (0.0, 0.0)
     v.velocity = (1.0, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (0.0, 5.0)
     v.velocity = (1.0, -1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876356880] = k
     ### 139643876356944
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (0.0, 5.0)
     v.velocity = (-0.9999999999999998, 0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (0.0, 0.0)
     v.velocity = (-0.9999999999999998, -0.9999999999999998)
     V.append(v)
     k.vertices = V
     triangles[139643876356944] = k
     ### 139643876357072
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (0.0, 5.0)
     v.velocity = (-0.9999999999999998, 0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.0, 5.0)
     v.velocity = (0.7807764064044151, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876357072] = k
     ### 139643876357136
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.0, 5.0)
     v.velocity = (0.7807764064044151, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (4.0, 5.0)
     v.velocity = (-0.7807764064044151, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876357136] = k
     ### 139643876357200
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (4.0, 5.0)
     v.velocity = (-0.7807764064044151, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.0, 5.0)
     v.velocity = (0.7807764064044151, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876357200] = k
     ### 139643876357264
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.0, 5.0)
     v.velocity = (0.7807764064044151, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (7.0, 5.0)
     v.velocity = (-0.7807764064044151, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876357264] = k
     ### 139643876357328
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (10.0, 5.0)
     v.velocity = (0.9999999999999998, 0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (7.0, 5.0)
     v.velocity = (-0.7807764064044151, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876357328] = k
     ### 139643876357456
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (0.9999999999999998, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (10.0, 5.0)
     v.velocity = (0.9999999999999998, 0.9999999999999998)
     V.append(v)
     k.vertices = V
     triangles[139643876357456] = k
     ### 139643876357520
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (7.0, 0.0)
     v.velocity = (-0.7094810050208543, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (0.9999999999999998, -0.9999999999999998)
     V.append(v)
     k.vertices = V
     triangles[139643876357520] = k
     ### 139643876357584
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (6.0, 0.0)
     v.velocity = (0.8611874208078342, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (7.0, 0.0)
     v.velocity = (-0.7094810050208543, -0.9999999999999998)
     V.append(v)
     k.vertices = V
     triangles[139643876357584] = k
     ### 139643876357648
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (4.0, 0.0)
     v.velocity = (-0.9049875621120889, -0.9999999999999999)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.0, 0.0)
     v.velocity = (0.8611874208078342, -0.9999999999999998)
     V.append(v)
     k.vertices = V
     triangles[139643876357648] = k
     ### 139643876357712
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (6.0, 0.0)
     v.velocity = (-0.8611874208078343, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.8, 2.0)
     v.velocity = (0.5885834574042905, 4.164041047077979)
     V.append(v)
     v = KineticVertex()
     v.origin = (4.0, 0.0)
     v.velocity = (0.9049875621120889, 0.9999999999999999)
     V.append(v)
     k.vertices = V
     triangles[139643876357712] = k
     ### 139643876357776
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (6.3, 2.0)
     v.velocity = (-0.3899868930592274, 4.141336851657371)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.8, 2.0)
     v.velocity = (0.5885834574042905, 4.164041047077979)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.0, 0.0)
     v.velocity = (-0.8611874208078343, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876357776] = k
     ### 139643876357840
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (6.3, 2.0)
     v.velocity = (-0.3899868930592274, 4.141336851657371)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (3.8, 2.0)
     v.velocity = (0.5885834574042905, 4.164041047077979)
     V.append(v)
     k.vertices = V
     triangles[139643876357840] = k
     ### 139643876357904
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (-1.0, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.3, 2.0)
     v.velocity = (-0.3899868930592274, 4.141336851657371)
     V.append(v)
     k.vertices = V
     triangles[139643876357904] = k
     ### 139643876357968
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (10.0, 5.0)
     v.velocity = (-1.0, -1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (-1.0, 1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876357968] = k
     ### 139643876358032
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (6.5, 3.0)
     v.velocity = (-0.0, -4.123105625617657)
     V.append(v)
     v = KineticVertex()
     v.origin = (10.0, 5.0)
     v.velocity = (-1.0, -1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (7.0, 5.0)
     v.velocity = (0.7807764064044151, -1.0)
     V.append(v)
     k.vertices = V
     triangles[139643876358032] = k
     ### 139643876358096
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (7.0, 5.0)
     v.velocity = (-0.7807764064044151, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.0, 5.0)
     v.velocity = (0.7807764064044151, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.5, 3.0)
     v.velocity = (0.0, 4.1231056256176615)
     V.append(v)
     k.vertices = V
     triangles[139643876358096] = k
     ### 139643876358160
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (-1.0, 1.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.3, 2.0)
     v.velocity = (-0.3899868930592274, 4.141336851657371)
     V.append(v)
     v = KineticVertex()
     v.origin = (7.0, 0.0)
     v.velocity = (0.7094810050208544, 0.9999999999999999)
     V.append(v)
     k.vertices = V
     triangles[139643876358160] = k
     ### 139643876358224
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (6.3, 2.0)
     v.velocity = (0.38998689305922796, -4.141336851657377)
     V.append(v)
     v = KineticVertex()
     v.origin = (6.0, 0.0)
     v.velocity = (0.8611874208078342, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (7.0, 0.0)
     v.velocity = (-0.7094810050208543, -0.9999999999999998)
     V.append(v)
     k.vertices = V
     triangles[139643876358224] = k
     ### 139643876358288
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (3.0, 0.0)
     v.velocity = (0.6770329614269006, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (0.0, 0.0)
     v.velocity = (-0.9999999999999998, -0.9999999999999998)
     V.append(v)
     v = KineticVertex()
     v.origin = (5.00625, 2.5)
     v.velocity = (0, 0)
     V.append(v)
     k.vertices = V
     triangles[139643876358288] = k
     ### neighbour relationships
     n = [
         triangles[139643876358288], triangles[139643876357648],
         triangles[139643876356368]
     ]
     triangles[139643876356304].neighbours = n
     n = [None, None, triangles[139643876356304]]
     triangles[139643876356368].neighbours = n
     n = [None, None, triangles[139643876356496]]
     triangles[139643876356432].neighbours = n
     n = [
         triangles[139643876356880], triangles[139643876356432],
         triangles[139643876356560]
     ]
     triangles[139643876356496].neighbours = n
     n = [
         triangles[139643876357840], triangles[139643876356624],
         triangles[139643876356496]
     ]
     triangles[139643876356560].neighbours = n
     n = [triangles[139643876356560], None, triangles[139643876356688]]
     triangles[139643876356624].neighbours = n
     n = [None, None, triangles[139643876356624]]
     triangles[139643876356688].neighbours = n
     n = [triangles[139643876357136], None, None]
     triangles[139643876356752].neighbours = n
     n = [None, None, triangles[139643876356880]]
     triangles[139643876356816].neighbours = n
     n = [triangles[139643876356816], None, triangles[139643876356496]]
     triangles[139643876356880].neighbours = n
     n = [triangles[139643876358288], None, triangles[139643876357072]]
     triangles[139643876356944].neighbours = n
     n = [None, triangles[139643876357136], triangles[139643876356944]]
     triangles[139643876357072].neighbours = n
     n = [
         triangles[139643876356752], triangles[139643876357200],
         triangles[139643876357072]
     ]
     triangles[139643876357136].neighbours = n
     n = [None, triangles[139643876357264], triangles[139643876357136]]
     triangles[139643876357200].neighbours = n
     n = [
         triangles[139643876358096], triangles[139643876357328],
         triangles[139643876357200]
     ]
     triangles[139643876357264].neighbours = n
     n = [triangles[139643876357264], None, triangles[139643876357456]]
     triangles[139643876357328].neighbours = n
     n = [triangles[139643876357328], None, triangles[139643876357520]]
     triangles[139643876357456].neighbours = n
     n = [triangles[139643876357456], None, triangles[139643876357584]]
     triangles[139643876357520].neighbours = n
     n = [
         triangles[139643876357520], triangles[139643876358224],
         triangles[139643876357648]
     ]
     triangles[139643876357584].neighbours = n
     n = [triangles[139643876357584], None, triangles[139643876356304]]
     triangles[139643876357648].neighbours = n
     n = [None, None, triangles[139643876357776]]
     triangles[139643876357712].neighbours = n
     n = [triangles[139643876357712], None, triangles[139643876357840]]
     triangles[139643876357776].neighbours = n
     n = [
         triangles[139643876356560], triangles[139643876357776],
         triangles[139643876357904]
     ]
     triangles[139643876357840].neighbours = n
     n = [
         triangles[139643876357840], triangles[139643876358160],
         triangles[139643876357968]
     ]
     triangles[139643876357904].neighbours = n
     n = [triangles[139643876357904], None, triangles[139643876358032]]
     triangles[139643876357968].neighbours = n
     n = [None, None, triangles[139643876357968]]
     triangles[139643876358032].neighbours = n
     n = [None, None, triangles[139643876357264]]
     triangles[139643876358096].neighbours = n
     n = [None, None, triangles[139643876357904]]
     triangles[139643876358160].neighbours = n
     n = [triangles[139643876357584], None, None]
     triangles[139643876358224].neighbours = n
     n = [triangles[139643876356944], triangles[139643876356304], None]
     triangles[139643876358288].neighbours = n
示例#14
0
 def setUp(self):
     """Initialize 3 infinite triangles and 1 finite 3-triangle.
     """
     self.triangles = {}
     triangles = self.triangles
     ### 139742234433616
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (2.0, 0.0)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (-2.0, -8.0)
     v.velocity = (-1.0, -1.8685170918213299)
     V.append(v)
     v = KineticVertex()
     v.origin = (-2.0, 8.0)
     v.velocity = (-1.0, 1.8685170918213299)
     V.append(v)
     k.vertices = V
     triangles[139742234433616] = k
     ### 139742234433872
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (2.0, 0.0)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (-2.0, 8.0)
     v.velocity = (-1.0, 1.8685170918213299)
     V.append(v)
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (1.8027756377319946, -0.0)
     V.append(v)
     k.vertices = V
     triangles[139742234433872] = k
     ### 139742234434000
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (-2.0, -8.0)
     v.velocity = (-1.0, -1.8685170918213299)
     V.append(v)
     v = KineticVertex()
     v.origin = (2.0, 0.0)
     v.velocity = (0, 0)
     V.append(v)
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (1.8027756377319946, -0.0)
     V.append(v)
     k.vertices = V
     triangles[139742234434000] = k
     ### 139742234434064
     k = KineticTriangle()
     V = []
     v = KineticVertex()
     v.origin = (10.0, 0.0)
     v.velocity = (-1.802775637731995, 0.0)
     V.append(v)
     v = KineticVertex()
     v.origin = (-2.0, 8.0)
     v.velocity = (1.0, -1.8685170918213299)
     V.append(v)
     v = KineticVertex()
     v.origin = (-2.0, -8.0)
     v.velocity = (1.0, 1.8685170918213299)
     V.append(v)
     k.vertices = V
     triangles[139742234434064] = k
     ### neighbours
     n = None, triangles[139742234433872], triangles[139742234434000]
     triangles[139742234433616].neighbours = list(n)
     n = None, triangles[139742234434000], triangles[139742234433616]
     triangles[139742234433872].neighbours = list(n)
     n = triangles[139742234433872], None, triangles[139742234433616]
     triangles[139742234434000].neighbours = list(n)
     n = None, None, None
     triangles[139742234434064].neighbours = list(n)
示例#15
0
    def setUp(self):
        self.triangles = {}
        triangles = self.triangles
        ### 139708485588816
        k = KineticTriangle()
        V = []
        v = KineticVertex()
        v.origin = (0.0, 1.0)
        v.velocity = (0, 0)
        V.append(v)
        v = KineticVertex()
        v.origin = (0.0, -1.0)
        v.velocity = (-0.0, -1.414213562373095)
        V.append(v)
        v = KineticVertex()
        v.origin = (-1.0, 0.0)
        v.velocity = (-1.0855388459943132, -0.3286747163787818)
        V.append(v)
        k.vertices = V
        triangles[139708485588816] = k
        ### 139708485588880
        k = KineticTriangle()
        V = []
        v = KineticVertex()
        v.origin = (0.0, 5.0)
        v.velocity = (-0.0, 5.099019513592779)
        V.append(v)
        v = KineticVertex()
        v.origin = (0.0, 1.0)
        v.velocity = (0, 0)
        V.append(v)
        v = KineticVertex()
        v.origin = (-1.0, 0.0)
        v.velocity = (-1.0855388459943132, -0.3286747163787818)
        V.append(v)
        k.vertices = V
        triangles[139708485588880] = k
        ### 139708485589072
        k = KineticTriangle()
        V = []
        v = KineticVertex()
        v.origin = (0.0, 1.0)
        v.velocity = (0, 0)
        V.append(v)
        v = KineticVertex()
        v.origin = (0.0, 5.0)
        v.velocity = (-0.0, 5.099019513592779)
        V.append(v)
        v = KineticVertex()
        v.origin = (1.0, 0.0)
        v.velocity = (1.0855388459943134, -0.32867471637878193)
        V.append(v)
        k.vertices = V
        triangles[139708485589072] = k
        ### 139708485589136
        k = KineticTriangle()
        V = []
        v = KineticVertex()
        v.origin = (0.0, -1.0)
        v.velocity = (-0.0, -1.414213562373095)
        V.append(v)
        v = KineticVertex()
        v.origin = (0.0, 1.0)
        v.velocity = (0, 0)
        V.append(v)
        v = KineticVertex()
        v.origin = (1.0, 0.0)
        v.velocity = (1.0855388459943134, -0.32867471637878193)
        V.append(v)
        k.vertices = V
        triangles[139708485589136] = k
        ### 139708485589200 <<< this is the bottom internal
        k = KineticTriangle()
        V = []
        v = KineticVertex()
        v.origin = (1.0, 0.0)
        v.velocity = (-1.0855388459943136, 0.328674716378782)
        V.append(v)
        v = KineticVertex()
        v.origin = (-1.0, 0.0)
        v.velocity = (1.0855388459943134, 0.32867471637878193)
        V.append(v)
        v = KineticVertex()
        v.origin = (0.0, -1.0)
        v.velocity = (0.0, 1.4142135623730951)
        V.append(v)
        k.vertices = V
        triangles[139708485589200] = k
        ### 139708485589264 <<< this is the top internal
        k = KineticTriangle()
        V = []
        v = KineticVertex()
        v.origin = (-1.0, 0.0)
        v.velocity = (1.0855388459943134, 0.32867471637878193)
        V.append(v)
        v = KineticVertex()
        v.origin = (1.0, 0.0)
        v.velocity = (-1.0855388459943136, 0.328674716378782)
        V.append(v)
        v = KineticVertex()
        v.origin = (0.0, 5.0)
        v.velocity = (0.0, -5.0990195135927845)
        V.append(v)
        k.vertices = V
        triangles[139708485589264] = k

        ### neighbour relationships
        n = [None, triangles[139708485588880], triangles[139708485589136]]
        triangles[139708485588816].neighbours = n
        n = [triangles[139708485588816], None, triangles[139708485589072]]
        triangles[139708485588880].neighbours = n
        n = [None, triangles[139708485589136], triangles[139708485588880]]
        triangles[139708485589072].neighbours = n
        n = [triangles[139708485589072], None, triangles[139708485588816]]
        triangles[139708485589136].neighbours = n
        n = [None, None, triangles[139708485589264]]
        triangles[139708485589200].neighbours = n
        n = [None, None, triangles[139708485589200]]
        triangles[139708485589264].neighbours = n