def generate_image(spacecraft_geometry, obs_vec_body, sun_vec_body, exposure_time, win_dim=(2, 2), dpm=50, load_bar=False): """ Debugging tool, used to make animations. Generates a 2D array of grayscale pixels representing an image of A Spacecraft Geometry Object. This assumes no FOV effects. Parameters: Spacecraft_Geometry = The SpacecraftGeometry object whose image will be generated. obs_vec_body = unit vector in body frame representing the direction the spacecraft is being VIEWED from. sun_vec_body = unit vector in body frame representing the direction the spacecraft is being ILLUMINATED from. exposure_time = float representing the ammount of time the CCD was exposed for in seconds. Keyword Parameters: win_dim = A tuple representing the dimensions of the projected area of the image in meters. dpm = INteger representing how many pixels per meter to generate. Larger numbers lead to signifnicant slower run times. load_bar = True if the user wants a loading bar to appear when generating an image. """ win_pix = (win_dim[0] * dpm, win_dim[1] * dpm) image = zeros(win_pix) perspective_distance = 5 obs_vec_body = obs_vec_body / norm(obs_vec_body) camera_pos = obs_vec_body * 5 ray_direction = -obs_vec_body camera_angle = arccos(dot(ray_direction, array([0, 0, 1]))) camera_rotation = CF.axis_angle2dcm(cross(array([0, 0, 1]), ray_direction), camera_angle) for y, row in enumerate(image): if load_bar: loading_bar(y / len(image), text='Recticulating Splines') for x, pix in enumerate(row): x_pos = (x - win_pix[0] / 2) / dpm y_pos = (win_pix[1] / 2 - y) / dpm pix_pos = camera_rotation @ array([x_pos, y_pos, 0]) + camera_pos image[x, y] = spacecraft_geometry.trace_ray(pix_pos, ray_direction, sun_vec_body, exposure_time) m = amax(image) # if m == 0: # print('m = 0',obs_vec_body, sun_vec_body) if m != 0: image = image / m return image
def generate_image(spacecraft_geometry, obs_vec_body, sun_vec_body, exposure_time, win_dim=(2, 2), dpm=50, load_bar=False): """ camera_axis is the direction that the camera is pointing sun axis is the direction that the light is moving (sun to spacecraft) """ win_pix = (win_dim[0] * dpm, win_dim[1] * dpm) image = zeros(win_pix) perspective_distance = 5 obs_vec_body = obs_vec_body / norm(obs_vec_body) camera_pos = obs_vec_body * 5 ray_direction = -obs_vec_body camera_angle = arccos(dot(ray_direction, array([0, 0, 1]))) camera_rotation = CF.axis_angle2dcm(cross(array([0, 0, 1]), ray_direction), camera_angle) for y, row in enumerate(image): if load_bar: loading_bar(y / len(image), text='Recticulating Splines') for x, pix in enumerate(row): x_pos = (x - win_pix[0] / 2) / dpm y_pos = (win_pix[1] / 2 - y) / dpm pix_pos = camera_rotation @ array([x_pos, y_pos, 0]) + camera_pos image[x, y] = spacecraft_geometry.trace_ray(pix_pos, ray_direction, sun_vec_body, exposure_time) m = amax(image) # if m == 0: # print('m = 0',obs_vec_body, sun_vec_body) if m != 0: image = image / m return image