acceptance_angle=1, radius=0.001, spectral_bins=8000, spectral_rays=1, pixel_samples=5, transform=translate(*start_point) * rotate_basis(forward_vector, up_vector), parent=world) fibre.min_wavelength = 350.0 fibre.max_wavelength = 700.0 fibre.observe() # Find the next intersection point of the ray with the world intersection = world.hit(CoreRay(start_point, forward_vector)) if intersection is not None: hit_point = intersection.hit_point.transform( intersection.primitive_to_world) else: raise RuntimeError("No intersection with the vessel was found.") # Traverse the ray with equation for a parametric line, # i.e. t=0->1 traverses the ray path. parametric_vector = start_point.vector_to(hit_point) t_samples = np.arange(0, 1, 0.01) # Setup some containers for useful parameters along the ray trajectory ray_r_points = [] ray_z_points = [] distance = []
x_points = [] y_points = [] z_points = [] z_show = np.zeros((num_pixels, num_pixels)) for ix in range(num_pixels): for iy in range(num_pixels): # generate pixel transform pixel_x = image_start_x - image_delta * ix pixel_y = image_start_y - image_delta * iy # calculate point in virtual image plane to be used for ray direction origin = Point3D().transform(translate(0, 0.16, -0.7) * rotate(0, -12, 0)) direction = Vector3D(pixel_x, pixel_y, 1).normalise().transform(translate(0, 0.16, -0.7) * rotate(0, -12, 0)) intersection = world.hit(CoreRay(origin, direction)) if intersection is not None: hit_point = intersection.hit_point.transform(intersection.primitive_to_world) x_points.append(hit_point.z) y_points.append(hit_point.x) z_points.append(hit_point.y) z_show[iy, ix] = hit_point.z else: # add small offset so background is black z_show[iy, ix] = 0.1 fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(x_points, y_points, z_points, c='k', marker='.') ax.set_xlabel('X Label')