예제 #1
0
 def drawSample(self, index, color):
     """Draw the points that were sampled for the fourier transform."""
     t = Trajectory.createFromTuples(self.graphs[index])
     l = t.sampleSegments(self.sample_number, include=self.include)
     for e in l:
         p = Point(*e, radius=5, conversion=False)
         p.show(self.context)
예제 #2
0
    draw = Draw(window=real_window)
    window = Surface(
        draw)  #Create not a real window but a surface to display on screen.
    #window=Window(fullscreen=True)
    p1 = Point(1, -6)
    p2 = Point(-2, 4)
    p3 = Point(8, 5)
    p4 = Point(4, 4, color=(0, 255, 0))
    points = [p1, p3, p2, p4]
    f = Form([
        Point(random.randint(-10, 10), random.randint(-10, 10))
        for i in range(10)
    ])
    #f.show(window)
    f2 = f.getSparse()
    p1.show(window)
    p2.show(window)
    v1 = Vector(p2[0] - p1[0], p2[1] - p1[1], color=(255, 0, 0))

    while window.open:
        window.check()
        window.clear()
        window.draw.control()
        v1.rotate(0.1)
        v2 = v1 % (pi / 2)
        v2.color = GREEN
        v2.rotate(0.1)
        f2.rotate(0.1)
        center = f2.center()
        center.color = BLUE
        #center.radius=0.1
예제 #3
0
        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
    p1.show(surface, color=mycolors.RED)
    p.showText(surface, "p")
    p1.showText(surface, "p1")
    p2.showText(surface, "p2")
    p3.showText(surface, "p3")
    pl = l1.crossLine(l2)

    if pl:
        pl.show(surface, color=mycolors.RED, mode="cross", width=3)
        pl.showText(surface, "pl")
        print("in s1:", pl in s1)
        print("in s2:", pl in s2)

        v1 = Vector.createFromTwoPoints(s1.p1, pl)
        v1.color = mycolors.BLUE
        v2 = s1.getVector()
예제 #4
0
    #print(b.points[-1])
    #print(b(1))
    #print(b.segments[-1])
    #c=CurvedForm(points)
    n = 0
    ncp = 50  #number construction points

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

        Point.turnPoints([1 / 1000 for i in range(l)], points)
        n = (n + 1) % (ncp + 1)
        b.showConstruction(surface, n / ncp)

        t.show(surface)
        b.show(surface)

        p1 = b(n / ncp)
        p2 = Point(*t(n / ncp))

        #l1=Line.createFromTwoPoints(p1,p2)

        p1.show(surface, color=mycolors.YELLOW, radius=0.1, fill=True)
        p2.show(surface, color=mycolors.YELLOW, radius=0.1, fill=True)
        #l1.show(surface,color=mycolors.LIGHTGREY)

        surface.flip()
예제 #5
0
points = [Point(2 * x, random.randint(-5, 5)) for x in range(l)]
n = 0
ncp = 200  # number construction points

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

    n = (n + 1) % (ncp + 1)
    Point.turnPoints([1 / 1000 for i in range(l)], points)

    pi1 = PolynomialInterpolation(points)
    pi2 = PolynomialInterpolation(points)
    # pi2.createPolynomialsRespectingDistance()
    ti = Trajectory(points)
    p1 = Point(*pi1(n / ncp))
    p2 = Point(*pi2(n / ncp))
    p3 = Point(*ti(n / ncp))

    # l1=Line.createFromTwoPoints(p1,p2)

    pi1.show(context, n=200)
    ti.show(context)
    p1.show(context, color=mycolors.YELLOW, radius=0.1, fill=True)
    p2.show(context, color=mycolors.YELLOW, radius=0.1, fill=True)
    p3.show(context, color=mycolors.YELLOW, radius=0.1, fill=True)

    context.flip()
예제 #6
0
        #Update data components
        Point.turnPoints([1 / 100 / l for i in range(l)], pts)
        #trajectory=Trajectory(pts,mycolors.GREEN)
        interpolation = PolynomialInterpolation([p.components for p in pts])
        npts = interpolation.sample(200)  #Sample 200 points by interpolation

        #Additional features
        n = (n + 1) % (m + 1)
        c1 = interpolation(n / m)
        pt1 = Point(*c1,
                    radius=0.1,
                    color=mycolors.lighten(mycolors.RED, 2),
                    fill=True)
        c2 = interpolation.trajectory(n / m)
        pt2 = Point(*c2,
                    radius=0.1,
                    color=mycolors.lighten(mycolors.GREEN, 2),
                    fill=True)

        #Show visual components
        pt1.show(context)
        pt2.show(context)
        interpolation.show(context, 200)
        interpolation.showTrajectory(context)

        #Console
        context.showConsole()

        #Flip the context
        context.flip()