예제 #1
0
 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))
예제 #2
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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
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)
예제 #8
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()
예제 #9
0
 def updateSample(self):
     """Update the sample."""
     t = Trajectory.createFromTuples(self.drawing)
     self.sample = t.sampleSegments(self.sample_number,
                                    include=self.include)
예제 #10
0
 def getTrajectory(self):
     """Return the trajectory associated with the points of the interpolation."""
     return Trajectory.createFromTuples(self.points)
예제 #11
0
 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)
예제 #12
0
 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)