Example #1
0
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
Example #2
0
base_path = os.path.split(os.path.realpath(__file__))[0]

world = World()

#  BUNNY
mesh = import_obj(os.path.join(base_path, "../resources/stanford_bunny.obj"),
                  parent=world,
                  transform=translate(0, 0, 0) * rotate(165, 0, 0),
                  material=schott("N-BK7"))

# LIGHT BOX
padding = 1e-5
enclosure_thickness = 0.001 + padding
glass_thickness = 0.003

light_box = Node(parent=world)

enclosure_outer = Box(
    Point3D(-0.10 - enclosure_thickness, -0.02 - enclosure_thickness,
            -0.10 - enclosure_thickness),
    Point3D(0.10 + enclosure_thickness, 0.0, 0.10 + enclosure_thickness))

enclosure_inner = Box(
    Point3D(-0.10 - padding, -0.02 - padding, -0.10 - padding),
    Point3D(0.10 + padding, 0.001, 0.10 + padding))

enclosure = Subtract(enclosure_outer,
                     enclosure_inner,
                     material=Lambert(ConstantSF(0.2)),
                     parent=light_box)
     0.059, 0.058, 0.059, 0.061, 0.061, 0.063, 0.063, 0.067, 0.068, 0.072, 0.08, 0.09, 0.099, 0.124, 0.154, 0.192,
     0.255, 0.287, 0.349, 0.402, 0.443, 0.487, 0.513, 0.558, 0.584, 0.62, 0.606, 0.609, 0.651, 0.612, 0.61, 0.65, 0.638,
     0.627, 0.62, 0.63, 0.628, 0.642, 0.639, 0.657, 0.639, 0.635, 0.642])

white_reflectivity = InterpolatedSF(wavelengths, white)
red_reflectivity = InterpolatedSF(wavelengths, red)
green_reflectivity = InterpolatedSF(wavelengths, green)

# define light spectrum
light_spectrum = InterpolatedSF(array([400, 500, 600, 700]), array([0.0, 8.0, 15.6, 18.4]))

# set-up scenegraph
world = World()

# enclosing box
enclosure = Node(world)

e_back = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
             parent=enclosure,
             transform=translate(0, 0, 1) * rotate(0, 0, 0),
             material=Lambert(white_reflectivity))

e_bottom = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
               parent=enclosure,
               transform=translate(0, -1, 0) * rotate(0, -90, 0),
               # material=m)
               material=Lambert(white_reflectivity))

e_top = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
            parent=enclosure,
            transform=translate(0, 1, 0) * rotate(0, 90, 0),
Example #4
0
       world,
       transform=translate(-1.2, 0.5001, 0.6),
       material=Aluminium())
Sphere(0.5, world, transform=translate(0, 0.5001, -1.8), material=Beryllium())

Box(Point3D(-100, -0.1, -100),
    Point3D(100, 0, 100),
    world,
    material=Lambert(ConstantSF(1.0)))
Cylinder(3.0,
         8.0,
         world,
         transform=translate(4, 8, 0) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))

camera = Node(parent=world,
              transform=translate(0, 4, -3.5) * rotate(0, -48, 180))

# b = BiConvex(0.0508, 0.0036, 1.0295, 1.0295, parent=camera, transform=translate(0, 0, 0.1), material=schott("N-BK7"))
# b = BiConvex(0.0508, 0.0062, 0.205, 0.205, parent=camera, transform=translate(0, 0, 0.05), material=schott("N-BK7"))
lens = BiConvex(0.0508,
                0.0144,
                0.0593,
                0.0593,
                parent=camera,
                transform=translate(0, 0, 0.0536),
                material=schott("N-BK7"))

body = Subtract(Subtract(
    Cylinder(0.0260, 0.07, transform=translate(0, 0, 0)),
    Cylinder(0.0255, 0.06, transform=translate(0, 0, 0.005))),
                Cylinder(0.015, 0.007, transform=translate(0, 0, 0.064)),
Example #5
0
from raysect.primitive import Box
from raysect.optical import World, translate, Point3D, Node
from raysect.optical.observer import Pixel, TargettedPixel, PowerPipeline0D
from raysect.optical.material import UnitySurfaceEmitter

SAMPLES = 100000

world = World()

# # create a small emitting box, simulating a 1x10 mm slit 100 mm from a 10x10 mm pixel surface, 20mm off axis
# emitter = Box(Point3D(-0.005, -0.0005, -0.0005), Point3D(0.005, 0.0005, 0.0005), world, translate(0.02, 0, 0.10), UnitySurfaceEmitter())
# targets = [emitter]

# create a small emitting box, same as above, but split into 10 1x1x1mm cubes so that the bounding spheres are a tighter fit to the slit.
emitter = Node(parent=world, transform=translate(0.02, 0, 0.10))
targets = []
for i in range(10):
    section = Box(Point3D(-0.0005, -0.0005, -0.0005),
                  Point3D(0.0005, 0.0005, 0.0005), emitter,
                  translate(0.001 * i - 0.0045, 0, 0), UnitySurfaceEmitter())
    targets.append(section)

# setup basic pixel
basic_pipeline = PowerPipeline0D(name="Basic Pixel Observer")
basic_pixel = Pixel(parent=world,
                    pixel_samples=SAMPLES,
                    pipelines=[basic_pipeline])

# setup targetted pixel
targetted_pipeline = PowerPipeline0D(name="Targeted Pixel Observer")
Example #6
0
     0.059, 0.058, 0.059, 0.061, 0.061, 0.063, 0.063, 0.067, 0.068, 0.072, 0.08, 0.09, 0.099, 0.124, 0.154, 0.192,
     0.255, 0.287, 0.349, 0.402, 0.443, 0.487, 0.513, 0.558, 0.584, 0.62, 0.606, 0.609, 0.651, 0.612, 0.61, 0.65, 0.638,
     0.627, 0.62, 0.63, 0.628, 0.642, 0.639, 0.657, 0.639, 0.635, 0.642])

white_reflectivity = InterpolatedSF(wavelengths, white)
red_reflectivity = InterpolatedSF(wavelengths, red)
green_reflectivity = InterpolatedSF(wavelengths, green)

# define light spectrum
light_spectrum = InterpolatedSF(array([400, 500, 600, 700]), array([0.0, 8.0, 15.6, 18.4]))

# set-up scenegraph
world = World()

# enclosing box
enclosure = Node(world)

e_back = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
             parent=enclosure,
             transform=translate(0, 0, 1) * rotate(0, 0, 0),
             material=Lambert(white_reflectivity))

e_bottom = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
               parent=enclosure,
               transform=translate(0, -1, 0) * rotate(0, -90, 0),
               # material=m)
               material=Lambert(white_reflectivity))

e_top = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
            parent=enclosure,
            transform=translate(0, 1, 0) * rotate(0, 90, 0),
    0.642
])

white_reflectivity = InterpolatedSF(wavelengths, white)
red_reflectivity = InterpolatedSF(wavelengths, red)
green_reflectivity = InterpolatedSF(wavelengths, green)

# define light spectrum
light_spectrum = InterpolatedSF(array([400, 500, 600, 700]),
                                array([0.0, 8.0, 15.6, 18.4]))

# set-up scenegraph
world = World()

# enclosing box
enclosure = Node(world)

e_back = Box(Point3D(-1, -1, 0),
             Point3D(1, 1, 0),
             parent=enclosure,
             transform=translate(0, 0, 1) * rotate(0, 0, 0),
             material=Lambert(white_reflectivity))

e_bottom = Box(
    Point3D(-1, -1, 0),
    Point3D(1, 1, 0),
    parent=enclosure,
    transform=translate(0, -1, 0) * rotate(0, -90, 0),
    # material=m)
    material=Lambert(white_reflectivity))
Example #8
0
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)

camera = PinholeCamera((256, 256),
                       fov=45,