def plot_geometry_perpendiculars(axes, geometry: Geometry, \
                                 colour='gray', alpha=.5):
    """Plots the normals/perpendiculars of each face in a geometry, and 
       displays them as little gray arrows.
       TODO: Implement scaling."""
    # First plot centroids of each plane:
    xc = []
    yc = []
    zc = []

    centroids = geometry.find_fcentroids()

    for vertex in centroids:
        xc.append(vertex.x)
        yc.append(vertex.y)
        zc.append(vertex.z)
    axes.scatter(xc, yc, zc, c=colour, s=5, alpha=alpha)

    # Then, attach plane-perpendicular arrows to the centroids:
    xyzuvw = geometry.perpendiculars_plotlist()
    axes.quiver(xyzuvw[0][:],
                xyzuvw[1][:],
                xyzuvw[2][:],
                xyzuvw[3][:],
                xyzuvw[4][:],
                xyzuvw[5][:],
                color=colour,
                alpha=alpha)
def plot_geometry(axes,
                  geometry: Geometry,
                  fill=0,
                  alpha=0.2,
                  linecolour='black',
                  linealpha=1,
                  illumination=False,
                  illumination_plane='xy'):
    """Plot geometry by individually plotting its faces. If illumination 
       is turned on, uses illuminated_faces() method to fetch which faces 
       are illuminated, and passes this to the plot_face() function.
       
       TODO: Allow passing of 'plane'
       """
    if illumination == True:
        ill_faces = geometry.illuminated_faces(plane=illumination_plane)
        for idx, face in enumerate(geometry.faces):
            plot_face(axes,
                      face,
                      fill=fill,
                      alpha=alpha,
                      linecolour=linecolour,
                      linealpha=linealpha,
                      illumination=True,
                      ill_value=ill_faces[idx])
    else:
        for idx, face in enumerate(geometry.faces):
            plot_face(axes,
                      face,
                      fill=fill,
                      alpha=alpha,
                      linecolour=linecolour,
                      linealpha=linealpha)
 def remove_geometry(self, geometry: Geometry):
     """TODO: merge into one add_child method."""
     self.geometries.remove(geometry)
     geometry.set_parenttype="global"
    p2 = Vertex(-0.05, -0.05, 0.1, frame1)
    p3 = Vertex(0.05, -0.05, 0.1, frame1)
    p4 = Vertex(0.05, -0.05, -0.1, frame1)
    p5 = Vertex(-0.05, 0.05, -0.1, frame1)
    p6 = Vertex(-0.05, 0.05, 0.1, frame1)
    p7 = Vertex(0.05, 0.05, 0.1, frame1)
    p8 = Vertex(0.05, 0.05, -0.1, frame1)

    fA = Face(p4, p3, p2, p1, frame1)
    fB = Face(p2, p3, p7, p6, frame1)
    fC = Face(p3, p4, p8, p7, frame1)
    fD = Face(p4, p1, p5, p8, frame1)
    fE = Face(p1, p2, p6, p5, frame1)
    fF = Face(p5, p6, p7, p8, frame1)

    cubesat = Geometry(frame1)
    cubesat.add_faces([fA, fB, fC, fD, fE, fF])

    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
Exemple #5
0
p2 = Vertex([-0.05, -0.05, 0.1])
p3 = Vertex([0.05, -0.05, 0.1])
p4 = Vertex([0.05, -0.05, -0.1])
p5 = Vertex([-0.05, 0.05, -0.1])
p6 = Vertex([-0.05, 0.05, 0.1])
p7 = Vertex([0.05, 0.05, 0.1])
p8 = Vertex([0.05, 0.05, -0.1])

fA = Face(p4, p3, p2, p1)
fB = Face(p2, p3, p7, p6)
fC = Face(p3, p4, p8, p7)
fD = Face(p4, p1, p5, p8)
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 ====
Exemple #6
0
    p2 = Vertex([-0.05, -0.05, 0.1])
    p3 = Vertex([0.05, -0.05, 0.1])
    p4 = Vertex([0.05, -0.05, -0.1])
    p5 = Vertex([-0.05, 0.05, -0.1])
    p6 = Vertex([-0.05, 0.05, 0.1])
    p7 = Vertex([0.05, 0.05, 0.1])
    p8 = Vertex([0.05, 0.05, -0.1])

    fA = Face(p4, p3, p2, p1)
    fB = Face(p2, p3, p7, p6)
    fC = Face(p3, p4, p8, p7)
    fD = Face(p4, p1, p5, p8)
    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()))

    # f1 = Face(Vertex(0,0,0), Vertex(1,0,0), Vertex(1,1,0), Vertex(0,1,0))
    # f2 = Face(Vertex(0,0,0), Vertex(1,0,0), Vertex(1,1,0), Vertex(0,1,0))
    # f3 = Face(Vertex(0,0,0), Vertex(1,0,0), Vertex(1,1,0), Vertex(0,1,0))
    # f4 = Face(Vertex(0,0,0), Vertex(1,0,0), Vertex(1,1,0), Vertex(0,1,0))
    # f5 = Face(Vertex(0,0,0), Vertex(1,0,0), Vertex(1,1,0), Vertex(0,1,0))
    # f6 = Face(Vertex(0,0,0), Vertex(1,0,0), Vertex(1,1,0), Vertex(0,1,0))
 #   the points is specified DOES matter! (see definition of Face class)
 
                             #         ^ Z
                             #         | 
 fA = Face(p4, p3, p2, p1)   #     E  ___  
 fB = Face(p2, p3, p7, p6)   #       |\ B_\  
 fC = Face(p3, p4, p8, p7)   #     A | |  | F        Y
 fD = Face(p4, p1, p5, p8)   #       | | C|  -------->
 fE = Face(p1, p2, p6, p5)   #        \|__|
 fF = Face(p5, p6, p7, p8)   #          D       
                             #            \
                             #             v X
 
 # Assembling a Geometry instance named 'cubesat', and add all the faces
 #   we just defined to the geometry.
 cubesat = Geometry([fA, fB, fC, fD, fE, fF])
 
 # Define a reference frame which will be attached to the centre of gravity
 #   of the CubeSat. If you move/rotate this frame, the 'cubesat' 
 #   Geometry will move/rotate along with it (if it is attached of course).
 frame1 = Frame()
 # Attaching the cubesat Geometry to 'frame1'
 frame1.add_geometry(cubesat)
 # Translate 'frame1' away from the origin. The sole reasons for doing this
 #   is so the geometry will not overlap with the yellow projection of the
 #   illuminated area, and because the plot will generally look nicer.
 frame1.translate(0.3, 0.3, 0.25)
 
 
 """ == HERE WE START CHANGING THE INITIAL ATTITUDE OF THE SATELLITE == """
 # Change the LTAN by 1.5 hours
Exemple #8
0

# Manually calculate centroid of Cubesat geometry
# COR = Vertex(0.05, 0.05, 0.1)
# COR.translate(0.1, 0.1, 0.1)

# Define faces of Cubesat
fA = Face(p4, p3, p2, p1)
fB = Face(p2, p3, p7, p6)
fC = Face(p3, p4, p8, p7)
fD = Face(p4, p1, p5, p8)
fE = Face(p1, p2, p6, p5)
fF = Face(p5, p6, p7, p8)

# Initialize Cubesat model as a Geometry object.
geometry1 = Geometry()
geometry1.add_faces([fA, fB, fC, fD, fE, fF])

# Translate geometry outward, so it is not positioned on the global axes.
geometry1.translate(0.1, 0.1, 0.1)

# Apply rotations as specified earlier.
geometry1.rotate_cuboid_centroid(a, b, c)

# Create a projection object that can be plotted later.
geometry1xy = geometry1.project_illuminated_faces('xy')


# %% Plotting code

# Check value for illuminated area. Because Cubesat is a cuboid, illuminated
Exemple #9
0
p8 = Vertex(0.1, 0.1, 0.0)

# Manually calculate centroid of Cubesat geometry
# COR = Vertex(0.05, 0.05, 0.1)
# COR.translate(0.1, 0.1, 0.1)

# Define faces of Cubesat
fA = Face(p4, p3, p2, p1)
fB = Face(p2, p3, p7, p6)
fC = Face(p3, p4, p8, p7)
fD = Face(p4, p1, p5, p8)
fE = Face(p1, p2, p6, p5)
fF = Face(p5, p6, p7, p8)

# Initialize Cubesat model as a Geometry object.
cubesat = Geometry()
cubesat.add_faces([fA, fB, fC, fD, fE, fF])

# Translate geometry outward, so it is not positioned on the global axes.
cubesat.translate(0.1, 0.25, 0.1)

# Apply rotations as specified earlier.
cubesat.rotate_cuboid_centroid(a, b, c)

# %% Plotting code

# Properly compute the illuminated area using Geometry method:
A_shadow = round(cubesat.illuminated_area(plane='xz'), 4)

print('Projected A_xz =', A_shadow, "m^2")