Ejemplo n.º 1
0
    def place_source(self):

        # self.source = Cylinder(radius=self.vessel_in_rad-0.002, height=self.vessel_width,
        #                material=self.PlasmaEmit(shape=self.plasma_shape, count=self.plasma_count, center=self.plasma_center,
        #                                         width=self.plasma_width, power_gain=self.plasma_power_gain, flatlen=self.plasma_flat),
        #                parent=self.world, transform=translate(0, 0, 0) * rotate(0, 0, 0), name='PlasmaSource')

        self.source = Cylinder(radius=self.vessel_in_rad - 0.0015,
                               height=self.vessel_width,
                               parent=self.world,
                               transform=translate(0, 0, 0) * rotate(0, 0, 0),
                               name='PlasmaSource')

        self.lid_back = Cylinder(
            radius=self.vessel_in_rad + 0.002,
            height=0.001,
            material=AbsorbingSurface(),
            parent=self.world,
            transform=translate(0, 0, self.vessel_width + 0.0005) *
            rotate(0, 0, 0))

        self.lid_front = Cylinder(radius=self.vessel_in_rad + 0.002,
                                  height=0.001,
                                  material=AbsorbingSurface(),
                                  parent=self.world,
                                  transform=translate(0, 0, -0.0015) *
                                  rotate(0, 0, 0))
Ejemplo n.º 2
0
def equilateral_prism(width=1.0,
                      height=1.0,
                      parent=None,
                      transform=None,
                      material=None):

    half_width = width / 2
    mid_point = half_width * tan(60 / 180 * pi) / 2

    centre = Box(Point3D(-half_width * 1.001, 0, 0),
                 Point3D(half_width * 1.001, height, width))

    left = Box(Point3D(0, -height * 0.001, -width * 0.001),
               Point3D(width, height * 1.001, 2 * width),
               transform=translate(half_width, 0, 0) * rotate(30, 0, 0))

    right = Box(Point3D(-width, -height * 0.001, -width * 0.001),
                Point3D(0.0, height * 1.001, 2 * width),
                transform=translate(-half_width, 0, 0) * rotate(-30, 0, 0))

    csg_prism = Subtract(Subtract(centre, left),
                         right,
                         parent=parent,
                         transform=transform * translate(0, 0, -mid_point),
                         material=material)

    return csg_prism
Ejemplo n.º 3
0
    def place_source(self, radius, angle, legs):
        self.lamp_radius = radius
        self.lamp_angle = angle
        pos_x = -self.lamp_radius * cos(radians(self.lamp_angle))
        pos_y = self.lamp_radius * sin(radians(self.lamp_angle))
        self.source = Cylinder(
            radius=0.00205,
            height=0.15,
            parent=self.world,
            transform=translate(
                pos_x, pos_y,
                -0.0454),  # scale=(1/0.007)*(699/(26*5))*1e8* (1/(1.175*1e6)))
            material=UniformVolumeEmitter(ConstantSF(1.0),
                                          scale=1.0),  #65.372925*1e3),
            name="light cylinder")

        if legs:
            leg_radius = 0.07705
            first_leg_angle = angle + 22.5
            if radius != 0.0:
                for i in range(8):
                    leg_angle = first_leg_angle + i * 45
                    leg_n = Cylinder(radius=0.00455,
                                     height=0.15,
                                     parent=self.world,
                                     material=AbsorbingSurface(),
                                     transform=translate(
                                         -leg_radius * cos(radians(leg_angle)),
                                         leg_radius * sin(radians(leg_angle)),
                                         -0.0454))
Ejemplo n.º 4
0
def load_dms_output(config, world, plasma, spec, fibgeom):
    from raysect.optical.observer import FibreOptic, PowerPipeline0D, SpectralRadiancePipeline0D
    from raysect.optical import translate, rotate, rotate_basis
    from raysect.core import Vector3D, Point3D

    power_arr = np.zeros(fibgeom.numfibres)
    spectra_arr = np.zeros((spec.pixels, fibgeom.numfibres))

    for i, f in enumerate(power_arr):
        print("Analysing fibre: ", int(i + 1))
        fibgeom.set_fibre(number=int(i + 1))
        start_point = Point3D(fibgeom.origin[0], fibgeom.origin[1],
                              fibgeom.origin[2])
        forward_vector = Vector3D(fibgeom.xhat(), fibgeom.yhat(),
                                  fibgeom.zhat()).normalise()
        up_vector = Vector3D(0, 0, 1.0)
        if config['dms']['power_pipeline']:
            power = PowerPipeline0D()
            fibre = FibreOptic([power],
                               acceptance_angle=1,
                               radius=0.001,
                               spectral_bins=spec.pixels,
                               spectral_rays=1,
                               pixel_samples=5,
                               transform=translate(*start_point) *
                               rotate_basis(forward_vector, up_vector),
                               parent=world)
            fibre.min_wavelength = spec.wlower
            fibre.max_wavelength = spec.wupper
            fibre.observe()
            power_arr[i] = power.value.mean
        else:
            power_arr[i] = None
        if config['dms']['radiance_pipeline']:
            spectra = SpectralRadiancePipeline0D(display_progress=False)
            fibre = FibreOptic([spectra],
                               acceptance_angle=1,
                               radius=0.001,
                               spectral_bins=spec.pixels,
                               spectral_rays=1,
                               pixel_samples=5,
                               transform=translate(*start_point) *
                               rotate_basis(forward_vector, up_vector),
                               parent=world)
            fibre.min_wavelength = spec.wlower
            fibre.max_wavelength = spec.wupper
            fibre.observe()
            spectra_arr[:, i] = spectra.samples.mean
        else:
            spectra_arr[:, i] = None

    return power_arr, spectra_arr
Ejemplo n.º 5
0
    def get_proj_matrix(self, pixel_side=60, out_file="proj_matrix1"):

        geo_matrix = np.empty((32, 0))
        for pixel in range(pixel_side * pixel_side):
            print('Progress: ' +
                  str(round(100 * pixel /
                            (pixel_side * pixel_side), 1)) + " %")

            self.world = World()
            self.add_isttok()

            self.pixel_source = Cylinder(radius=self.vessel_in_rad - 0.0015,
                                         height=self.vessel_width,
                                         parent=self.world,
                                         transform=translate(0, 0, 0) *
                                         rotate(0, 0, 0),
                                         name='PlasmaSource')
            one_pixel = PixelMaterial(pixel_side=pixel_side,
                                      pixel_id=pixel,
                                      print=False)
            self.pixel_source.material = one_pixel
            self.simulate_rays()

            column = np.hstack((self.top_data, self.out_data)).reshape((32, 1))
            geo_matrix = np.hstack((geo_matrix, column))

        np.save(out_file, geo_matrix)
Ejemplo n.º 6
0
 def place_single_pixel(self, pixel_id, pixel_side=60):
     pixel_material = PixelMaterial(pixel_side=pixel_side,
                                    pixel_id=pixel_id)
     self.pixel_source = Cylinder(radius=self.vessel_in_rad - 0.0015,
                                  height=self.vessel_width,
                                  parent=self.world,
                                  transform=translate(0, 0, 0) *
                                  rotate(0, 0, 0),
                                  name='PlasmaSource',
                                  material=pixel_material)
Ejemplo n.º 7
0
def equilateral_prism(width=1.0, height=1.0, parent=None, transform=None, material=None):

    half_width = width / 2
    mid_point = half_width * tan(60/180*pi) / 2

    centre = Box(Point3D(-half_width * 1.001, 0, 0), Point3D(half_width * 1.001, height, width))

    left = Box(Point3D(0, -height * 0.001, -width * 0.001),
               Point3D(width, height * 1.001, 2 * width),
               transform=translate(half_width, 0, 0) * rotate(30, 0, 0))

    right = Box(Point3D(-width, -height * 0.001, -width * 0.001),
                Point3D(0.0, height * 1.001, 2 * width),
                transform=translate(-half_width, 0, 0) * rotate(-30, 0, 0))

    csg_prism = Subtract(Subtract(centre, left), right,
                     parent=parent, transform=transform * translate(0, 0, -mid_point),
                     material=material)

    return csg_prism
Ejemplo n.º 8
0
    def place_lamp(self, radius, angle):
        self.lamp_radius = radius
        self.lamp_angle = angle
        pos_x = -self.lamp_radius * cos(radians(self.lamp_angle))
        pos_y = self.lamp_radius * sin(radians(self.lamp_angle))
        self.lamp_source = Cylinder(radius=0.00205,
                                    height=0.15,
                                    parent=self.world,
                                    transform=translate(pos_x, pos_y, -0.0454),
                                    material=UniformVolumeEmitter(
                                        ConstantSF(1.0), scale=1.0),
                                    name="light cylinder")

        self.plot_lamp_tomogram(radius=radius, angle=angle)
Ejemplo n.º 9
0
 def place_plasma(self,
                  shape='gaussian',
                  emissiv_gain=1.0,
                  mean=None,
                  cov=None):
     fourier_plasma = PlasmaProf(shape=shape,
                                 emissiv_gain=emissiv_gain,
                                 mean=mean,
                                 cov=cov)
     # print(type(fourier_plasma))
     self.plasma_source = Cylinder(radius=self.vessel_in_rad - 0.0015,
                                   height=self.vessel_width,
                                   parent=self.world,
                                   transform=translate(0, 0, 0) *
                                   rotate(0, 0, 0),
                                   name='PlasmaSource',
                                   material=fourier_plasma)
Ejemplo n.º 10
0
# Box defining the floor
ground = Box(lower=Point3D(-100, -14.2, -100), upper=Point3D(100, -14.1, 100), material=RoughAluminium(0.05))

# Box defining the isotropic emitter
emitterIsotropic = Box(lower=Point3D(-25, -10, -10), upper=Point3D(-5, 10, 10),
              material=UniformSurfaceEmitter(d65_white), transform=rotate(0, 0, 0))
# Box defining the anisotropic emitter
emitterAnisotropic = Box(lower=Point3D(5, -10, -10), upper=Point3D(25, 10, 10),
              material=BlueYellowEmitter(), transform=rotate(0, 0, 0))


# 2. Add Observer
# ---------------

# camera
camera = PinholeCamera((384, 384), transform=translate(0, 0, -80))
camera.fov = 45
camera.pixel_samples = 250
camera.pipelines[0].accumulate = False


# 3. Build Scenegraph
# -------------------

world = World()
ground.parent = world
emitterIsotropic.parent = world
emitterAnisotropic.parent = world
camera.parent = world

Ejemplo n.º 11
0

world = World()

# construct diffuse floor surface
floor = Box(Point3D(-1000, -0.1, -1000),
            Point3D(1000, 0, 1000),
            parent=world,
            material=Lambert())

# construct prism from utility method
prism = equilateral_prism(0.06,
                          0.15,
                          parent=world,
                          material=schott("SF11"),
                          transform=translate(0, 0.0 + 1e-6, -0.01))

# Curved target screen for collecting rainbow light
stand = Intersect(
    Box(Point3D(-10, -10, -10), Point3D(10, 10, 0)),
    Subtract(Cylinder(0.21, 0.15),
             Cylinder(0.20, 0.16, transform=translate(0, 0, -0.005)),
             transform=rotate(0, 90, 0)),
    transform=translate(0.0, 1e-6, 0.0),
    parent=world,
    material=schott("N-BK7")  # RoughIron(0.25)
)

surface = Intersect(Box(Point3D(-10, -10, -10), Point3D(10, 10, -0.015)),
                    Subtract(Cylinder(0.1999,
                                      0.12,
Ejemplo n.º 12
0
from matplotlib import pyplot as plt

from raysect.primitive import Cylinder, Subtract
from raysect.optical import World, translate, rotate
from raysect.optical.observer import PinholeCamera, FullFrameSampler2D

from cherab.tools.raytransfer import RayTransferPipeline2D, RayTransferCylinder
from cherab.tools.raytransfer import RoughNickel

world = World()

# creating the scene
cylinder_inner = Cylinder(radius=80., height=140.)
cylinder_outer = Cylinder(radius=220., height=140.)
wall = Subtract(cylinder_outer, cylinder_inner, material=RoughNickel(0.1), parent=world,
                transform=translate(0, 0, -70.))

# creating ray transfer cylinder with 200 (m) outer radius, 100 (m) inner radius, 140 (m) height
# for axisymmetric cylindrical emission profile defined on a 100 x 100 (R, Z) gird
rtc = RayTransferCylinder(200., 100., 100, 100, radius_inner=100.)
# n_polar=0 by default (axisymmetric case)
rtc.parent = world
rtc.transform = translate(0, 0, -50.)

# unlike the demo with a mask, here we not only cut out a circle but also
# create 50 ring-shaped light sources using the voxel map
rad_circle = 50.
xsqr = np.linspace(-49.5, 49.5, 100) ** 2
rad = np.sqrt(xsqr[:, None] + xsqr[None, :])
voxel_map = np.zeros((100, 100), dtype=np.int)
voxel_map[rad > 50.] = -1  # removing the area outside the circle
Ejemplo n.º 13
0
from raysect.optical.library import schott
from raysect.optical.observer import PinholeCamera, RGBPipeline2D, SpectralPowerPipeline2D


red_glass = Dielectric(index=Sellmeier(1.03961212, 0.231792344, 1.01046945, 6.00069867e-3, 2.00179144e-2, 1.03560653e2),
                       transmission=InterpolatedSF([300, 490, 510, 590, 610, 800], array([0.0, 0.0, 0.0, 0.0, 1.0, 1.0])*0.7))

green_glass = Dielectric(index=Sellmeier(1.03961212, 0.231792344, 1.01046945, 6.00069867e-3, 2.00179144e-2, 1.03560653e2),
                         transmission=InterpolatedSF([300, 490, 510, 590, 610, 800], array([0.0, 0.0, 1.0, 1.0, 0.0, 0.0])*0.7))

blue_glass = Dielectric(index=Sellmeier(1.03961212, 0.231792344, 1.01046945, 6.00069867e-3, 2.00179144e-2, 1.03560653e2),
                        transmission=InterpolatedSF([300, 490, 510, 590, 610, 800], array([1.0, 1.0, 0.0, 0.0, 0.0, 0.0])*0.7))

world = World()

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)

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))
Ejemplo n.º 14
0
        wvl_centre = 0.5 * (spectrum.max_wavelength + spectrum.min_wavelength)
        wvl_range = spectrum.min_wavelength - spectrum.max_wavelength
        shift = 2 * (spectrum.wavelengths - wvl_centre) / wvl_range
        radius = sqrt(point.x**2 + point.y**2)
        spectrum.samples += cos((shift + 5) * radius)**4
        return spectrum


# scene
world = World()
emitter = Box(Point3D(-1, -1, -0.25),
              Point3D(1, 1, 0.25),
              material=CosGlow(),
              parent=world,
              transform=translate(0, 1, 0) * rotate(30, 0, 0))
floor = Box(Point3D(-100, -0.1, -100),
            Point3D(100, 0, 100),
            world,
            material=RoughTitanium(0.1))

# camera
rgb_pipeline = RGBPipeline2D(display_update_time=5)
sampler = RGBAdaptiveSampler2D(rgb_pipeline, min_samples=100, fraction=0.2)
camera = PinholeCamera((512, 512),
                       parent=world,
                       transform=translate(0, 4, -3.5) * rotate(0, -45, 0),
                       pipelines=[rgb_pipeline],
                       frame_sampler=sampler)
camera.spectral_bins = 15
camera.spectral_rays = 1
Ejemplo n.º 15
0

# 1. Create Primitives
# --------------------

# Box defining the ground plane
ground = Box(lower=Point3D(-50, -1.51, -50), upper=Point3D(50, -1.5, 50), material=Lambert())

# checker board wall that acts as emitter
emitter = Box(lower=Point3D(-10, -10, 10), upper=Point3D(10, 10, 10.1),
              material=Checkerboard(4, d65_white, d65_white, 0.1, 2.0), transform=rotate(45, 0, 0))

# Sphere
# Note that the sphere must be displaced slightly above the ground plane to prevent numerically issues that could
# cause a light leak at the intersection between the sphere and the ground.
sphere = Sphere(radius=1.5, transform=translate(0, 0.0001, 0), material=schott("N-BK7"))


# 2. Build Scenegraph
# -------------------

world = World()

sphere.parent = world
ground.parent = world
emitter.parent = world


# 3. Add Observer
# ---------------
Ejemplo n.º 16
0
                0.0052,
                0.0506,
                0.0506,
                parent=world,
                material=lens_glass)
lens.meta['viz-color'] = (66 / 255, 188 / 255, 244 / 255)
lens.meta['viz-opacity'] = 0.5

# lens.meta['viz']['color'] = (66/255, 188/255, 244/255)
# lens.meta['viz']['opacity'] = 0.5

# Create a target plane behind the lens.
target = Box(lower=Point3D(-0.05, -0.05, -0),
             upper=Point3D(0.05, 0.05, 0),
             material=AbsorbingSurface(),
             transform=translate(0, 0, 0.1),
             parent=world)
target.meta['viz-color'] = (224 / 255, 100 / 255, 17 / 255)

# for each sample direction trace a logging ray and plot the ray trajectory
plt.ion()
fig = plt.figure()
# ax = fig.gca(projection='3d')

# for u in np.linspace(-0.006, 0.006, 5):
for v in np.linspace(-0.012, 0.012, 11):

    start = Point3D(v, 0, -0.05)
    log_ray = LoggingRay(start, Vector3D(0, 0, 1))
    log_ray.trace(world)
Ejemplo n.º 17
0
from raysect.primitive import Sphere, Box, Cylinder
from raysect.optical.observer import PinholeCamera, RGBPipeline2D
from raysect.optical.material import UniformSurfaceEmitter
from raysect.optical.library import *


rough_max = 0.5

world = World()

# glass spheres
angle = 6
distance = 3
radius = 0.15

Sphere(radius, world, transform=rotate(-4 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=Aluminium())
Sphere(radius, world, transform=rotate(-3 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.125 * rough_max))
Sphere(radius, world, transform=rotate(-2 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.25 * rough_max))
Sphere(radius, world, transform=rotate(-1 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.375 * rough_max))
Sphere(radius, world, transform=rotate(0 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.5 * rough_max))
Sphere(radius, world, transform=rotate(1 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.625 * rough_max))
Sphere(radius, world, transform=rotate(2 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.750 * rough_max))
Sphere(radius, world, transform=rotate(3 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.875 * rough_max))
Sphere(radius, world, transform=rotate(4 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(1.0 * rough_max))

# metal spheres
angle = 6
distance = 3.6
radius = 0.15

Sphere(radius, world, transform=rotate(-4 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=Copper())
Ejemplo n.º 18
0
from matplotlib.pyplot import *

from raysect.optical import World, translate, rotate, Point3D, d65_white, ConstantSF, Node
from raysect.primitive import Sphere, Box, Cylinder, Subtract
from raysect.primitive.lens.spherical import BiConvex
from raysect.optical.library.metal import Gold, Silver, Copper, Titanium, Aluminium, Beryllium
from raysect.optical.material import Lambert, UniformSurfaceEmitter, AbsorbingSurface, NullMaterial
from raysect.optical.library import schott
from raysect.optical.observer import RGBPipeline2D, BayerPipeline2D, TargettedCCDArray, CCDArray, RGBAdaptiveSampler2D
from raysect.optical.colour import ciexyz_x, ciexyz_y, ciexyz_z


world = World()

Sphere(0.5, world, transform=translate(1.2, 0.5001, 0.6), material=Gold())
Sphere(0.5, world, transform=translate(0.6, 0.5001, -0.6), material=Silver())
Sphere(0.5, world, transform=translate(0, 0.5001, 0.6), material=Copper())
Sphere(0.5, world, transform=translate(-0.6, 0.5001, -0.6), material=Titanium())
Sphere(0.5, 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"))
Ejemplo n.º 19
0
from matplotlib.pyplot import *

from raysect.primitive import Sphere, Box, Cylinder
from raysect.optical import World, translate, rotate, Point3D, d65_white, ConstantSF
from raysect.optical.observer import PinholeCamera
from raysect.optical.library import Gold, Silver, Copper, Titanium, Aluminium
from raysect.optical.material import Lambert, UniformSurfaceEmitter


world = World()

Sphere(0.5, world, transform=translate(1.2, 0.5001, 0.6), material=Gold())
Sphere(0.5, world, transform=translate(0.6, 0.5001, -0.6), material=Silver())
Sphere(0.5, world, transform=translate(0, 0.5001, 0.6), material=Copper())
Sphere(0.5, world, transform=translate(-0.6, 0.5001, -0.6), material=Titanium())
Sphere(0.5, world, transform=translate(-1.2, 0.5001, 0.6), material=Aluminium())

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 = PinholeCamera((512, 512), parent=world, transform=translate(0, 4, -3.5) * rotate(0, -48, 0))
camera.spectral_bins = 15
camera.pixel_samples = 100

# start ray tracing
ion()
for p in range(1, 1000):
    print("Rendering pass {}...".format(p))
    camera.observe()
    camera.pipelines[0].save("demo_metal_{}_samples.png".format(p))
Ejemplo n.º 20
0
blue_attn = array([1.0, 1.0, 0.0, 0.0, 0.0, 0.0]) * 0.98
yellow_attn = array([0.0, 0.0, 1.0, 1.0, 1.0, 1.0]) * 0.85
cyan_attn = array([1.0, 1.0, 1.0, 1.0, 0.0, 0.0]) * 0.85
purple_attn = array([1.0, 1.0, 0.0, 0.0, 1.0, 1.0]) * 0.95

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)

camera = PinholeCamera((256, 256), fov=45, parent=world, transform=translate(0, 0, -6.5) * rotate(0, 0, 0))

ion()
camera.ray_max_depth = 500
camera.ray_extinction_prob = 0.01
camera.pixel_samples = 100
camera.spectral_rays = 1
camera.spectral_bins = 21
Ejemplo n.º 21
0
=================================

Raysect recreates of the results of Veach's thesis on multiple importance sampling.

Veach, E., 1997. Robust Monte Carlo methods for lighting simulation
(Doctoral dissertation, Ph. D. thesis, Stanford University).
"""

pixels = (1280, 720)
samples = 100

# set-up scenegraph
world = World()

# background
wall = Box(Point3D(-10, -8, 0), Point3D(10, 8, 0.1), world, transform=translate(0, -1, 10), material=UniformSurfaceEmitter(d65_white, 0.00005))
wall.material.importance = 0

# emitting spheres
Sphere(radius=0.5, parent=world, transform=translate(-2, 3, 2), material=UniformSurfaceEmitter(light_blue))
Sphere(radius=0.2, parent=world, transform=translate(-0.667, 3, 2), material=UniformSurfaceEmitter(green, scale=0.5**2/0.2**2))
Sphere(radius=0.05, parent=world, transform=translate(0.667, 3, 2), material=UniformSurfaceEmitter(orange, scale=0.5**2/0.05**2))
Sphere(radius=0.008, parent=world, transform=translate(2, 3, 2), material=UniformSurfaceEmitter(red, scale=0.5**2/0.008**2))

# reflecting plates
Box(lower=Point3D(-3, -0.1, -0.5), upper=Point3D(3, 0.1, 0.5), parent=world,
    transform=translate(0, 1.5, 2)*rotate(0, 45.5, 0), material=RoughAluminium(0.0003))

Box(lower=Point3D(-3, -0.1, -0.5), upper=Point3D(3, 0.1, 0.5), parent=world,
    transform=translate(0, 0.7, 1)*rotate(0, 32, 0), material=RoughAluminium(0.005))
Ejemplo n.º 22
0
        wvl_centre = 0.5 * (spectrum.max_wavelength + spectrum.min_wavelength)
        wvl_range = spectrum.min_wavelength - spectrum.max_wavelength
        shift = 2 * (spectrum.wavelengths - wvl_centre) / wvl_range
        radius = sqrt(point.x**2 + point.y**2)
        spectrum.samples += cos((shift + 5) * radius)**4
        return spectrum


# scene
world = World()

# boxes
box_unshifted = Box(
    Point3D(-1, -1, -0.25), Point3D(1, 1, 0.25),
    material=CosGlow(),
    parent=world, transform=translate(3.2, 1, 0) * rotate(-30, 0, 0)
)

box_down_shifted = Box(
    Point3D(-1, -1, -0.25), Point3D(1, 1, 0.25),
    material=VolumeTransform(CosGlow(), translate(0, 0.5, 0)),
    parent=world, transform=translate(1.1, 1, 0.8) * rotate(-10, 0, 0)
)

box_up_shifted = Box(
    Point3D(-1, -1, -0.25), Point3D(1, 1, 0.25),
    material=VolumeTransform(CosGlow(), translate(0, -0.5, 0)),
    parent=world, transform=translate(-1.1, 1, 0.8) * rotate(10, 0, 0)
)

box_rotated = Box(
Ejemplo n.º 23
0
        wvl_range = spectrum.min_wavelength - spectrum.max_wavelength
        shift = 2 * (spectrum.wavelengths - wvl_centre) / wvl_range
        radius = sqrt(point.x**2 + point.y**2)
        spectrum.samples += cos((shift + 5) * radius)**4
        return spectrum


# scene
world = World()

# boxes
box_unshifted = Box(Point3D(-1, -1, -0.25),
                    Point3D(1, 1, 0.25),
                    material=CosGlow(),
                    parent=world,
                    transform=translate(3.2, 1, 0) * rotate(-30, 0, 0))

box_down_shifted = Box(Point3D(-1, -1, -0.25),
                       Point3D(1, 1, 0.25),
                       material=VolumeTransform(CosGlow(),
                                                translate(0, 0.5, 0)),
                       parent=world,
                       transform=translate(1.1, 1, 0.8) * rotate(-10, 0, 0))

box_up_shifted = Box(Point3D(-1, -1, -0.25),
                     Point3D(1, 1, 0.25),
                     material=VolumeTransform(CosGlow(), translate(0, -0.5,
                                                                   0)),
                     parent=world,
                     transform=translate(-1.1, 1, 0.8) * rotate(10, 0, 0))
Ejemplo n.º 24
0
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")
targetted_pixel = TargettedPixel(parent=world, targets=targets, pixel_samples=SAMPLES, pipelines=[targetted_pipeline])
targetted_pixel.targetted_path_prob = 1
Ejemplo n.º 25
0
green_glass = Dielectric(
    index=Sellmeier(1.03961212, 0.231792344, 1.01046945, 6.00069867e-3,
                    2.00179144e-2, 1.03560653e2),
    transmission=InterpolatedSF([300, 490, 510, 590, 610, 800],
                                array([0.0, 0.0, 1.0, 1.0, 0.0, 0.0]) * 0.7))

blue_glass = Dielectric(
    index=Sellmeier(1.03961212, 0.231792344, 1.01046945, 6.00069867e-3,
                    2.00179144e-2, 1.03560653e2),
    transmission=InterpolatedSF([300, 490, 510, 590, 610, 800],
                                array([1.0, 1.0, 0.0, 0.0, 0.0, 0.0]) * 0.7))

world = World()

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)

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))
Ejemplo n.º 26
0
image_start_x = 0.5 * num_pixels * image_delta
image_start_y = 0.5 * num_pixels * image_delta

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()
Ejemplo n.º 27
0
d_gamma_recom = RecombinationLine(d_gamma, lineshape=StarkBroadenedLine)
d_delta_excit = ExcitationLine(d_delta, lineshape=StarkBroadenedLine)
d_delta_recom = RecombinationLine(d_delta, lineshape=StarkBroadenedLine)
d_epsilon_excit = ExcitationLine(d_epsilon, lineshape=StarkBroadenedLine)
d_epsilon_recom = RecombinationLine(d_epsilon, lineshape=StarkBroadenedLine)
plasma.models = [d_alpha_excit, d_alpha_recom, d_beta_excit, d_beta_recom, d_gamma_excit,
                 d_gamma_recom, d_delta_excit, d_delta_recom, d_epsilon_excit, d_epsilon_recom]


start_point = Point3D(1.669, 0, -1.6502)
forward_vector = Vector3D(1-1.669, 0, -2+1.6502).normalise()
up_vector = Vector3D(0, 0, 1.0)

spectra = SpectralRadiancePipeline0D()
fibre = FibreOptic([spectra], acceptance_angle=1, radius=0.001, spectral_bins=800000, 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,
Ejemplo n.º 28
0
A Diamond Stanford Bunny on an Illuminated Glass Pedestal
---------------------------------------------------------

Bunny model source:
  Stanford University Computer Graphics Laboratory
  http://graphics.stanford.edu/data/3Dscanrep/
  Converted to obj format using MeshLab
"""

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)
Ejemplo n.º 29
0
r, _, z, t_samples = sample3d(h0.distribution.density, (-1, 2, 200), (0, 0, 1),
                              (-1, 1, 200))
plt.imshow(np.transpose(np.squeeze(t_samples)), extent=[-1, 2, -1, 1])
plt.colorbar()
plt.axis('equal')
plt.xlabel('x axis')
plt.ylabel('z axis')
plt.title("Neutral Density profile in x-z plane")

###########################
# Inject beam into plasma #

adas = OpenADAS(permit_extrapolation=True, missing_rates_return_null=True)

integration_step = 0.0025
beam_transform = translate(-0.5, 0.0, 0) * rotate_basis(
    Vector3D(1, 0, 0), Vector3D(0, 0, 1))

beam_energy = 110000  # keV
beam_current = 10  # A
beam_sigma = 0.05
beam_divergence = 0.5
beam_length = 3.0
beam_temperature = 20

bes_full_model = BeamEmissionLine(Line(deuterium, 0, (3, 2)),
                                  sigma_to_pi=SIGMA_TO_PI,
                                  sigma1_to_sigma0=SIGMA1_TO_SIGMA0,
                                  pi2_to_pi3=PI2_TO_PI3,
                                  pi4_to_pi3=PI4_TO_PI3)
Ejemplo n.º 30
0
class CosGlow(InhomogeneousVolumeEmitter):

    def emission_function(self, point, direction, spectrum, world, ray, primitive, to_local, to_world):

        wvl_centre = 0.5 * (spectrum.max_wavelength + spectrum.min_wavelength)
        wvl_range = spectrum.min_wavelength - spectrum.max_wavelength
        shift = 2 * (spectrum.wavelengths - wvl_centre) / wvl_range
        radius = sqrt(point.x**2 + point.y**2)
        spectrum.samples += cos((shift + 5) * radius)**4
        return spectrum


# scene
world = World()
emitter = Box(Point3D(-1, -1, -0.25), Point3D(1, 1, 0.25), material=CosGlow(), parent=world, transform=translate(0, 1, 0) * rotate(30, 0, 0))
floor = Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=RoughTitanium(0.1))

# camera
rgb_pipeline = RGBPipeline2D(display_update_time=5)
sampler = RGBAdaptiveSampler2D(rgb_pipeline, min_samples=100, fraction=0.2)
camera = PinholeCamera((512, 512), parent=world, transform=translate(0, 4, -3.5) * rotate(0, -45, 0), pipelines=[rgb_pipeline], frame_sampler=sampler)
camera.spectral_bins = 15
camera.spectral_rays = 1
camera.pixel_samples = 200
camera.render_engine = MulticoreEngine(4)

# integration resolution
emitter.material.integrator.step = 0.05

# start ray tracing
Ejemplo n.º 31
0
from raysect.primitive.parabola import Parabola

rotation = 90.0

# Instantiate world object
world = World()

# Create lens objects
# Parabola(radius=0.5, height=0.1, parent=world, material=schott("N-BK7"), transform=translate(0.05, 0, 0) * rotate(90, 0, 0))
# Parabola(radius=0.1, height=0.1, parent=world, material=Dielectric(ConstantSF(1.4), ConstantSF(0.01)), transform=translate(0.05, 0, 0) * rotate(0, 0, 0))
# Parabola(radius=0.25, height=0.5, parent=world, material=Gold(), transform=translate(0, 0, 0)*rotate(0, -90, 0))
Parabola(radius=0.1,
         height=0.2,
         parent=world,
         material=schott("N-BK7"),
         transform=translate(0, 0, 0) * rotate(0, 100, 0))
# Sphere(radius=0.1, parent=world, material=Dielectric(ConstantSF(1.0), ConstantSF(0.02)), transform=translate(0, 0, 0) * rotate(0, 0, 0))
# Parabola(radius=1000, height=0.1, parent=world, material=schott("N-BK7"), transform=translate(0, 0, 0) * rotate(0, 0, 0))
# Parabola(radius=0.1, height=0.05, parent=world, material=Lambert(), transform=translate(0, 0, 0) * rotate(270, 0, 0))

# Background Checkerboard
Box(Point3D(-50.0, -50.0, 50),
    Point3D(50.0, 50.0, 50.1),
    world,
    material=Checkerboard(10, d65_white, d65_white, 0.4, 0.8))

# Instantiate camera object, and configure its settings.
plt.ion()
camera = PinholeCamera((256, 256),
                       fov=45,
                       parent=world,
Ejemplo n.º 32
0
# Box defining the ground plane
ground = Box(lower=Point3D(-50, -1.51, -50),
             upper=Point3D(50, -1.5, 50),
             material=Lambert())

# checker board wall that acts as emitter
emitter = Box(lower=Point3D(-10, -10, 10),
              upper=Point3D(10, 10, 10.1),
              material=Checkerboard(4, d65_white, d65_white, 0.1, 2.0),
              transform=rotate(45, 0, 0))

# Sphere
# Note that the sphere must be displaced slightly above the ground plane to prevent numerically issues that could
# cause a light leak at the intersection between the sphere and the ground.
sphere = Sphere(radius=1.5,
                transform=translate(0, 0.0001, 0),
                material=schott("N-BK7"))

# 2. Build Scenegraph
# -------------------

world = World()

sphere.parent = world
ground.parent = world
emitter.parent = world

# 3. Add Observer
# ---------------

spectra = SpectralPowerPipeline0D()
Ejemplo n.º 33
0
# Setup deuterium line
d_alpha = Line(deuterium, 0, (3, 2), wavelength=656.19)

# Load the deuterium atom species and electron distribution for use in rate calculations.
d_atom_species = plasma.get_species(deuterium, 0)
electrons = plasma.electron_distribution

# Load the Excitation and Recombination lines and add them as emitters to the world.
d_alpha_excit = ExcitationLine(d_alpha, plasma.electron_distribution, d_atom_species)

outer_radius = plasma.misc_properties['maxr'] + 0.001
plasma_height = plasma.misc_properties['maxz'] - plasma.misc_properties['minz']
lower_z = plasma.misc_properties['minz']

main_plasma_cylinder = Cylinder(outer_radius, plasma_height, parent=world,
                                material=d_alpha_excit, transform=translate(0, 0, lower_z))

# Load a MAST-U midplane camera
camera_config = load_calcam_calibration('./demo/mast/camera_configs/mug_bulletb_midplane.nc')

# Setup camera for interactive use...
pixels_shape, pixel_origins, pixel_directions = camera_config
camera = VectorCamera(pixel_origins, pixel_directions, pixels=pixels_shape, parent=world)
camera.spectral_samples = 15
camera.pixel_samples = 1
camera.display_progress = True
camera.display_update_time = 20
ion()
camera.observe()

Ejemplo n.º 34
0
    def add_isttok(self, pixel_samples=1000000):
        nickel_roughness = 0.23
        min_wl = 50
        max_wl = 51

        # add vessel and cameras
        self.vessel = import_stl(
            "../isttok_3d/vessel5_stl.stl",
            scaling=1,
            mode='binary',
            parent=self.world,
            material=RoughNickel(nickel_roughness),  #AbsorbingSurface(),
            transform=translate(0, 0, 0) * rotate(0, 0, 0))

        self.camera_top = import_stl(
            "../isttok_3d/camera_top3_stl.stl",
            scaling=1,
            mode='binary',
            parent=self.world,
            material=AbsorbingSurface(),
            transform=translate(
                self.x_shift_top, self.y_shift_top + self.tube_height +
                self.lid_top, self.vessel_width / 2.0) * rotate(0, -90, 0))

        # self.camera_outer = import_stl("../isttok_3d/camera_outer3_stl.stl", scaling=1, mode='binary', parent=self.world,
        #                                material=AbsorbingSurface(),
        #                                transform=translate(self.x_shift_outer - self.tube_height - self.lid_outer,
        #                                                    0.0,
        #                                                    self.vessel_width / 2.0) * rotate(-90, 0, 0))

        self.camera_outer = import_stl(
            "../isttok_3d/camera_outer4_newpin_stl.stl",
            scaling=1,
            mode='binary',
            parent=self.world,
            material=AbsorbingSurface(),
            transform=translate(
                self.x_shift_outer - self.tube_height - self.lid_outer, 0.0,
                self.vessel_width / 2.0) * rotate(-90, 0, 0))

        pinhole_sphere_radius = 0.0005  # 0.0005
        self.top_pinhole = Sphere(radius=pinhole_sphere_radius,
                                  parent=self.world,
                                  transform=translate(self.x_shift_top,
                                                      self.y_shift_top,
                                                      self.vessel_width / 2),
                                  material=Vacuum())
        pinhole_sphere_radius = 0.00035  # 0.0005
        self.out_pinhole = Sphere(radius=pinhole_sphere_radius,
                                  parent=self.world,
                                  transform=translate(self.x_shift_outer, 0.0,
                                                      self.vessel_width / 2),
                                  material=Vacuum())

        for i in range(16):
            self.top_power.append(PowerPipeline0D(accumulate=False))
            self.out_power.append(PowerPipeline0D(accumulate=False))

            top_px_x = self.top_px_first_x - i * 0.00095
            top_px_y = self.top_px_first_y - i * 2 * (self.top_twist / 15)
            top_angle = degrees(asin(2 * self.top_twist / 0.01425))

            out_px_y = self.out_px_first_y - i * 0.00095
            out_px_x = self.out_px_first_x - i * 2 * (self.out_twist / 15)
            out_angle = -degrees(asin(2 * self.out_twist / 0.01425))

            self.top_px.append(
                TargettedPixel(
                    targets=[self.top_pinhole],
                    targetted_path_prob=1.0,
                    pipelines=[self.top_power[i]],
                    x_width=0.00075,
                    y_width=0.00405,
                    min_wavelength=min_wl,
                    max_wavelength=max_wl,
                    spectral_bins=1,
                    pixel_samples=pixel_samples,
                    parent=self.world,
                    quiet=True,
                    ray_importance_sampling=True,
                    ray_important_path_weight=0.05,
                    ray_max_depth=50,
                    transform=translate(top_px_x, top_px_y, self.top_px_z) *
                    rotate(0, 0, top_angle) * rotate(0, -90, 0)))

            self.out_px.append(
                TargettedPixel(
                    targets=[self.out_pinhole],
                    targetted_path_prob=1.0,
                    pipelines=[self.out_power[i]],
                    x_width=0.00075,
                    y_width=0.00405,
                    min_wavelength=min_wl,
                    max_wavelength=max_wl,
                    spectral_bins=1,
                    pixel_samples=pixel_samples,
                    parent=self.world,
                    quiet=True,
                    ray_importance_sampling=True,
                    ray_important_path_weight=0.05,
                    ray_max_depth=50,
                    transform=translate(out_px_x, out_px_y, self.out_px_z) *
                    rotate(0, 0, out_angle) * rotate(-90, 0, 90)))
Ejemplo n.º 35
0
-------------------------------------------------------

Bunny model source:
  Stanford University Computer Graphics Laboratory
  http://graphics.stanford.edu/data/3Dscanrep/
  Converted to obj format using MeshLab
"""

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(
Ejemplo n.º 36
0
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
camera.spectral_bins = 30
rgb = camera.pipelines[0]

# for each frame rotate the CSG primitive and re-render
Ejemplo n.º 37
0
                                    d_ion_species,
                                    inside_outside=plasma.inside_outside)
d_epsilon_recom.add_emitter_to_world(world, plasma)

start_point = Point3D(1.669, 0, -1.6502)
forward_vector = Vector3D(1 - 1.669, 0, -2 + 1.6502).normalise()
up_vector = Vector3D(0, 0, 1.0)

spectra = SpectralPipeline0D()
fibre = FibreOptic([spectra],
                   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.")
Ejemplo n.º 38
0
        material=UniformSurfaceEmitter(d65_white, 250))

    return node


world = World()


# construct diffuse floor surface
floor = Box(Point3D(-1000, -0.1, -1000), Point3D(1000, 0, 1000),
            parent=world, material=Lambert())


# construct prism from utility method
prism = equilateral_prism(0.06, 0.15, parent=world,
                          material=schott("SF11"), transform=translate(0, 0.0 + 1e-6, 0))


# Curved target screen for collecting rainbow light
screen = Intersect(
    Box(Point3D(-10, -10, -10), Point3D(10, 10, 0)),
    Subtract(Cylinder(0.22, 0.15),
             Cylinder(0.20, 0.16, transform=translate(0, 0, -0.005)),
             transform=rotate(0, 90, 0)),
    parent=world,
    material=Lambert()
)


# construct main collimated light source
prism_light = light_box(parent=world,
Ejemplo n.º 39
0

"""
World contains point
--------------------

This demo shows how the world.contains() method can be used to query the world for
all primitives that intersect the test point. This simple scene contains a Sphere
at the origin of radius 0.5m. A grid of test points is generated in the x-y plane.
Each point is tested to see if it lies inside the sphere.
"""

world = World()

# Place test sphere at origin
sphere = Sphere(radius=0.5, transform=translate(0, 0, 0), material=schott("N-BK7"))
sphere.parent = world

# Construct test points in x-y plane

xpts = np.linspace(-1.0, 1.0)
ypts = np.linspace(-1.0, 1.0)

x_inside = []
y_inside = []
x_outside = []
y_outside = []

for x in xpts:
    for y in ypts:
Ejemplo n.º 40
0
from raysect.optical.observer import PinholeCamera, RGBPipeline2D, RGBAdaptiveSampler2D
from raysect.optical.library import RoughTitanium
from raysect.optical.material import UniformSurfaceEmitter, UniformVolumeEmitter, Dielectric, Sellmeier


# DIAMOND MATERIAL
diamond_material = Dielectric(Sellmeier(0.3306, 4.3356, 0.0, 0.1750**2, 0.1060**2, 0.0), ConstantSF(1))
diamond_material.importance = 2

world = World()

base_path = os.path.split(os.path.realpath(__file__))[0]

# the diamond
diamond = import_obj(os.path.join(base_path, "../resources/diamond.obj"), scaling=0.01, smoothing=False, parent=world,
                     transform=translate(0.0, 0.713001, 0.0)*rotate(-10, 0, 0), material=diamond_material)

# floor
Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=RoughTitanium(0.1))

# front light
Sphere(5, world, transform=translate(1, 8, -10), material=UniformVolumeEmitter(d65_white, 1.0))

# fill light
Sphere(10, world, transform=translate(7, 20, 20), material=UniformSurfaceEmitter(d65_white, 0.15))

# camera
rgb_pipeline = RGBPipeline2D(display_update_time=15, display_unsaturated_fraction=0.998)
sampler = RGBAdaptiveSampler2D(rgb_pipeline, min_samples=400, fraction=0.1)
camera = PinholeCamera((1024, 1024), parent=world, transform=translate(0, 4, -3.5) * rotate(0, -46, 0), pipelines=[rgb_pipeline], frame_sampler=sampler)
camera.spectral_bins = 18
Ejemplo n.º 41
0
from matplotlib.pyplot import *
from numpy import array

from raysect.primitive import Sphere, Box, Cylinder, Union, Intersect, Subtract
from raysect.optical import World, translate, rotate, Point3D, d65_white, InterpolatedSF
from raysect.optical.material.emitter import UniformSurfaceEmitter, Checkerboard
from raysect.optical.material.dielectric import Dielectric, Sellmeier
from raysect.optical.library import schott
from raysect.optical.observer import PinholeCamera, RGBPipeline2D, SpectralPowerPipeline2D

world = World()

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))

# 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"))
# Union(Union(cyl_x, cyl_y), cyl_z, world)
Intersect(Intersect(cyl_x, cyl_y), cyl_z, world)
# Intersect(cyl_x, cyl_y, world)
# Union(cyl_y, cyl_z, world)
# Union(cyl_z, cyl_x, world)

camera = PinholeCamera((256, 256),
                       parent=world,
                       transform=translate(0, 0, -4) * rotate(0, 0, 0))

from raysect.vtk import visualise_scenegraph

visualise_scenegraph(camera)
Ejemplo n.º 42
0
from raysect.optical.material.emitter import Checkerboard
from raysect.optical.library import schott

from raysect.primitive import Box


# Import the new lens classes
from raysect.primitive.lens.spherical import *

rotation = 90.0

# Instantiate world object
world = World()

# Create lens objects
BiConvex(0.0254, 0.0052, 0.0506, 0.0506, parent=world, transform=translate(0.02, 0.02, 0) * rotate(rotation, 0.0, 0.0), material=schott("N-BK7"))
BiConcave(0.0254, 0.0030, 0.052, 0.052, parent=world, transform=translate(-0.02, 0.02, 0) * rotate(rotation, 0.0, 0.0), material=schott("N-BK7"))
PlanoConvex(0.0254, 0.0053, 0.0258, parent=world, transform=translate(0.02, -0.02, 0) * rotate(rotation, 0.0, 0.0), material=schott("N-BK7"))
PlanoConcave(0.0254, 0.0035, 0.0257, parent=world, transform=translate(-0.02, -0.02, 0) * rotate(rotation, 0.0, 0.0), material=schott("N-BK7"))
Meniscus(0.0254, 0.0036, 0.0321, 0.0822, parent=world, transform=translate(0, 0, 0) * rotate(rotation, 0.0, 0.0), material=schott("N-BK7"))

# Background Checkerboard
Box(Point3D(-50.0, -50.0, 0.1), Point3D(50.0, 50.0, 0.2), world, material=Checkerboard(0.01, d65_white, d65_white, 0.4, 0.8))

# Instantiate camera object, and configure its settings.
plt.ion()
camera = PinholeCamera((512, 512), fov=45, parent=world, transform=translate(0, 0, -0.1) * rotate(0, 0, 0))
camera.pixel_samples = 100
camera.spectral_rays = 1
camera.spectral_bins = 20
Ejemplo n.º 43
0
    def check_scene(self, max_iter=200):

        self.vessel.material = Lambert(blue)
        self.camera_outer.material = Lambert(yellow)
        self.camera_top.material = Lambert(yellow)
        self.source.material = Lambert(green)
        self.top_pinhole.material = Lambert(green)
        self.out_pinhole.material = Lambert(green)

        # cube walls
        bottom = Box(lower=Point3D(-0.99, -1.02, -0.99),
                     upper=Point3D(0.99, -1.01, 0.99),
                     parent=self.world,
                     material=Lambert(red))
        # top = Box(lower=Point3D(-0.99, 1.01, -0.99), upper=Point3D(0.99, 1.02, 0.99), parent=self.world,
        #           material=Lambert(red))
        left = Box(lower=Point3D(1.01, -0.99, -0.99),
                   upper=Point3D(1.02, 0.99, 0.99),
                   parent=self.world,
                   material=Lambert(yellow))
        # right = Box(lower=Point3D(-1.02, -0.99, -0.99), upper=Point3D(-1.01, 0.99, 0.99), parent=self.world,
        #             material=Lambert(purple))
        back = Box(lower=Point3D(-0.99, -0.99, 1.01),
                   upper=Point3D(0.99, 0.99, 1.02),
                   parent=self.world,
                   material=Lambert(orange))

        # various wall light sources
        light_front = Box(lower=Point3D(-1.5, -1.5, -10.1),
                          upper=Point3D(1.5, 1.5, -10),
                          parent=self.world,
                          material=UniformSurfaceEmitter(d65_white, 1.0))
        light_top = Box(lower=Point3D(-0.99, 1.01, -0.99),
                        upper=Point3D(0.99, 1.02, 0.99),
                        parent=self.world,
                        material=UniformSurfaceEmitter(d65_white, 1.0),
                        transform=translate(0, 1.0, 0))

        light_bottom = Box(lower=Point3D(-0.99, -3.02, -0.99),
                           upper=Point3D(0.99, -3.01, 0.99),
                           parent=self.world,
                           material=UniformSurfaceEmitter(d65_white, 1.0),
                           transform=translate(0, 1.0, 0))

        light_right = Box(lower=Point3D(-1.92, -0.99, -0.99),
                          upper=Point3D(-1.91, 0.99, 0.99),
                          parent=self.world,
                          material=UniformSurfaceEmitter(d65_white, 1.0))

        light_left = Box(lower=Point3D(1.91, -0.99, -0.99),
                         upper=Point3D(1.92, 0.99, 0.99),
                         parent=self.world,
                         material=UniformSurfaceEmitter(d65_white, 1.0))

        # Process the ray-traced spectra with the RGB pipeline.
        rgb = RGBPipeline2D()

        # camera
        pix = 1000
        camera = PinholeCamera(
            (pix, pix),
            pipelines=[rgb],
            transform=translate(-0.01, 0.0, -0.25) * rotate(0, 0, 0))
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(0.0, 0.0, 0.4) * rotate(180, 0, 0))
        # top view
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(0.0, self.vessel_out_rad+0.15, self.vessel_width/2)*rotate(0, -90, 0))
        # prof
        camera = PinholeCamera(
            (pix, pix),
            pipelines=[rgb],
            transform=translate(-0.13, 0.13, -0.2) * rotate(-25, -25.0, 0))

        # camera top side
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top, self.top_px_first_y+0.0004, self.top_px_z-self.cam_in_radius+0.005)*rotate(0, 0, 0))
        # camera top down-up
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top, self.top_px_first_y-0.01, self.vessel_width/2)*rotate(0, 90, 0))
        # camera top up-down
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top-0.004, self.top_px_first_y+self.lid_top+self.tube_height-0.01, self.vessel_width/2)*rotate(0, -90, 0))

        # camera out side
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(-self.vessel_out_rad-0.015, 0.000, self.vessel_width/2-self.cam_in_radius/2+0.0001))
        # camera out down-up
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.out_px_first_x+0.005+0.005, 0.0, self.vessel_width/2)*rotate(90, 0, 0))
        # camera out up-down
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(-self.vessel_out_rad-self.tube_height-0.01, 0.0, self.vessel_width/2-0.005)*rotate(-90, 0, 0))

        # camera - pixel sampling settings
        camera.fov = 60  # 45
        camera.pixel_samples = 10

        # camera - ray sampling settings
        camera.spectral_rays = 1
        camera.spectral_bins = 25
        camera.parent = self.world

        plt.ion()
        p = 1
        while not camera.render_complete:
            print("Rendering pass {}...".format(p))
            camera.observe()
            print()
            p += 1
            if p > max_iter:
                break

        plt.ioff()
        rgb.display()
Ejemplo n.º 44
0
angle = 6
distance = 3
radius = 0.15

for i in range(9):
    roughness = roughness_scan[i]
    increment = angle_increments[i]

    # use raw material if roughness = 0
    if roughness == 0:
        material = schott("N-BK7")
    else:
        material = Roughen(schott("N-BK7"), roughness)

    Sphere(radius, world,
           transform=rotate(increment * angle, 0, 0) * translate(0, radius + 0.00001, distance),
           material=material)

# metal spheres
angle = 6
distance = 3.6
radius = 0.15

for i in range(9):
    roughness = roughness_scan[i]
    increment = angle_increments[i]

    # use raw material if roughness = 0
    if roughness == 0:
        material = Aluminium()
    else:
Ejemplo n.º 45
0

# 1. Create Primitives
# --------------------

# Box defining the ground plane
ground = Box(lower=Point3D(-50, -1.51, -50), upper=Point3D(50, -1.5, 50), material=Lambert())

# checker board wall that acts as emitter
emitter = Box(lower=Point3D(-10, -10, 10), upper=Point3D(10, 10, 10.1),
              material=Checkerboard(4, d65_white, d65_white, 0.1, 2.0), transform=rotate(45, 0, 0))

# Sphere
# Note that the sphere must be displaced slightly above the ground plane to prevent numerically issues that could
# cause a light leak at the intersection between the sphere and the ground.
sphere = Sphere(radius=1.5, transform=translate(0, 0.0001, 0), material=schott("N-BK7"))


# 2. Add Observer
# ---------------

# Process the ray-traced spectra with the RGB pipeline.
rgb = RGBPipeline2D()

# camera
camera = PinholeCamera((512, 512), pipelines=[rgb], transform=translate(0, 10, -10) * rotate(0, -45, 0))

# camera - pixel sampling settings
camera.fov = 45
camera.pixel_samples = 250
Ejemplo n.º 46
0
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),
            material=Lambert(white_reflectivity))

e_left = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
             parent=enclosure,
Ejemplo n.º 47
0
# Import the new lens classes
from raysect.primitive.lens.spherical import *

rotation = 90.0

# Instantiate world object
world = World()

# Create lens objects
BiConvex(0.0254,
         0.0052,
         0.0506,
         0.0506,
         parent=world,
         transform=translate(0.02, 0.02, 0) * rotate(rotation, 0.0, 0.0),
         material=schott("N-BK7"))
BiConcave(0.0254,
          0.0030,
          0.052,
          0.052,
          parent=world,
          transform=translate(-0.02, 0.02, 0) * rotate(rotation, 0.0, 0.0),
          material=schott("N-BK7"))
PlanoConvex(0.0254,
            0.0053,
            0.0258,
            parent=world,
            transform=translate(0.02, -0.02, 0) * rotate(rotation, 0.0, 0.0),
            material=schott("N-BK7"))
PlanoConcave(0.0254,
Ejemplo n.º 48
0
from raysect.primitive import Sphere
"""
World contains point
--------------------

This demo shows how the world.contains() method can be used to query the world for
all primitives that intersect the test point. This simple scene contains a Sphere
at the origin of radius 0.5m. A grid of test points is generated in the x-y plane.
Each point is tested to see if it lies inside the sphere.
"""

world = World()

# Place test sphere at origin
sphere = Sphere(radius=0.5,
                transform=translate(0, 0, 0),
                material=schott("N-BK7"))
sphere.parent = world

# Construct test points in x-y plane

xpts = np.linspace(-1.0, 1.0)
ypts = np.linspace(-1.0, 1.0)

x_inside = []
y_inside = []
x_outside = []
y_outside = []

for x in xpts:
    for y in ypts:
Ejemplo n.º 49
0
angle = 6
distance = 3.6
radius = 0.15

for i in range(9):
    temperature = temperature_scan[i]
    increment = angle_increments[i]

    material = Add(RoughIron(0.05),
                   UniformSurfaceEmitter(BlackBody(temperature)),
                   surface_only=True)

    Sphere(radius,
           world,
           transform=rotate(increment * angle, 0, 0) *
           translate(0, radius + 0.00001, distance),
           material=material)

# glass spheres
angle = 6
distance = 3
radius = 0.15

for i in range(9):
    temperature = temperature_scan[i]
    increment = angle_increments[i]

    # WARNING: This is an unphysical demo, the attenuation of the glass is not applied to the black body emission.
    # WARNING: The full volume emission is simply added to the light transmitted through the glass.
    # WARNING: In practice, only all emitting volumes or all absorbing volumes should be physically combined.
    # WARNING: This demo highlights the risks of using modifiers without considering the raytracing process.
Ejemplo n.º 50
0
world = World()

angle_increments = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
roughness = 0.25
colours = [yellow, orange, red_orange, red, purple, blue, light_blue, cyan, green]

# coloured metal spheres
angle = 6
radius = 0.12
distance = 3.2

for i in range(9):
    increment = angle_increments[i]
    Sphere(radius, world,
           transform=rotate(increment * angle, 0, 0) * translate(0, radius + 0.00001, distance),
           material=UniformSurfaceEmitter(colours[i]))

# diffuse ground plane
Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=Lambert(ConstantSF(0.5)))

rgb = RGBPipeline2D(name="sRGB")
sampler = RGBAdaptiveSampler2D(rgb, ratio=10, fraction=0.2, min_samples=500, cutoff=0.05)

# observer
camera = PinholeCamera((512, 256), fov=42, parent=world, transform=translate(0, 3.3, 0) * rotate(0, -47, 0), pipelines=[rgb], frame_sampler=sampler)
camera.spectral_bins = 25
camera.pixel_samples = 250

# start ray tracing
ion()
Ejemplo n.º 51
0
Archivo: beam.py Proyecto: cherab/core
c6_distribution = Maxwellian(c6_density, temperature, bulk_velocity, elements.carbon.atomic_weight * atomic_mass)
ne10_distribution = Maxwellian(ne10_density, temperature, bulk_velocity, elements.neon.atomic_weight * atomic_mass)
e_distribution = Maxwellian(e_density, temperature, bulk_velocity, electron_mass)

d_species = Species(elements.deuterium, 1, d_distribution)
he2_species = Species(elements.helium, 2, he2_distribution)
c6_species = Species(elements.carbon, 6, c6_distribution)
ne10_species = Species(elements.neon, 10, ne10_distribution)

# define species
plasma.b_field = ConstantVector3D(Vector3D(1.0, 1.0, 1.0))
plasma.electron_distribution = e_distribution
plasma.composition = [d_species, he2_species, c6_species, ne10_species]

# BEAM ------------------------------------------------------------------------
beam = Beam(parent=world, transform=translate(1.0, 0.0, 0) * rotate(90, 0, 0))
beam.plasma = plasma
beam.atomic_data = adas
beam.energy = 60000
beam.power = 3e6
beam.element = elements.deuterium
beam.sigma = 0.025
beam.divergence_x = 0.5
beam.divergence_y = 0.5
beam.length = 3.0
beam.attenuator = SingleRayAttenuator(clamp_to_zero=True)
beam.models = [
    BeamCXLine(Line(elements.helium, 1, (4, 3))),
    BeamCXLine(Line(elements.helium, 1, (6, 4))),
    BeamCXLine(Line(elements.carbon, 5, (8, 7))),
    BeamCXLine(Line(elements.carbon, 5, (9, 8))),
Ejemplo n.º 52
0
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),
            material=Lambert(white_reflectivity))

e_left = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
             parent=enclosure,