Beispiel #1
0
    def update(self, i):
        i = int(i)
        self.parent.matrix = np.array(
            (self.parent.i_vector, self.parent.j_vector,
             self.parent.k_vector)).T
        self.parent.plus_matrix = np.array(
            (self.parent.i_plus_vector, self.parent.j_plus_vector,
             self.parent.k_plus_vector)).T

        if self.canvasFigure != None:
            try:
                self.parent.quiver.remove()
                self.parent.plus_quiver.remove()
            except:
                print("do nothing")
            self.parent.matrix = (1 - self.parent.sigmoid(i)) * np.array(
                (self.parent.i_origin, self.parent.j_origin, self.parent.
                 k_origin)) + self.parent.sigmoid(i) * self.parent.matrix
            self.parent.plus_matrix = (1 - self.parent.sigmoid(i)) * np.array(
                (self.parent.i_origin, self.parent.j_origin, self.parent.
                 k_origin)) + self.parent.sigmoid(i) * self.parent.plus_matrix
        else:
            self.parent.matrix = np.array(
                (self.parent.i_origin, self.parent.j_origin,
                 self.parent.k_origin)) + self.parent.matrix
            self.parent.plus_matrix = np.array(
                (self.parent.i_origin, self.parent.j_origin,
                 self.parent.k_origin)) + self.parent.plus_matrix
        # Compute a matrix that is in the middle between the full transformation matrix and the identity

        self.parent.vector_location = np.array(
            (self.parent.matrix.dot(self.parent.i_origin),
             self.parent.matrix.dot(self.parent.j_origin),
             self.parent.matrix.dot(self.parent.k_origin))).T
        self.parent.quiver = self.parent.ax.quiver(
            0,
            0,
            0,
            self.parent.vector_location[0],
            self.parent.vector_location[1],
            self.parent.vector_location[2],
            length=1,
            color='r',
            arrow_length_ratio=0.1)
        self.parent.plus_vector_location = np.array(
            (self.parent.plus_matrix.dot(self.parent.i_origin),
             self.parent.plus_matrix.dot(self.parent.j_origin),
             self.parent.plus_matrix.dot(self.parent.k_origin))).T
        self.parent.plus_quiver = self.parent.ax.quiver(
            0,
            0,
            0,
            self.parent.plus_vector_location[0],
            self.parent.plus_vector_location[1],
            self.parent.plus_vector_location[2],
            length=1,
            color='y',
            arrow_length_ratio=0.1)
        # Set vector location - must transpose since we need U and V representing x and y components
        # of each vector respectively (without transposing, e  ach column represents each unit vector)
        self.parent.transform = np.array(
            [self.parent.matrix.dot(k) for k in self.parent.x])

        #ax.view_init((1 - self.parent.sigmoid(i)) * elevation, (1 - self.parent.sigmoid(i)) * angle)
        if self.canvasFigure != None:
            self.parent.scat._offsets3d = [
                self.parent.transform[:, 0], self.parent.transform[:, 1],
                self.parent.transform[:, 2]
            ]
            self.canvasFigure.draw()
            a = self.parent.plus_vector_location
            #with pylatex.config.active.change(indent=False):
            doc = Document()
            doc.packages.append(
                Package('geometry',
                        options=['paperwidth=6in', 'paperheight=2.5in']))
            section = Section('Linear Combination')

            subsection = Subsection('Using the dot product')
            V1 = np.transpose(np.array([[1, 1]]))
            M1 = np.array((self.parent.i_vector, self.parent.j_vector)).T
            math = Math(data=[
                Matrix(M1), 'dot',
                Matrix(V1), '=',
                Matrix(np.dot(M1, V1))
            ])
            subsection.append(math)
            section.append(subsection)

            subsection = Subsection('Using vector addition')
            V1 = np.array([self.parent.i_vector])
            V2 = np.array([self.parent.j_vector])
            math = Math(
                data=[Matrix(V1), '+',
                      Matrix(V2), '=',
                      Matrix(V1 + V2)])
            subsection.append(math)
            section.append(subsection)
            #doc.append(section)
            '''
            subsection = Subsection('Product')

            math = Math(data=['M', vec_name, '=', Matrix(M * a)])
            subsection.append(math)

            section.append(subsection)
            doc.append(section)
            '''
            doc.append(section)
            latex = doc.dumps_as_content()
            print(latex)
            self.strvar.set(latex)
            #self.strvar.set("\prod_{p\,\mathrm{prime}}\\frac1{1-p^{-s}} = \sum_{n=1}^\infty \\frac1{n^s}")
            self.on_latex()