from mycontext import Context from myabstract import Point from myinterpolation import PolynomialInterpolation context = Context() l = 10 points = [Point(2 * x, random.randint(-5, 5)) for x in range(l)] n = 0 ncp = 50 #number construction points while context.open: context.check() context.control() context.clear() context.show() Point.turnPoints([1 / 1000 for i in range(l)], points) p = PolynomialInterpolation(points) p.show(context) n = (n + 1) % (ncp + 1) p1 = b(n / ncp) p2 = t(n / ncp) #l1=Line.createFromTwoPoints(p1,p2) p1.show(context, color=mycolors.YELLOW, radius=0.1, fill=True) p2.show(context, color=mycolors.YELLOW, radius=0.1, fill=True) context.flip()
#Setting the console context.console.append([ "interpolation: " + str(interpolation), "trajectory: " + str(interpolation.trajectory) ]) #Main loop of the context while context.open: #Update the context context.check() context.control() context.clear() context.show() #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),