def light_box(parent, transform=None): # Notice that this function is creating and returning a parent node which holds references # to the underlying primitives. node = Node(parent=parent, transform=transform) outer = Box(Point3D(-0.01, 0, -0.05), Point3D(0.01, 0.15, 0.0)) slit = Box(Point3D(-0.0015, 0.03, -0.045), Point3D(0.0015, 0.12, 0.0001)) Subtract(outer, slit, parent=node, material=Lambert(reflectivity=ConstantSF(0.1))) Box(Point3D(-0.0015, 0.03, -0.045), Point3D(0.0015, 0.12, -0.04), parent=node, material=UniformSurfaceEmitter(d65_white, 250)) return node
print("Starting observations with volume emitter...") calculated_volume_emission = 16 / 3 * pi**2 * sphere_radius**3 * (max_wl - min_wl) emitter.material = UnityVolumeEmitter() observing_plane.observe() measured_volume_emission = 6 * power.value.mean measured_volume_error = 6 * power.value.error() # Emitter is a sphere surface emitter located at the origin # Surface area of the sphere is 4 * Pi * r^2, lambert emitter # UniformSurfaceEmitter is configured to emit 1W/str/m^2/ x nm, where x is the wavelength interval print("Starting observations with surface emitter...") calculated_surface_emission = 4 * pi**2 * sphere_radius**2 * (max_wl - min_wl) emitter.material = UniformSurfaceEmitter(ConstantSF(1.0)) observing_plane.observe() measured_surface_emission = 6 * power.value.mean measured_surface_error = 6 * power.value.error() print() print('Expected volume emission => {} W'.format(calculated_volume_emission)) print('Measured volume emission => {} +/- {} W'.format( measured_volume_emission, measured_volume_error)) print() print('Expected surface emission => {} W'.format(calculated_surface_emission)) print('Measured surface emission => {} +/- {} W'.format( measured_surface_emission, measured_surface_error))
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() ioff() # camera.pipelines[0].save("render.png") camera.pipelines[0].display() show()
0.13, transform=translate(0, 0, 0.010)), transform=rotate(0, 90, 0)), parent=stand, material=Lambert(ConstantSF(1.0))) # construct main collimated light source prism_light = light_box(parent=world, transform=rotate(-35.5, 0, 0) * translate(0.10, 0, 0) * rotate(90, 0, 0)) # background light source top_light = Sphere(0.25, parent=world, transform=translate(-1, 2, 1), material=UniformSurfaceEmitter(d65_white, scale=5)) # Give the prism a high importance to ensure adequate sampling prism.material.importance = 9 rgb = RGBPipeline2D() rgb.display_sensitivity = 2.0 sampler = RGBAdaptiveSampler2D(rgb, min_samples=500) # create and setup the camera camera = PinholeCamera((1920, 1080), fov=45, parent=world, pipelines=[rgb], frame_sampler=sampler)
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) 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-LAK9")) 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() # create and setup the camera rgb = RGBPipeline2D() rgb.accumulate = True spectral = SpectralPowerPipeline2D() spectral.accumulate = True pipelines = [rgb] camera = PinholeCamera((256, 256), parent=world, transform=translate(0, 0, -4) * rotate(0, 0, 0), pipelines=pipelines) camera.pixel_samples = 250 camera.fov = 75
red_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, red_attn)) green_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, green_attn)) blue_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, blue_attn)) yellow_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, yellow_attn)) cyan_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, cyan_attn)) purple_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, purple_attn)) Sphere(1000, world, material=UniformSurfaceEmitter(d65_white, 1.0)) node = Node(parent=world, transform=rotate(0, 0, 90)) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 0) * translate(0, 1, -0.500001), red_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 60) * translate(0, 1, -0.500001), yellow_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 120) * translate(0, 1, -0.500001), green_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 180) * translate(0, 1, -0.500001), cyan_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 240) * translate(0, 1, -0.500001), blue_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 300) * translate(0, 1, -0.500001), purple_glass)