Beispiel #1
0
    def update(i):

        # Transforming frame1
        if i < steps / 2:
            frame1.translate(1 / steps, 2 / steps, 2 / steps)
        else:
            frame1.translate(1 / steps, -2 / steps, -2 / steps)
        frame1.rotate(0, -2 * np.pi / steps, -2 * np.pi / steps)
        # frame1.rotate(0,0,0)

        # vertex1.rotate(2*np.pi/steps,0,0, cor=vertex2)

        # Setting up the axes object
        ax.clear()

        ax.set_title("Wireframe visualization. Frame: {}".format(str(i)))

        plotscale = 1
        ax.set_xlim(0, 1.25 * plotscale)
        ax.set_ylim(0, 1.25 * plotscale)
        ax.set_zlim(0, plotscale)
        # ax.set_xlim(-1, 1)
        # ax.set_ylim(-1, 1)
        # ax.set_zlim(-1, 1)

        ax.set_xlabel('x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')

        # Plotting the global XYZ tripod
        plot_global_tripod(ax, scaling=plotscale / 2)

        # Plot tripod of frame1:
        plot_frame(ax, frame1, tripod_scale=plotscale / 8, facealpha=0.4)
Beispiel #2
0
    def update(i):

        # Transforming frame1
        cubesat.rotate(angle_step,
                       0,
                       0,
                       cor=list(cubesat.find_cuboid_centroid()))

        print("[DEBUG] Plotting frame {}".format(i))

        # Setting up the axes object
        ax.clear()

        ax.set_title("Wireframe visualization. Frame: {}".format(str(i)))

        plotscale = 1
        ax.set_xlim(0, 1.25 * plotscale)
        ax.set_ylim(0, 1.25 * plotscale)
        ax.set_zlim(0, plotscale)

        ax.set_xlabel('x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')

        # Plotting the global XYZ tripod
        plot_global_tripod(ax, scaling=plotscale / 2)

        # Plot tripod of frame1:
        plot_frame(ax,
                   frame1,
                   tripod_scale=plotscale / 8,
                   perpfill=True,
                   perpscale=0.1,
                   facealpha=0.8)
Beispiel #3
0
    def update(i):

        # Transforming frame1
        frame1.translate(2 / steps, 2 / steps, 2 / steps)
        # frame1.rotate(0,0,-2*np.pi/(steps))

        # Local transformation of vertex1 - rotate around vertex2
        vertex1.rotate(2 * np.pi / steps, 0, 0, cor=vertex2)

        # Setting up the axes object
        ax.clear()

        ax.set_title("Wireframe visualization. Frame: {}".format(str(i)))

        ax.set_xlim(0, 0.4 * 10)
        ax.set_ylim(0, 0.4 * 10)
        ax.set_zlim(0, 0.3 * 10)

        ax.set_xlabel('x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')

        # Plotting the global XYZ tripod
        plot_global_tripod(ax)

        # Plot tripod of frame1:
        plot_frame(ax, frame1)
    def update(i):

        # Transforming frame1
        cubesat.rotate(angle_step, 0, 0, cor=cubesat.make_cuboid_centroid())

        projection_frame = Frame()

        for face in cubesat.faces:
            face.project(new_frame=projection_frame, plane='xz')

        print("[DEBUG] Plotting frame {}".format(i))

        # Setting up the axes object
        ax.clear()

        ax.set_title("Wireframe visualization. Frame: {}".format(str(i)))

        plotscale = 1
        ax.set_xlim(0, 1.25 * plotscale)
        ax.set_ylim(0, 1.25 * plotscale)
        ax.set_zlim(0, plotscale)
        # ax.set_xlim(-1, 1)
        # ax.set_ylim(-1, 1)
        # ax.set_zlim(-1, 1)

        ax.set_xlabel('x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')

        # Plotting the global XYZ tripod
        plot_global_tripod(ax, scaling=plotscale / 2)

        # Plot tripod of frame1:
        plot_frame(ax, frame1, tripod_scale=plotscale / 8, facefill=False)
        plot_frame(ax,
                   projection_frame,
                   tripod_scale=plotscale / 8,
                   facefill=False,
                   linecolour="#AA2")
Beispiel #5
0
    ax.set_title("Wireframe visualization. Illuminated area: {} m^2.".format(
        round(frame1.illuminated_area(cubesat, plane='xz'), 4)))

    ax.set_xlim(0, 1)
    ax.set_ylim(0, 1)
    ax.set_zlim(0, 1)

    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')

    # Plotting the global XYZ tripod
    plot_global_tripod(ax)

    # ==== Plot custom objects ====

    # plot_vertex(ax, p0)
    # plot_face(ax, f)

    # plot_face(ax, fA, frame1.plotlist(fA))
    plot_frame(ax, frame1, tripod_scale=0.2, \
               illumination=True, ill_plane='xz', \
               facecolour="#468", facealpha=0.95, \
               perpfill=True, perpscale=0.1, perpalpha=0.25)

    plot_illumination(ax, frame1, plane='xz')

    # =============================

    plt.show()
    def update(i):
        
        """ Defining some plotting parameters. """
        # Clearing the plot with each update, so matplotlib doesn't keep
        #   rendering overtop one another in the plot window.
        ax.clear()
        
        # Set the scale of the plot with a sizing factor.
        plotscale = 0.5
        # Set the limits of the X/Y/Z axes of the plot. You can change these,
        #   but the CubeSat may start looking oddly fat or skinny.
        ax.set_xlim(0, 1.25*plotscale)
        ax.set_ylim(0, 1.25*plotscale)
        ax.set_zlim(0, plotscale)
        
        # Labelling the axes
        ax.set_xlabel('x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')
        
        
        """ ============== TRANSFORMING THE CUBESAT MODEL ================ """
        # We could rotate the whole CubeSate by rotating its parent frame
        #   'frame1'. You would do this like so:
        # frame1.rotate(angle_step,0,0,cor=frame1.origin())
        # This is bad, because it forces us to define the rotations of the 
        #   CubeSat in terms of the global frame of reference. This is hard.
        
        # However, instead we will merely rotate the 'cubesat' Geometry and
        #   keep 'frame1' stationary. This way, we can define the rototations
        #   of the CubeSat in terms of the local frame 'frame1'.
        # Note that we rotate by angle_step each time the function updates, 
        #   and that we rotate 'cubesat' around the CubeSat centroid.
        
        cubesat.rotate(angle_step,0,0,cor=list(cubesat.find_cuboid_centroid()))
        
        # We rotate the fake earth Geometry 'E' by the same amount, and also
        #   around the CubeSat centroid.
        E.rotate(angle_step,0,0,cor=list(cubesat.find_cuboid_centroid()))


        """ ================ SETTING UP ALBEDO SIMULATION ================= """
        
        # Calculate the albedo vector. This is needed to determine the albedo
        #   multiplier. We will also plot it in purple, so it will be easy
        #   to understand what is going on:        
        albedo_vector = frame1.vertex_xyz_global(cubesat.make_cuboid_centroid()) \
            - frameE.vertex_xyz_global(E_anchor)
            
        # Normalize albedo vector to unit vector
        albedo_vector = albedo_vector/np.linalg.norm(albedo_vector)

        # Add the albedo vector to the plot so it is easy to visualize.
        plot_arrow(ax, 
                   frameE.vertex_xyz_global(E_anchor), 
                   albedo_vector, 
                   scaling=0.05)


        # Finding albedo multiplier
        multiplier[i-1] = np.dot(albedo_vector, frame1.illumination_vector('xz'))
        # If the satellite is behind the Earth, no reflected albedo light
        #   reaches the satellite. If the satellite is behind the Earth, the 
        #   dot product between the illumination vector (from Sun->CubeSat)
        #   and the albedo vector will be positive. If this is the case, we 
        #   want to make the multiplier 0 (no albedo).
        if multiplier[i-1] >= 0:
            multiplier[i-1] = 0
        # Else, we just set the multiplier to positive and assign it.
        #   The value of multiplier goes from 0 to 1.
        else:
            multiplier[i-1] = -multiplier[i-1]
        
        
        """ ================ SETTING UP SHADOW SIMULATION ================ """        
        # Shitty shadow simulation: Here we use a simple if-statement to check
        #   whether the satellite is behind the Earth. If it is, none of the
        #   satellite sides are illuminated, and so we just set the illuminated
        #   area to zero.
        
        if True: # If you set this False, you turn the shadow simulation off
            shadow = False  
            if 0.5-0.361/2 <= i/(steps-1) <= 0.5+0.361/2:
                shadow = True
            else:
                shadow = False
        
        # Unnecessary but I'm keeping it here just in case
#        global A_ill
        
        # If the CubeSat is not in the Earth's shadow, calculate the 
        #   illuminated area (from sun) and the area subjected to albedo.
        if not shadow:
            A_ill[i-1] = round(frame1.illuminated_area(cubesat, plane='xz'), 4)
            A_ill2[i-1] = round(frame1.area_projected(cubesat, albedo_vector),4)
        else:
            A_ill[i-1] = 0
            A_ill2[i-1] = 0
        
        
        """ ================= CALCULATE THE POWER VALUES ================= """    
        
        # Power from sunlight:
        P_sun[i-1] = A_ill[i-1]\
            * solar_flux * n_cell * n_packing \
            * (1 - degradation * years_elapsed)
        
        # Power from albedo:
        P_alb[i-1] = A_ill2[i-1] * multiplier[i-1] * ALB_earth_avg \
            * solar_flux * n_cell * n_packing \
            * (1 - degradation * years_elapsed)    
        
        # Calculate the total power
        P_tot[i-1] = P_sun[i-1] + P_alb[i-1]
        
        # Debug line to monitor A_ill, A_ill2 for each frame.        
#        print("[DEBUG] Frame {}, A_ill = {}, A_ill2 = {}"\
#              .format(i, A_ill[i-1], A_ill2[i-1]))        
        
        
        """ ======================= MAKE THE 3D PLOT ====================== """  
        # This section uses several variables from cp_plotting.py
        
        # Plotting the global XYZ tripod
        plot_global_tripod(ax, scaling=plotscale/2)
        
        
        if not shadow:
            # Sunlight shining on satellite? Plot contents of 'frame1', and use
            #   illumination values to show which sides are illuminated
            plot_frame(ax, frame1, tripod_scale=plotscale/8,
                       perpfill=False, perpscale=0.1, 
                       illumination=True, ill_plane='xz',
                       facecolour="#0F0F0F", facealpha=0.7
                       )
            
            # Sunlight shining on satellite? Plot illuminated area in yellow
            plot_illumination(ax, frame1, plane='xz')
            
        else:
            # Satellite in shadow? Plot contents of 'frame1', but disable
            #   illumination.
            plot_frame(ax, frame1, tripod_scale=plotscale/8,
                       perpfill=False, perpscale=0.1, 
                       illumination=False, ill_plane='xz',
                       facecolour="#0F0F0F", facealpha=0.7
                       )
            
            # Satellite in shadow? Plot illuminated area in black        
            plot_illumination(ax, frame1, plane='xz',linecolour="#000")
            
        
        # Plot the fake earth by plotting the contents of 'frameE'
        plot_frame(ax, frameE, tripod_scale=plotscale/8, show_tripod=False,
                   linefill=False, facefill=False,
                   illumination=False,
                   vertexcolour="#0000DD", vertexsize=300
                   )

        # Set plot title
        ax.set_title("3D Visualization.    Frame: {}.    A_ill = {} m^2.    Shadow is {}.\
                     ".format(str(i), str(A_ill[i-1]), shadow))
    
        
        # If simulation is at the final step, plot the power curve:
        if i == steps-1:
            print("Function update() is done! Plotting power curves...")
            
            # Call power curve plotting function
            plot_power(P_sun, P_alb)
    """ TO CHANGE THE DEFAULT CAMERA VIEW, CHANGE THESE: """
    ax.view_init(elev=20, azim=-60)

    # Setting up the axes object
    ax.set_title("Wireframe visualization.")

    ax.set_xlim(-2, 2)
    ax.set_ylim(-2, 2)
    ax.set_zlim(-2, 2)

    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')

    # Plotting the global XYZ tripod
    plot_global_tripod(ax)

    # ==== Plot custom objects ====

    for vertex in [p1, p2, p3, p4, p5, p6]:
        plot_vertex(ax, vertex)

    for face in [f1, f2]:
        plot_face(ax, face)

    plot_frame(ax, frame1)

    # =============================

    plt.show()
    ax = mp3d.Axes3D(fig)
    """ TO CHANGE THE DEFAULT CAMERA VIEW, CHANGE THESE: """
    ax.view_init(elev=20, azim=-60)

    # Setting up the axes object
    ax.set_title("Wireframe visualization.")

    ax.set_xlim(0, 1)
    ax.set_ylim(0, 1)
    ax.set_zlim(0, 1)

    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')

    # Plotting the global XYZ tripod
    plot_global_tripod(ax)

    # ==== Plot custom objects ====

    # plot_vertex(ax, p0)
    # plot_face(ax, f)

    # plot_face(ax, fA, frame1.plotlist(fA))
    plot_frame(ax, frame1, tripod_scale=0.2, \
               perpfill=True, perpscale=0.1, perpalpha=0.25)

    # =============================

    plt.show()
    def update(i):

        # Setting up the axes object
        ax.clear()

        plotscale = 0.5
        ax.set_xlim(0, 1.25 * plotscale)
        ax.set_ylim(0, 1.25 * plotscale)
        ax.set_zlim(0, plotscale)

        ax.set_xlabel('x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')

        # Transforming cubesat
        cubesat.rotate(angle_step,
                       0,
                       0,
                       cor=list(cubesat.find_cuboid_centroid()))

        # Transform fake Earth
        E.rotate(angle_step, 0, 0, cor=list(cubesat.find_cuboid_centroid()))

        # Shitty shadow simulation:
        if True:  # Toggle
            shadow = False
            if 0.5 - 0.361 / 2 <= i / (steps - 1) <= 0.5 + 0.361 / 2:
                shadow = True
            else:
                shadow = False

        global A_ill
        if not shadow:
            A_ill[i - 1] = round(frame1.illuminated_area(cubesat, plane='xz'),
                                 4)
        else:
            A_ill[i - 1] = 0

        print("[DEBUG] Frame {}, i/(steps-1) = {}, shadow {}"\
              .format(i, round(i/(steps-1),2), shadow))

        # Plotting the global XYZ tripod
        plot_global_tripod(ax, scaling=plotscale / 2)

        # Plot tripod of frame1:
        if not shadow:
            plot_frame(ax,
                       frame1,
                       tripod_scale=plotscale / 8,
                       perpfill=False,
                       perpscale=0.1,
                       illumination=True,
                       ill_plane='xz',
                       facecolour="#0F0F0F",
                       facealpha=1)

            plot_illumination(ax, frame1, plane='xz')

        else:
            plot_frame(ax,
                       frame1,
                       tripod_scale=plotscale / 8,
                       perpfill=False,
                       perpscale=0.1,
                       illumination=False,
                       ill_plane='xz',
                       facecolour="#0F0F0F",
                       facealpha=1)

            plot_illumination(ax, frame1, plane='xz', linecolour="#000")

        plot_frame(ax,
                   frameE,
                   tripod_scale=plotscale / 8,
                   show_tripod=False,
                   linefill=False,
                   facefill=False,
                   illumination=False,
                   vertexcolour="#0000DD",
                   vertexsize=300)

        ax.set_title(
            "3D Visualization.    Frame: {}.    A_ill = {} m^2.    Shadow is {}.\
                     ".format(str(i), str(A_ill[i - 1]), shadow))