Intersect(sphere, Subtract(cube, Union(Union(cyl_x, cyl_y), cyl_z)), world, translate(2.1, 2.1, 2.5) * rotate(-30, -20, 0), schott("SF6")) Intersect(sphere, Subtract(cube, Union(Union(cyl_x, cyl_y), cyl_z)), world, translate(2.1, -2.1, 2.5) * rotate(-30, 20, 0), schott("LF5G19")) Intersect(sphere, Subtract(cube, Union(Union(cyl_x, cyl_y), cyl_z)), world, translate(-2.1, -2.1, 2.5) * rotate(30, 20, 0), schott("N-BK7")) s1 = Sphere(1.0, transform=translate(0, 0, 1.0 - 0.01)) s2 = Sphere(0.5, transform=translate(0, 0, -0.5 + 0.01)) Intersect(s1, s2, world, translate(0, 0, -3.6) * rotate(50, 50, 0), schott("N-BK7")) Box(Point3D(-50, -50, 50), Point3D(50, 50, 50.1), world, material=Checkerboard(4, d65_white, d65_white, 0.4, 0.8)) Box(Point3D(-100, -100, -100), Point3D(100, 100, 100), world, material=UniformSurfaceEmitter(d65_white, 0.1)) ion() camera = OrthographicCamera((256, 256), width=10.0, parent=world, transform=translate(0, 0, -4) * rotate(0, 0, 0)) camera.pixel_samples = 50 camera.spectral_bins = 15 camera.observe()
BeamCXLine(Line(elements.carbon, 5, (10, 8))), BeamCXLine(Line(elements.neon, 9, (11, 10))), BeamCXLine(Line(elements.neon, 9, (12, 11))), ] beam.integrator.step = integration_step beam.integrator.min_samples = 10 # LENS ------------------------------------------------------------------------ # s1 = Sphere(1.0, transform=translate(0, 0, 1.0-0.01)) # s2 = Sphere(0.5, transform=translate(0, 0, -0.5+0.01)) # Intersect(s1, s2, world, translate(0, 0, -1.6)*rotate(-30,30,0), schott("N-BK7")) # BACKGROUND ------------------------------------------------------------------ Box(Point3D(-50, -50, 50), Point3D(50, 50, 50.1), world, material=Checkerboard(4, d65_white, d65_white, 0.001, 0.002)) # Box(Point(-100, -100, -100), Point(100, 100, 100), world, material=UniformSurfaceEmitter(d65_white, 0.001)) # OBSERVER -------------------------------------------------------------------- #import cProfile # # def profile_test(n=25000): # r = Ray(origin=Point(0.0, 0, 0), min_wavelength=526, max_wavelength=532, num_samples=100) # for i in range(n): # r.trace(world) # # cProfile.run("profile_test()", sort="tottime") ion()
import matplotlib.pyplot as plt from raysect.optical import World, translate, rotate, Point3D, d65_white from raysect.optical.observer import PinholeCamera from raysect.optical.material.emitter import Checkerboard from raysect.optical.library import schott from raysect.primitive import Sphere, Box, Cylinder, Intersect plt.ion() world = World() # Background checkerboard lightsource Box(Point3D(-10, -10, 4.0), Point3D(10, 10, 4.1), world, material=Checkerboard(1, d65_white, d65_white, 0.2, 0.8)) # Build a CSG primitive from a number of basic underlying primitives cyl_x = Cylinder(1, 4.2, transform=rotate(90, 0, 0)*translate(0, 0, -2.1)) cyl_y = Cylinder(1, 4.2, transform=rotate(0, 90, 0)*translate(0, 0, -2.1)) cyl_z = Cylinder(1, 4.2, transform=rotate(0, 0, 0)*translate(0, 0, -2.1)) cube = Box(Point3D(-1.5, -1.5, -1.5), Point3D(1.5, 1.5, 1.5)) sphere = Sphere(2.0) target = Intersect(sphere, cube, parent=world, transform=translate(0, 0, 0)*rotate(0, 0, 0), material=schott("N-BK7")) # create and setup the camera camera = PinholeCamera((256, 256), fov=45, parent=world, transform=translate(0, 0, -6) * rotate(0, 0, 0)) camera.spectral_rays = 9