Exemplo n.º 1
0
def make_zone_plate(distance, wavelength, phase_diff, a_density, b_density,
                    direction, x_range, y_range):
    surface = lambda a, b: (a, b, distance)
    source = (0, 0, 0)

    planewave = hl.PlaneWave(source=source,
                             wavelength=wavelength,
                             amplitude=1,
                             init_phase=0,
                             direction=direction)

    spherewave = hl.PointSource(source=source,
                                wavelength=wavelength,
                                amplitude=1,
                                init_phase=phase_diff)

    points = hl.eval_surface_intensity(sources=(planewave, spherewave),
                                       surface=surface,
                                       a_range=x_range,
                                       b_range=y_range,
                                       a_density=a_density,
                                       b_density=b_density)

    canv = hl.set_to_gradient(points,
                              x_range=x_range,
                              y_range=y_range,
                              black_ref=0,
                              white_ref=4.0,
                              default=hl.GRAY,
                              resolution=30)

    return canv
Exemplo n.º 2
0
def plane_interference(distance, wavelength, phase_diff, sampling_density,
                       a_direction, b_direction):
    surface = lambda a, b: (a, b, distance)
    source1 = (0, 0, 0)
    source2 = (0, 0, 0)

    pin1 = hl.PlaneWave(source=source1,
                        wavelength=wavelength,
                        amplitude=1,
                        init_phase=0,
                        direction=a_direction)

    pin2 = hl.PlaneWave(source=source2,
                        wavelength=wavelength,
                        amplitude=1,
                        init_phase=phase_diff,
                        direction=b_direction)

    points = hl.eval_surface_intensity(sources=(pin1, pin2),
                                       surface=surface,
                                       a_range=(-15, 15),
                                       b_range=(-15, 15),
                                       a_density=sampling_density,
                                       b_density=sampling_density)

    canv = hl.set_to_gradient(points,
                              x_range=(-15, 15),
                              y_range=(-15, 15),
                              black_ref=0,
                              white_ref=4.0,
                              default=hl.GRAY,
                              resolution=50)

    return canv
Exemplo n.º 3
0
def make_pinholes(distance, wavelength, phase_diff, sampling_density,
                  separation):
    surface = lambda a, b: (a, b, distance)
    source1 = (-separation, 0, 0)
    source2 = (separation, 0, 0)

    pin1 = hl.PointSource(source=source1,
                          wavelength=wavelength,
                          amplitude=1,
                          init_phase=0)

    pin2 = hl.PointSource(source=source2,
                          wavelength=wavelength,
                          amplitude=1,
                          init_phase=phase_diff)

    points = hl.eval_surface_intensity(sources=(pin1, pin2),
                                       surface=surface,
                                       a_range=(-30, 30),
                                       b_range=(-30, 30),
                                       a_density=sampling_density,
                                       b_density=sampling_density)

    canv = hl.set_to_gradient(points,
                              x_range=(-30, 30),
                              y_range=(-30, 30),
                              black_ref=0,
                              white_ref=4.0,
                              default=hl.GRAY,
                              resolution=50)

    return canv
Exemplo n.º 4
0
def sample(a_density, b_density, at, params={}):
    print(params)
    points = hl.surface_region(at,
                               params=params,
                               a_range=(-10, 10),
                               b_range=(-10, 10),
                               a_name='x',
                               b_name='y',
                               a_density=a_density,
                               b_density=b_density)
    canvas = hl.set_to_gradient(points=points,
                                x_range=(-10, 10),
                                y_range=(-10, 10),
                                black_ref=-1,
                                white_ref=1,
                                resolution=100,
                                default=hl.GRAY)
    print("canvas", type(canvas), canvas.shape, canvas)

    return canvas
Exemplo n.º 5
0
    def render_scene(self,
                     params="none",
                     x_range=(-10, 10),
                     y_range=(-10, 10),
                     camera_position='default',
                     projection_type='none',
                     resolution=5,
                     density=5,
                     black_ref=-1.0,
                     white_ref=1.0,
                     default=hl.BLUE,
                     style='uniform',
                     region_params="none",
                     display=False,
                     save=False,
                     filename='default',
                     backdrop="new"):
        if params == "none":
            params = {}

        points, _ = self.frame_at_p(params=params,
                                    camera_position=camera_position,
                                    projection_type=projection_type,
                                    region_params=region_params,
                                    style=style,
                                    density=density)
        arr = hl.set_to_gradient(points=points,
                                 x_range=x_range,
                                 y_range=y_range,
                                 black_ref=black_ref,
                                 white_ref=white_ref,
                                 default=default,
                                 resolution=resolution,
                                 backdrop=backdrop)
        if display:
            hl.render_from_array(arr)
        if save:
            hl.save_img(arr, filename)
        return arr
Exemplo n.º 6
0
import sys

sys.path.append('../hallucinator')
import hallucinator

topdown_gradient = lambda x, y: (x, y, -y)

conditions = (lambda x, y: y < x, lambda x, y: y > x**2 - 4)

gradient_along_path = hallucinator.conditional_region(f=topdown_gradient,
                                                      conditions=conditions,
                                                      x_range=(-5, 5),
                                                      y_range=(-5, 5),
                                                      density=10)

gradient_image = hallucinator.set_to_gradient(points=gradient_along_path,
                                              x_range=(-5, 5),
                                              y_range=(-5, 5),
                                              black_ref=-5,
                                              white_ref=5,
                                              resolution=20,
                                              default=hallucinator.BLACK)

# hallucinator.render_from_array(gradient_image)
hallucinator.save_img(gradient_image, 'conditional')
Exemplo n.º 7
0
import sys
sys.path.append('../hallucinator')
import hallucinator

topdown_discrete = lambda x, y: (x, y, -1 if y < 0 else 1)
topdown_gradient = lambda x, y: (x, y, -y)

path = lambda p: (p, p)
p_range = [-3, 3]
gradient_along_path = hallucinator.path_region(f=topdown_gradient,
                                               path=path,
                                               p_range=p_range,
                                               density=5)

gradient_image = hallucinator.set_to_gradient(points=gradient_along_path,
                                              x_range=(-5, 5),
                                              y_range=(-5, 5),
                                              black_ref=-3,
                                              white_ref=3,
                                              default=hallucinator.BLUE)

# hallucinator.render_from_array(gradient_image)
hallucinator.save_img(gradient_image, 'path_grad_test0')
Exemplo n.º 8
0
print(hl.intensity_at(sources=[source1], location=(1, 0)))
print(hl.intensity_at(sources=[source2], location=(1, 0)))
print(hl.intensity_at(sources=[source1, source2], location=(1, 0)))
print(hl.intensity_at(sources=[source1, source2], location=(1.01, 0)))'''

a_range = (-1, 1)
b_range = (-1, 1)

intensities = hl.eval_surface_intensity(
    sources=[*line_of_sources],
    surface=surface,
    a_range=a_range,
    b_range=b_range,
    a_density=2000,
    b_density=2000,
    # density=100
)
canv = hl.set_to_gradient(
    intensities,
    x_range=a_range,
    y_range=b_range,
    black_ref=0,
    white_ref=4.0,
    default=hl.GRAY,
    resolution=2000,
)

hl.render_from_array(canv)
hl.save_img(canv, 'width{0}_{1}-points_random'.format(slit_width, num_sources))
#hl.save_img(canv, 'two_point_stacked')
Exemplo n.º 9
0
surface = lambda a, b: (a, b, 10)
source = (0, 0, 0)
direction = (0, 0, 1)

planewave = hl.PlaneWave(source=source,
                         wavelength=0.05,
                         amplitude=1,
                         init_phase=0,
                         direction=direction)

spherewave = hl.PointSource(source=source,
                            wavelength=0.05,
                            amplitude=1,
                            init_phase=math.pi / 2)

points = hl.eval_surface_intensity(sources=(planewave, spherewave),
                                   surface=surface,
                                   a_range=(-15, 15),
                                   b_range=(-15, 15),
                                   density=15)

canv = hl.set_to_gradient(points,
                          x_range=(-15, 15),
                          y_range=(-15, 15),
                          black_ref=0,
                          white_ref=4.0,
                          default=hl.GRAY,
                          resolution=50)

hl.render_from_array(canv)
hl.save_img(canv, 'w0.05-d10-15-15-p0.5pi')