コード例 #1
0
ファイル: prism.py プロジェクト: June-Eok/source
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
コード例 #2
0
ファイル: observing_box.py プロジェクト: raysect/source
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))
コード例 #3
0
ファイル: bunny.py プロジェクト: hooyuser/source
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)

glass_outer = Box(Point3D(-0.10, -0.02, -0.10), Point3D(0.10, 0.0, 0.10))

glass_inner = Box(
    Point3D(-0.10 + glass_thickness, -0.02 + glass_thickness,
            -0.10 + glass_thickness),
    Point3D(0.10 - glass_thickness, 0.0 - glass_thickness,
            0.10 - glass_thickness))

glass = Subtract(glass_outer,
                 glass_inner,
                 material=schott("N-BK7"),
                 parent=light_box)
コード例 #4
0
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=Lambert(colours[i]))

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

# four strip lights
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 8) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 6) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
Cylinder(0.5,
         1.0,
         world,
コード例 #5
0
ファイル: prism.py プロジェクト: raysect/source
             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,
                                      transform=translate(0, 0, 0.015)),
                             Cylinder(0.1998,
                                      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
コード例 #6
0
import os
import time
from matplotlib.pyplot import *

from raysect.optical import World, translate, rotate, Point3D, d65_white, ConstantSF
from raysect.primitive import Sphere, Box, import_obj
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(0.998))
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),
コード例 #7
0
ファイル: colours_emissive.py プロジェクト: raysect/source
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)
コード例 #8
0
mesh_path = path.join(path.dirname(__file__), "../resources/stanford_bunny.rsm")
mesh = Mesh.from_file(mesh_path, parent=world, transform=rotate(180, 0, 0))

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

glass_outer = Box(Point3D(-0.10, -0.02, -0.10),
                  Point3D(0.10, 0.0, 0.10))
glass_inner = Box(Point3D(-0.10 + glass_thickness, -0.02 + glass_thickness, -0.10 + glass_thickness),
                  Point3D(0.10 - glass_thickness, 0.0 - glass_thickness, 0.10 - glass_thickness))
glass = Subtract(glass_outer, glass_inner, material=schott("N-BK7"), parent=light_box)

emitter = Box(Point3D(-0.10 + glass_thickness + padding, -0.02 + glass_thickness + padding, -0.10 + glass_thickness + padding),
              Point3D(0.10 - glass_thickness - padding, 0.0 - glass_thickness - padding, 0.10 - glass_thickness - padding),
              material=UniformVolumeEmitter(d65_white, 50), parent=light_box)


fov = 45
num_pixels = 256
コード例 #9
0
ファイル: raysect_logo.py プロジェクト: raysect/source
from raysect.optical import World, Node, translate, rotate, Point3D, d65_white, ConstantSF, InterpolatedSF
from raysect.optical.observer import PinholeCamera
from raysect.optical.material.emitter import UniformSurfaceEmitter
from raysect.optical.material.dielectric import Dielectric

world = World()

wavelengths = array([300, 490, 510, 590, 610, 800])
red_attn = array([0.0, 0.0, 0.0, 0.0, 1.0, 1.0]) * 0.98
green_attn = array([0.0, 0.0, 1.0, 1.0, 0.0, 0.0]) * 0.85
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))
コード例 #10
0
import os
import time
from matplotlib.pyplot import *

from raysect.optical import World, translate, rotate, Point3D, d65_white, ConstantSF
from raysect.primitive import Sphere, Box, import_obj
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),