Ejemplo n.º 1
0
    def plot_airfoil_with_cabin(self,
                                offsetFront,
                                length,
                                height,
                                angle,
                                show_plot=True,
                                save_plot_path='',
                                clear_plot=True,
                                ax=None):
        top, buttom = self.get_cooridnates_top_buttom(500)
        #if bzFoil.valid == False:
        #    return False, False
        air = Airfoil(None)
        air.set_coordinates(top, buttom)

        air.rotate(angle)
        # air.rotate(angle)
        px_ul = offsetFront
        px_ur = offsetFront + length
        py_ul = max(air.get_buttom_y(px_ul), air.get_buttom_y(px_ur))
        py_ur = py_ul
        px_ol = px_ul
        px_or = px_ur
        py_ol = min(air.get_top_y(px_ol), air.get_top_y(px_or))
        py_or = py_ol
        print('geometrical calculated height = ' + str(py_ol - py_ul))
        (px_ol, py_ol) = air.rotatePoint((0, 0), (px_ol, py_ol), -angle)
        (px_ul, py_ul) = air.rotatePoint((0, 0), (px_ul, py_ul), -angle)

        # py_ur = air.get_buttom_y(px_ur)
        # px_or = px_ur
        # py_or = py_ur + height
        (px_or, py_or) = air.rotatePoint((0, 0), (px_or, py_or), -angle)
        (px_ur, py_ur) = air.rotatePoint((0, 0), (px_ur, py_ur), -angle)
        air.rotate(0.)

        #fig, ax = air.plotAirfoil(showPlot=False, showPoints=False, ax=ax)

        ax.plot([px_ol, px_ul, px_ur, px_or, px_ol],
                [py_ol, py_ul, py_ur, py_or, py_ol],
                'rx-',
                label='cabin',
                color='#AD031B')
        #plt.show()

        plt.axis('equal')
        if save_plot_path != '':
            fig.set_size_inches(18.5, 10.5)
            #plt.savefig(save_plot_path, dpi=900)
            plt.savefig(save_plot_path + '.svg', dpi=900)
        if show_plot:
            plt.show()
        if clear_plot:
            plt.clf()
        '''
        #angle = 0.
        #offsetFront = 0.11
        #length = 0.55
        air = Airfoil(None)
        air.set_coordinates(self.topCoords, self.buttomCoords)
        air.rotate(angle)

        px_ul = offsetFront
        px_ur = offsetFront + length
        py_ul = max(air.get_buttom_y(px_ul), air.get_buttom_y(px_ur))
        py_ur = py_ul
        px_ol = px_ul
        px_or = px_ur
        py_ol = min(air.get_top_y(px_ol), air.get_top_y(px_or))
        py_or = py_ol
        print('geometrical calculated height = ' + str(py_ol - py_ul))
        (px_ol, py_ol) = air.rotatePoint((0, 0), (px_ol, py_ol), -angle)
        (px_ul, py_ul) = air.rotatePoint((0, 0), (px_ul, py_ul), -angle)

        # py_ur = air.get_buttom_y(px_ur)
        # px_or = px_ur
        # py_or = py_ur + height
        (px_or, py_or) = air.rotatePoint((0, 0), (px_or, py_or), -angle)
        (px_ur, py_ur) = air.rotatePoint((0, 0), (px_ur, py_ur), -angle)
        air.rotate(0.)
        fig, ax = air.plotAirfoil(showPlot=False, showPoints=False)
        ax.plot([px_ol, px_ul, px_ur, px_or, px_ol], [py_ol, py_ul, py_ur, py_or, py_ol], 'rx-')
        '''
        """
#angle = 0.
#offsetFront = 0.11
air = Airfoil(INPUT_DIR + '/' + 'airfoil.dat')
air.rotate(angle)
#air.rotate(angle)
px_ul = offsetFront
px_ur = offsetFront + length
py_ul = max(air.get_buttom_y(px_ul), air.get_buttom_y(px_ur))
py_ur = py_ul
px_ol = px_ul
px_or = px_ur
py_ol = min(air.get_top_y(px_ol), air.get_top_y(px_or))
py_or = py_ol
print('geometrical calculated height = ' + str(py_ol - py_ul))
(px_ol, py_ol) = air.rotatePoint((0, 0), (px_ol, py_ol), -angle)
(px_ul, py_ul) = air.rotatePoint((0, 0), (px_ul, py_ul), -angle)

#py_ur = air.get_buttom_y(px_ur)
#px_or = px_ur
#py_or = py_ur + height
(px_or, py_or) = air.rotatePoint((0, 0), (px_or, py_or), -angle)
(px_ur, py_ur) = air.rotatePoint((0, 0), (px_ur, py_ur), -angle)
air.rotate(0.)
fig, ax = air.plotAirfoil(showPlot=False, showPoints=False)
ax.plot([px_ol, px_ul, px_ur, px_or, px_ol],
        [py_ol, py_ul, py_ur, py_or, py_ol], 'rx-')
plt.show()
outputF.write('aircraft.centerbody.px_ol\t= {:.7f};\n'.format(px_ol))
outputF.write('aircraft.centerbody.py_ol\t= {:.7f};\n'.format(py_ol))
outputF.write('aircraft.centerbody.px_or\t= {:.7f};\n'.format(px_or))