def showModeConstruction(self): """Show the graphical components of the mode construction.""" if len(self.graph_drawing) > 1: t1 = Trajectory.createFromTuples(self.graph_drawing, segment_color=mycolors.GREEN) t2 = Trajectory.createFromTuples(self.graph_construction, segment_color=mycolors.BLUE) t3 = Trajectory.createFromTuples(self.graph_display, segment_color=mycolors.RED) t1.show(self.context) t2.show(self.context) t3.show(self.context) #self.showVectors([(0,0)]+self.graph_construction,self.vectors,mycolors.RED) self.context.text.append("time: " + str(self.time))
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)
def setConstructionMode(self): """Set the attributes before starting the construction mode.""" self.step = 0 self.display = [] t = Trajectory.createFromTuples(self.drawing) l = t.sample(self.sample_number) self.coefficients = Fourier.transform(l, self.coefficients_number)
def getTrajectory(self, t=1, split=1, **kwargs): """Return the trajectory of the point supposing it is not under any extern forces or restraints.""" points = [] for i in range(split): point = self.getNext(t) points.append(point) return Trajectory(points, **kwargs)
def showModeDrawing(self): """Show the graphical components of the mode drawing.""" if len(self.graph_drawing) > 1: t = Trajectory.createFromTuples(self.graph_drawing, segment_color=mycolors.GREEN) p = PolynomialInterpolation(self.graph_drawing, color=mycolors.RED) t.show(self.context) p.show(self.context, 200)
def interpolate(path, n=200): """Interpolate n points from the path.""" return Trajectory.createFromTuples(path).sample(n)
def trajectory(self): """Return the trajectory of the pendulum.""" return Trajectory.createFromTuples(self.points)
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()
def updateSample(self): """Update the sample.""" t = Trajectory.createFromTuples(self.drawing) self.sample = t.sampleSegments(self.sample_number, include=self.include)
def getTrajectory(self): """Return the trajectory associated with the points of the interpolation.""" return Trajectory.createFromTuples(self.points)
def showTrajectory(self, context, color=None): """Show the trajectory defined by the points of the interpolation.""" if not color: color = self.trajectory_color Trajectory.createFromTuples(self.points).show(context, color=color)
def showModeDisplay(self): """Show the graphical components of the mode display.""" t3 = Trajectory.createFromTuples(self.graph_display, segment_color=mycolors.RED) t3.show(self.context)