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")
from cp_utilities import d2r #, r2d from cp_plotting import plot_global_tripod, plot_frame # Toggle plotting functionality: if True: # Setting up the plot: fig = plt.figure(figsize=(10, 7)) ax = mp3d.Axes3D(fig) """ TO CHANGE THE DEFAULT CAMERA VIEW, CHANGE THESE: """ ax.view_init(elev=20, azim=-60) steps = 40 angle_step = d2r(360 / steps) frame1 = Frame() frame1.translate(0.5, 0.5, 0.5) frame1.rotate(0, 0, d2r(1 * 360 / 12)) p1 = Vertex(-0.05, -0.05, -0.1, frame1) 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)
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 frame1.rotate(0, 0, d2r(1.5/24*360)) """EXAMPLE: Nadir pointing with +Z""" # The way we've set it up, at the start of the simulation, the satellite
from cp_utilities import d2r #, r2d from cp_plotting import plot_global_tripod, plot_frame # Toggle plotting functionality: if True: # Setting up the plot: fig = plt.figure(figsize=(10, 7)) ax = mp3d.Axes3D(fig) """ TO CHANGE THE DEFAULT CAMERA VIEW, CHANGE THESE: """ ax.view_init(elev=20, azim=-60) steps = 128 angle_step = d2r(360 / steps) frame1 = Frame() projection_frame = Frame() p1 = Vertex(-0.05, -0.05, -0.1, frame1) 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)
import matplotlib.pyplot as plt import matplotlib.animation as animation import mpl_toolkits.mplot3d as mp3d from cp_vertex import Vertex from cp_face import Face from cp_geometry import Geometry from cp_vector import Vector from cp_frame import Frame from cp_utilities import d2r #, r2d from cp_plotting import plot_global_tripod, plot_frame, \ plot_vertex, plot_face #%% ==== Manipulate objects ==== frame1 = Frame() frame1.translate(1, 1, 1) frame2 = Frame() # p1 = Vertex(0,0,0,frame1) # p2 = Vertex(1,0,0) # p3 = Vertex(1,1,0) # p4 = Vertex(0,1,0) # p5 = Vertex(0,1,1) # p6 = Vertex(0,0,1) # f1 = Face(p1, p2, p3, p4, frame1) # f2 = Face(p1, p4, p5, p6, frame1) frame1.readout()