Beispiel #1
0
scene = hl.MonochromeScene()

path = hl.line_parametric(p0=(0, 0), dx=1, dy=0.5)
f = lambda u: 3 / (2 * u**2 + 1)
disturbance = hl.propagating_disturbance(f, v=2)

backdrop = hl.MonochromeScene()

backdrop.add_object(hl.axes(x_range=(-10, 10), y_range=(-10, 10)), "axes")

backdrop_arr = backdrop.render_scene(x_range=(-10, 10),
                                     y_range=(-10, 10),
                                     resolution=40,
                                     density=10,
                                     foreground=hl.WHITE,
                                     background=hl.BLACK)

# TODO fix this
scene.add_object(hl.disturbance_on_path(disturbance=disturbance,
                                        polarization=(-0.5, 1),
                                        init_pos=-10,
                                        path=path,
                                        p_range=(-10, 10),
                                        path_length=math.sqrt(10**2 + 5**2)),
                 name="wave")

hl._deprecated_video(frame_func=lambda t: at_t(t, scene, backdrop_arr),
                     filename='2d_disturbance_test',
                     t_range=(0, 10),
                     FPS=20)
Beispiel #2
0
                              density=3,
                              foreground=hallucinator.WHITE,
                              background=hallucinator.GREEN,
                              backdrop=background,
                              display=False)


canvas = hallucinator.MonochromeScene()

#TODO is origin working correctly?
canvas.add_object(hallucinator.axes_3(x_range=(-500, 500),
                                      y_range=(-500, 500),
                                      z_range=(-50, 50),
                                      origin=(20, 20,
                                              35)).project(method='weak'),
                  name="axes")

background = canvas.render_scene(x_range=(-30, 30),
                                 y_range=(-30, 30),
                                 resolution=5,
                                 density=1,
                                 foreground=hallucinator.WHITE,
                                 background=hallucinator.GREEN,
                                 display=False)

hallucinator._deprecated_video(
    frame_func=lambda t: rotating_box(t, background),
    filename='weak_projection_test_green',
    t_range=(0, 20),
    FPS=20)
                              starttime=5)

superposition = lambda x, y, t: tuple(
    map(operator.add, source1(x, y, t), source2(x, y, t)))
superposition2 = lambda x, y, t: tuple(
    map(operator.add, superposition(x, y, t), source3(x, y, t)))
superposition3 = lambda x, y, t: tuple(
    map(operator.add, superposition2(x, y, t), source4(x, y, t)))
superposition4 = lambda x, y, t: tuple(
    map(operator.add, superposition3(x, y, t), source5(x, y, t)))
superposition5 = lambda x, y, t: tuple(
    map(operator.add, superposition4(x, y, t), source6(x, y, t)))
superposition6 = lambda x, y, t: tuple(
    map(operator.add, superposition5(x, y, t), source7(x, y, t)))
superposition7 = lambda x, y, t: tuple(
    map(operator.add, superposition6(x, y, t), source8(x, y, t)))
superposition8 = lambda x, y, t: tuple(
    map(operator.add, superposition7(x, y, t), source9(x, y, t)))

hallucinator._deprecated_video(
    frame_func=lambda t: hallucinator.gradient_frame(f=superposition8,
                                                     p={'t': t},
                                                     x_range=(-5, 5),
                                                     y_range=(-5, 5),
                                                     resolution=10,
                                                     white_ref=10.0,
                                                     black_ref=0),
    filename='doesthisstillwork2',
    t_range=(0, 5.5),
    FPS=10)
Beispiel #4
0
source1 = hl.wave_2(f=f, v=1, source=center1, falloff=0)
source2 = hl.wave_2(f=f, v=1, source=center2, falloff=0)

superposition = hl.superposition(source1, source2)

scene = hl.GrayscaleScene()

wave = hl.ParaObject2(f=superposition,
                      region_type="surface",
                      region_params={"a_range": (-10, 10),
                                     "b_range": (-10, 10),
                                     "a_name": 'x',
                                     "b_name": 'y'},
                      species='wave_superposition')

scene.add_object(wave.rotate(theta=math.pi / 2, p=(0, 0)), name='wave')

hl._deprecated_video(frame_func=lambda t: scene.render_scene(params={'wave': {'t': t}},
                                                             x_range=(-12, 12),
                                                             y_range=(-12, 12),
                                                             resolution=20,
                                                             density=5,
                                                             white_ref=2.0,
                                                             black_ref=-2.0,
                                                             display=False,
                                                             default=hl.GRAY),
                     filename='two_slit2',
                     t_range=(1, 5),
                     FPS=10)
Beispiel #5
0
import sys

import math

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


def rotating_wheel(t, frequency):
    canvas = hl.MonochromeScene()
    canvas.add_object(hl.wheel(radius=1, num_spokes=10).rotate(theta=math.pi * 2 * frequency * t), "wheel")

    return canvas.render_scene(x_range=(-2, 2),
                               y_range=(-2, 2),
                               resolution=200,
                               density=30,
                               foreground=hl.WHITE,
                               background=hl.BLACK,
                               display=False)


frequency = 2.3

hl._deprecated_video(frame_func=lambda t: rotating_wheel(t, frequency),
                     filename='rotating_wheel_frequency_{0}'.format(frequency),
                     t_range=(0, 1),
                     FPS=20)
Beispiel #6
0
sys.path.append('../hallucinator')
import hallucinator


def at_t(t, scene):
    return scene.render_scene(params={'wave': {
        't': t
    }},
                              x_range=(-10, 10),
                              y_range=(-10, 10),
                              resolution=40,
                              density=5,
                              foreground=hallucinator.WHITE,
                              background=hallucinator.BLACK,
                              display=False)


scene = hallucinator.MonochromeScene()

scene.add_object(hallucinator.axes(x_range=(-10, 10), y_range=(-10, 10)),
                 "axes")
f = lambda u: 3 / (2 * u**2 + 1)
#TODO this is broken by update on disturbance_on_path
scene.add_object(hallucinator.disturbance_on_path(f=f, v=2, x_range=(-10, 10)),
                 "wave")

hallucinator._deprecated_video(frame_func=lambda t: at_t(t, scene),
                               filename='t_param_test',
                               t_range=(0, 10),
                               FPS=20)
                              y_range=(-80, 80),
                              resolution=5,
                              density=2,
                              foreground=hl.WHITE,
                              background=hl.BLACK,
                              backdrop=background)


canvas = hl.MonochromeScene()
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(-50, 0)), "axes1")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(-50, 50)), "axes2")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(-50, -50)), "axes3")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(0, 0)), "axes4")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(0, 50)), "axes5")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(0, -50)), "axes6")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(50, 0)), "axes7")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(50, 50)), "axes8")
canvas.add_object(hl.axes((-20, 20), (-20, 20), origin=(50, -50)), "axes9")

background = canvas.render_scene(x_range=(-80, 80),
                                 y_range=(-80, 80),
                                 resolution=5,
                                 density=2,
                                 foreground=hl.WHITE,
                                 background=hl.RED)

hl._deprecated_video(frame_func=lambda t: scene_at_t(t, background),
                     filename='transform_test_6',
                     t_range=(0, 10),
                     FPS=20)
Beispiel #8
0
    frame.add_object(hallucinator.box(20, 20, 20, p0=(-10, -10, -10)).rotate(
        theta=math.cos(t) * speed * math.pi * t,
        axis=normal_vec).project(method='ortho'),
                     name="box")

    return frame.render_scene(x_range=(-30, 30),
                              y_range=(-30, 30),
                              resolution=5,
                              density=3,
                              foreground=hallucinator.WHITE,
                              background=hallucinator.RED,
                              backdrop=background,
                              display=False)


canvas = hallucinator.MonochromeScene()

background = canvas.render_scene(x_range=(-30, 30),
                                 y_range=(-30, 30),
                                 resolution=5,
                                 density=1,
                                 foreground=hallucinator.WHITE,
                                 background=hallucinator.RED,
                                 display=False)

hallucinator._deprecated_video(
    frame_func=lambda t: rotating_box(t, background),
    filename='cubetest',
    t_range=(0, 20),
    FPS=20)
Beispiel #9
0
            i)].rotate(math.pi / 8, (1, 0, 0), (-50 + -50 * i, -40, 30))
        frame.objects["box{0}".format(i)] = frame.objects["box{0}".format(
            i)].project("ortho")

    return frame.render_scene(x_range=(-100, 100),
                              y_range=(-100, 100),
                              resolution=5,
                              density=3,
                              foreground=hl.WHITE,
                              background=hl.RED,
                              backdrop=background,
                              display=False)


canvas = hl.MonochromeScene()

# canvas.add_object(hallucinator.axes((-50, 50), (-50, 50), origin=(0, 0)), "axes1")

background = canvas.render_scene(x_range=(-100, 100),
                                 y_range=(-100, 100),
                                 resolution=5,
                                 density=1,
                                 foreground=hl.WHITE,
                                 background=hl.RED,
                                 display=False)

hl._deprecated_video(frame_func=lambda t: rotating_box(t, background),
                     filename='cube_shear_test',
                     t_range=(0, 5),
                     FPS=20)
Beispiel #10
0
import hallucinator
import math
import numpy as np

frequency = 100
amplitude = 1

f = lambda u: amplitude * math.sin(frequency * u / (2 * np.pi))

source1 = hallucinator.wave_2(f=f, v=1, source=(0, 0), falloff=0.5)

rect_region = lambda fu: hallucinator.surface_region(f=fu,
                                                     x_range=(-1, 1),
                                                     y_range=(-2, 2),
                                                     density=10)



hallucinator._deprecated_video(frame_func=lambda t: hallucinator.regional_gradient_frame(f=source1,
                                                                                         t=t,
                                                                                         region=rect_region,
                                                                                         x_range=(-5, 5),
                                                                                         y_range=(-5, 5),
                                                                                         resolution=5,
                                                                                         white_ref=1.0,
                                                                                         black_ref=-1.0,
                                                                                         default=hallucinator.RED),
                               filename='grad_path_vid_test',
                               t_range=(1, 10),
                               FPS=10)
Beispiel #11
0
#disturbance = lambda u: math.sin(u*50)

backdrop = hallucinator.MonochromeScene()

backdrop.add_object(hallucinator.axes(x_range=(-20, 20), y_range=(-20, 20)),
                    "axes")

backdrop_arr = backdrop.render_scene(x_range=(-20, 20),
                                     y_range=(-20, 20),
                                     resolution=20,
                                     density=5,
                                     foreground=hallucinator.WHITE,
                                     background=hallucinator.RED)

scene.add_object(hallucinator.disturbance_on_path_3(
    disturbance=disturbance,
    v=2,
    init_pos=-2,
    polarization=(0, 1, 0),
    path=spiral,
    p_range=(-2, 2),
    path_length=4 * 2 * 5 * math.pi).translate(tz=50).project("weak",
                                                              z_factor=0.03),
                 name="wave")

hallucinator._deprecated_video(
    frame_func=lambda t: at_t(t, scene, backdrop_arr),
    filename='3d_smooth_disturbance_test',
    t_range=(0, 5),
    FPS=20)
Beispiel #12
0
import sys

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


def scene_at_t(t):
    frame = hallucinator.MonochromeScene()
    frame.add_object(
        hallucinator.plane_section(p0=(t * 20 - 50, 0, 0),
                                   v1=(0, 1, 0),
                                   v2=(1, 0, 1),
                                   a_range=(-100, 100),
                                   b_range=(0, 200)).project(method='weak'),
        "plane")

    return frame.render_scene(x_range=(-30, 30),
                              y_range=(-30, 30),
                              resolution=20,
                              density=50,
                              foreground=hallucinator.WHITE,
                              background=hallucinator.BLACK,
                              display=False)


hallucinator._deprecated_video(frame_func=lambda t: scene_at_t(t),
                               filename='plane_test_3',
                               t_range=(0, 10),
                               FPS=20)
Beispiel #13
0
                                       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


'''canv = make_pinholes(distance=10,
                     wavelength=0.001,
                     phase_diff=0,
                     sampling_density=20,
                     separation=0.1)

hl.render_from_array(canv)
hl.save_img(canv, 'two_pinhole_d10-w0.001-s0.1-sd20')'''

hl._deprecated_video(frame_func=lambda t: make_pinholes(distance=10,
                                                        wavelength=0.001,
                                                        phase_diff=0,
                                                        sampling_density=t**2,
                                                        separation=0.1),
                     filename='pinholes_2',
                     t_range=(0, 7),
                     FPS=5)
Beispiel #14
0
    frame.add_object(hl.sphere(center=(10, 0, 30), radius=10).rotate(
        theta=math.pi / 2, axis=(0, 1, 0),
        p=(10, 0, 30)).rotate(theta=t * speed, axis=vector,
                              p=(10, 0, 30)).project(method='weak'),
                     name="sphere")

    frame.add_object(hl.sphere(center=(10, 0, 30), radius=7).rotate(
        theta=math.pi / 2, axis=(0, 1, 0),
        p=(10, 0, 30)).rotate(theta=-t * speed, axis=vector,
                              p=(10, 0, 30)).project(method='weak'),
                     name="sphere2")

    return frame.render_scene(x_range=(-10, 50),
                              y_range=(-30, 30),
                              resolution=20,
                              density=5,
                              style='wireframe',
                              region_params={
                                  'a_spacing': 2,
                                  'b_spacing': 2
                              },
                              foreground=(51, 255, 255),
                              background=(112, 50, 50),
                              display=False)


hl._deprecated_video(frame_func=lambda t: rotating_sphere(t),
                     filename='sphere_in_sphere',
                     t_range=(0, 10),
                     FPS=20)