def plot_frame( axes: plt.matplotlib.axes, frame: Frame, # Tripod properties show_tripod=True, # If False, does not plot the tripod tripod_scale=1, # Sets the scale of the tripod plot_perpendiculars=True, # Plot perpendiculars # Vertex plotting properties: vertexfill=True, # If False, vertex will not be plotted vertexcolour="#000", # Specifies the vertex colour vertexsize=10, # Size of the plotted vertex vertexalpha=1, # Opacity of the plotted vertex # Face plotting properties: linefill=True, # If False, does not plot face lines linecolour="#000", # Colour of face lines linewidth=2, # Thickness of face lines linealpha=1, # Opacity of face lines facefill=True, # If False, does not shade the face area facecolour="#555", # Colour of the face area shading facealpha=1, # Opacity of the face area shading # Face perpendicular arrow plotting properties: perpfill=False, # If True, plot perpendiculars perpcolour="#888", # Specifies the perp. arrow colour perpscale=1, # Size of the plotted perp. arrow perpalpha=0.5, # Opacity of the plotted perp. arrow # Illumination: illumination=False, # If True, plots illumination intensity ill_value=0, # Used to plot illumination intensity ill_plane=None, # If illumination is used, a plane # MUST be satisfied. # Vector plotting properties: vectorfill=True, # If False, does not plot vector arrow vectorcolour="#000", # Colour of vector arrow vectoralpha=1, # Opacity of vector arrow vectorscale=1, # Scale the whole vector by a constant vectorratio=0.15 # Vector arrow length ratio ): if frame.geometries: """If frame contains geometries, plot these. Then find out if there are any leftover edges and vertices associated with the frame, plot these too. """ for geometry in frame.geometries: # Plot unique vertices first: for vertex in geometry.vertices(): plot_vertex(axes, vertex, frame.vertex_xyz_global(vertex), vertexfill=vertexfill, vertexcolour=vertexcolour, vertexsize=vertexsize, vertexalpha=vertexalpha) # Then plot faces, without plotting the vertices for face in geometry.faces: if illumination: if not ill_plane: raise AssertionError("If illumination is plotted, an \ illumination plane MUST be \ specified, e.g. \ (ill_plane = 'xy')") else: if face not in frame.illuminated_faces( geometry, plane=ill_plane): ill_value = 0 else: ill_value = frame.illuminated_strength( face, plane=ill_plane) plot_face(axes, face, frame.plotlist(face), linefill=linefill, linecolour=linecolour, linewidth=linewidth, linealpha=linealpha, facefill=facefill, facecolour=facecolour, facealpha=facealpha, vertexfill=False, vertexcolour=vertexcolour, vertexsize=vertexsize, vertexalpha=vertexalpha, illumination=illumination, ill_value=ill_value) if perpfill: # First plot centroids of each plane: plot_geometry_perpendiculars(axes, \ frame.perpendiculars_plotlist(geometry, perpscale), colour = perpcolour, alpha = perpalpha) if show_tripod: plot_frame_tripod(axes, frame, scaling=tripod_scale)
fE = Face(p1, p2, p6, p5) fF = Face(p5, p6, p7, p8) cubesat = Geometry([fA, fB, fC, fD, fE, fF]) frame1 = Frame() frame1.add_geometry(cubesat) frame1.translate(0.5, 0.5, 0.5) frame1.rotate(0, 0, d2r(1 * 360 / 12)) cubesat.rotate(d2r(-45), 0, 0, cor=list(cubesat.find_cuboid_centroid())) f = Face(Vertex([0, 0, 0]), Vertex([1, 0, 0]), Vertex([1, 1, 0]), Vertex([0, 1, 0])) for face in frame1.illuminated_faces(cubesat, 'xz'): print(frame1.illuminated_strength(face, 'xz')) #%% ==== Plotting ==== # Toggle plotting functionality: if True: # Setting up the plot: fig = plt.figure(figsize=(8, 8)) 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. Illuminated area: {} m^2.".format(
def plot_illumination( axes: plt.matplotlib.axes, frame: Frame, plane='xy', geometry: Geometry = None, # Tripod properties show_tripod=False, # If False, does not plot the tripod tripod_scale=1, # Sets the scale of the tripod plot_perpendiculars=False, # Plot perpendiculars # Vertex plotting properties: vertexfill=False, # If False, vertex will not be plotted vertexcolour="FFC125", # Specifies the vertex colour vertexsize=10, # Size of the plotted vertex vertexalpha=1, # Opacity of the plotted vertex # Face plotting properties: linefill=True, # If False, does not plot face lines linecolour="#FFC125", # Colour of face lines linewidth=2, # Thickness of face lines linealpha=1, # Opacity of face lines facefill=False, # If False, does not shade the face area facecolour="FFC125", # Colour of the face area shading facealpha=1, # Opacity of the face area shading # Face perpendicular arrow plotting properties: perpfill=False, # If True, plot perpendiculars perpcolour="#888", # Specifies the perp. arrow colour perpscale=1, # Size of the plotted perp. arrow perpalpha=0.5, # Opacity of the plotted perp. arrow # Illumination: illumination=False, # If True, plots illumination intensity ill_value=0, # Used to plot illumination intensity # Vector plotting properties: vectorfill=False, # If False, does not plot vector arrow vectorcolour="#000", # Colour of vector arrow vectoralpha=1, # Opacity of vector arrow vectorscale=1, # Scale the whole vector by a constant vectorratio=0.15 # Vector arrow length ratio ): # Gather the faces to be plotted in the geometry. If no geometry was # provided (geometry=None), plot all the illuminated faces in the frame. if not geometry: geometries = frame.geometries else: geometries = list(geometry) illuminated_faces = [] # Find out what faces are illuminated: for geo in geometries: faces = frame.illuminated_faces(geo, plane=plane) illuminated_faces.extend(faces) # Plot each face after projecting them in the global frame: for face in illuminated_faces: # projected_face = frame.project_face(face) plot_face(axes, frame.project_face(face, plane=plane), linefill=linefill, linecolour=linecolour, linewidth=linewidth, linealpha=linealpha, facefill=facefill, facecolour=facecolour, facealpha=facealpha, vertexfill=vertexfill, vertexcolour=vertexcolour, vertexsize=vertexsize, vertexalpha=vertexalpha, illumination=False)