Пример #1
0
    def eDone(self, index):
        e = [[
            float(self.form.e1x.text()),
            float(self.form.e1y.text()),
            float(self.form.e1z.text())
        ],
             [
                 float(self.form.e2x.text()),
                 float(self.form.e2y.text()),
                 float(self.form.e2z.text())
             ],
             [
                 float(self.form.e3x.text()),
                 float(self.form.e3y.text()),
                 float(self.form.e3z.text())
             ]]
        import CfdTools
        for i in range(3):
            e[i] = CfdTools.normalise(e[i])

        # Keep this one fixed. Make the other two orthogonal. The previous one edited gets to stay in its plane; the
        # one edited longest ago just gets recomputed
        if self.lastEVectorChanged == index:
            prevIndex = self.lastLastEVectorChanged
        else:
            prevIndex = self.lastEVectorChanged
        indexplus = (index + 1) % 3
        indexminus = (index - 1) % 3
        import numpy
        if indexplus == prevIndex:  # indexminus must be the one changed longest ago
            e[indexminus] = numpy.cross(e[index], e[indexplus])
            e[indexplus] = numpy.cross(e[indexminus], e[index])
        else:
            e[indexplus] = numpy.cross(e[indexminus], e[index])
            e[indexminus] = numpy.cross(e[index], e[indexplus])
        e[indexplus] = CfdTools.normalise(e[indexplus])
        e[indexminus] = CfdTools.normalise(e[indexminus])

        self.form.e1x.setText("{:.2f}".format(e[0][0]))
        self.form.e1y.setText("{:.2f}".format(e[0][1]))
        self.form.e1z.setText("{:.2f}".format(e[0][2]))
        self.form.e2x.setText("{:.2f}".format(e[1][0]))
        self.form.e2y.setText("{:.2f}".format(e[1][1]))
        self.form.e2z.setText("{:.2f}".format(e[1][2]))
        self.form.e3x.setText("{:.2f}".format(e[2][0]))
        self.form.e3y.setText("{:.2f}".format(e[2][1]))
        self.form.e3z.setText("{:.2f}".format(e[2][2]))
    def eDone(self, index):
        e = [[
            self.form.e1x.property('quantity').getValueAs('1').Value,
            self.form.e1y.property('quantity').getValueAs('1').Value,
            self.form.e1z.property('quantity').getValueAs('1').Value
        ],
             [
                 self.form.e2x.property('quantity').getValueAs('1').Value,
                 self.form.e2y.property('quantity').getValueAs('1').Value,
                 self.form.e2z.property('quantity').getValueAs('1').Value
             ],
             [
                 self.form.e3x.property('quantity').getValueAs('1').Value,
                 self.form.e3y.property('quantity').getValueAs('1').Value,
                 self.form.e3z.property('quantity').getValueAs('1').Value
             ]]
        for i in range(3):
            e[i] = CfdTools.normalise(e[i])

        # Keep this one fixed. Make the other two orthogonal. The previous one edited gets to stay in its plane; the
        # one edited longest ago just gets recomputed
        if self.lastEVectorChanged == index:
            prevIndex = self.lastLastEVectorChanged
        else:
            prevIndex = self.lastEVectorChanged
        indexplus = (index + 1) % 3
        indexminus = (index - 1) % 3
        if indexplus == prevIndex:  # indexminus must be the one changed longest ago
            e[indexminus] = numpy.cross(e[index], e[indexplus])
            e[indexplus] = numpy.cross(e[indexminus], e[index])
        else:
            e[indexplus] = numpy.cross(e[indexminus], e[index])
            e[indexminus] = numpy.cross(e[index], e[indexplus])
        e[indexplus] = CfdTools.normalise(e[indexplus])
        e[indexminus] = CfdTools.normalise(e[indexminus])

        setQuantity(self.form.e1x, str(e[0][0]))
        setQuantity(self.form.e1y, str(e[0][1]))
        setQuantity(self.form.e1z, str(e[0][2]))
        setQuantity(self.form.e2x, str(e[1][0]))
        setQuantity(self.form.e2y, str(e[1][1]))
        setQuantity(self.form.e2z, str(e[1][2]))
        setQuantity(self.form.e3x, str(e[2][0]))
        setQuantity(self.form.e3y, str(e[2][1]))
        setQuantity(self.form.e3z, str(e[2][2]))