Beispiel #1
0
    def show(self, context):
        """Show all the objects on screen."""
        for object in self.objects:
            object.center.showMotion(context)
            object.show(context)

        l = len(self.objects)
        for i in range(l):
            for j in range(i + 1, l):
                points = self.objects[i].abstract | self.objects[j].abstract
                if points != []:
                    self.objects[i].velocity *= 0
                    print(points)
                    l1 = Segment(*points[:2])
                    l1.color = mycolors.GREEN
                    l1.show(context)
                    p = l1.center
                    p.show(context, mode="cross", color=mycolors.RED)
                    c1 = self.objects[i].center.abstract
                    v = Vector.createFromTwoPoints(c1, p)
                    v.color = mycolors.GREEN
                    v.show(context, c1)
                    v.norm = 1
                    v.color = mycolors.BLUE
                    v.show(context, p)
                    v.showText(context, p, 'up')
                    v.rotate(math.pi / 2)
                    v.show(context, p)
                    v.showText(context, p, 'uo')
Beispiel #2
0
 def showBar(self, context, t, l):
     """Show the bar."""
     v = self.getVector()
     v *= l
     p = self(t)
     v.rotate(math.pi / 2)
     p1 = v(p)
     v.rotate(math.pi)
     p2 = v(p)
     s = Segment(p1, p2)
     s.color = self.color
     s.show(context)
e = 10e-10

surface = Surface(name="Segment Demonstration")

while surface.open:
    surface.check()
    surface.control()
    surface.clear()
    surface.show()

    p = Point(list(surface.point()))
    #if p in surface:
    s1.p2 = p
    if s1.crossSegment(s2):
        s1.color = mycolors.RED
        s2.color = mycolors.RED
    else:
        s1.color = mycolors.WHITE
        s2.color = mycolors.WHITE
    l1 = s1.getLine()
    l2 = s2.getLine()
    l1.color = mycolors.GREEN
    l1.width = 1
    l2.color = mycolors.GREEN
    l2.width = 1
    l1.show(surface)
    l2.show(surface)
    s1.show(surface)
    s2.show(surface)
    p1 = s1.center