Ejemplo n.º 1
0
def textured_path(texture, pos, polarization, path, p_range, path_length):
    def f(p): return tuple(np.add((texture(p - pos) * np.asarray(polarization)), path(p)))

    return hl.ParaObject3(f,
                          region_params={'path_range': p_range,
                                         'path_length': path_length},
                          species='textured_path')
Ejemplo n.º 2
0
def textured_surface(texture, pos, polarization, surface, a_range, b_range,
                     a_length="auto",
                     b_length="auto"):
    """
    :param texture:
    :param pos:
    :param polarization:
    :param surface:
    :param a_range:
    :param b_range:
    :param a_length:
    :param b_length:
    :return:
    """

    def f(a, b): return tuple(np.add((texture(math.sqrt((pos[0] - a) ** 2 + (pos[1] - b) ** 2))
                                      * np.asarray(polarization)),
                                     surface(a, b)))

    return hl.ParaObject3(f,
                          region_type='2d',
                          region_params={'a_range': a_range,
                                         'b_range': b_range,
                                         'a_length': a_length,
                                         'b_length': b_length},
                          species='textured_surface')
Ejemplo n.º 3
0
def surface(surface_func, a_range, b_range, a_length='auto', b_length='auto'):
    return hl.ParaObject3(surface_func,
                          region_type='2d',
                          region_params={'a_range': a_range,
                                         'b_range': b_range,
                                         'a_length': a_length,
                                         'b_length': b_length},
                          species='surface')
Ejemplo n.º 4
0
def disturbance_on_path_3(disturbance, init_pos, polarization, path, p_range, path_length="auto"):

    def f(p, t): return tuple(np.add((disturbance(p - init_pos, t) * np.asarray(polarization)), path(p)))

    return hl.ParaObject3(f,
                          region_params={'path_range': p_range,
                                         'path_length': path_length},
                          species='disturbance_on_path')
Ejemplo n.º 5
0
def plane_section(p0=(0, 0, 0), v1=(0, 1, 0), v2=(1, 0, 0), a_range=(0, 1), b_range=(0, 1)):
    a_length = math.sqrt(v1[0] ** 2 + v1[1] ** 2 + v1[2] ** 2)
    b_length = math.sqrt(v2[0] ** 2 + v2[1] ** 2 + v2[2] ** 2)
    return hl.ParaObject3(plane(p0, v1, v2),
                          region_type='2d',
                          region_params={'a_range': a_range,
                                         'b_range': b_range,
                                         'a_length': a_length,
                                         'b_length': b_length},
                          species='plane')
Ejemplo n.º 6
0
def sphere(center, radius):
    return hl.ParaObject3(spherical(center, radius),
                          region_type='2d',
                          region_params={'a_range': (0, 2 * math.pi),
                                         'b_range': (0, math.pi),
                                         'a_length': (2 * math.pi * radius),
                                         'b_length': (math.pi * radius),
                                         'a_name': 'azimuth',
                                         'b_name': 'polar'},

                          species='sphere')
Ejemplo n.º 7
0
def vector_3(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x_len = x2 - x1
    y_len = y2 - y1
    z_len = z2 - z1
    distance = math.sqrt(x_len ** 2 + y_len ** 2 + z_len ** 2)
    return hl.ParaObject3(line_3(p1, x_len / distance, y_len / distance, z_len / distance),
                          region_type='path',
                          region_params={'path_range': (0, distance),
                                         'path_length': distance},
                          species='3vector')
Ejemplo n.º 8
0
def wavy_surface(amplitude: float = 1,
                 frequency: float = 1,
                 direction: float = 0,
                 phase: float = 0,
                 rotate_x: float = 0,
                 rotate_y: float = 0,
                 rotate_z: float = 0,
                 location: Tuple[int, int, int] = (0, 0, 20)):

    surface_obj = hl.ParaObject3(hl.gen_plane_wave(amplitude, frequency, hl.unit_vector(direction), phase),
                                 region_type='2d',
                                 region_params={'surface_range': ((-5, 5), (-5, 5))},
                                 species='surface')
    surface_obj = surface_obj.rotate(theta=rotate_x, axis=(1, 0, 0))
    surface_obj = surface_obj.rotate(theta=rotate_y, axis=(0, 1, 0))
    surface_obj = surface_obj.rotate(theta=rotate_z, axis=(0, 0, 1))
    surface_obj = surface_obj.translate(location)
    return surface_obj
Ejemplo n.º 9
0
def surface(amplitude: float = 1,
            frequency: float = 1,
            direction: float = math.pi,
            phase: float = math.pi,
            rotate_x: float = 0,
            rotate_y: float = 0,
            rotate_z: float = 0,
            x: int = 0,
            y: int = 0,
            z: int = 40):
    surface_obj = hl.ParaObject3(
        hl.gen_plane_wave(amplitude, frequency, hl.unit_vector(direction),
                          phase),
        region_type='2d',
        region_params={'surface_range': ((-5, 5), (-5, 5))},
        species='surface')
    surface_obj = surface_obj.rotate(theta=rotate_x, axis=(1, 0, 0))
    surface_obj = surface_obj.rotate(theta=rotate_y, axis=(0, 1, 0))
    surface_obj = surface_obj.rotate(theta=rotate_z, axis=(0, 0, 1))
    surface_obj = surface_obj.translate((x, y, z))
    return surface_obj
Ejemplo n.º 10
0
def surface(amplitude: float = 1,
            frequency: float = 1,
            direction: Tuple[float, float] = (0, 1),
            phase: float = 0,
            rotate_x: float = 0,
            location: Tuple[int, int, int] = (0, 0, 20),
            camera_pos: Tuple[int, int, int] = (0, 0, 0)):
    resolution = 200
    x_range = (-5, 5)
    y_range = (-5, 5)
    projection_type = 'weak'
    render_density = 10
    surface_func = hl.plane_wave(amplitude,
                                 frequency,
                                 direction=direction,
                                 phase=phase)
    surface_obj = hl.ParaObject3(
        surface_func,
        region_type='2d',
        region_params={
            'a_range': (-3, 3),
            'b_range': (-3, 3),
            'a_length': 'auto',
            'b_length': 'auto'
        },
        species='surface').rotate(theta=rotate_x,
                                  axis=(1, 0, 0)).translate(location)
    scene = hl.MonochromeScene()

    scene.add_object(surface_obj, name='surface')
    return hl.camscene(
        scene,
        camera_pos,
        render_density=render_density,
        projection_type=projection_type,
        styles='line',
        x_range=x_range,
        y_range=y_range,
        resolution=resolution,
    )
Ejemplo n.º 11
0
import hallucinator as hl
import math

scene = hl.MonochromeScene()

location = (5, -10, 40)
location_2 = (0, 8, 60)
spiral_location = (-7, -10, 10)
rotate_x = math.pi / 4
scene.add_object(hl.ParaObject3(hl.gen_ripple(amplitude=0.5, frequency=3, phase=0),
                                region_type='2d',
                                region_params={'surface_range': ((-10, 10), (-10, 10))},
                                species='surface').rotate(theta=rotate_x, axis=(1, 0, 0)).translate(location),
                 "ripple")
scene.add_object(hl.ParaObject3(hl.gen_ripple(amplitude=0.5, frequency=3, phase=0),
                                region_type='2d',
                                region_params={'surface_range': ((-10, 10), (-10, 10))},
                                species='surface').rotate(theta=-rotate_x, axis=(1, 1, 0)).translate(location_2),
                 "ripple2")

scene.add_object(hl.path_3(path_func=hl.gen_spiral(coil_density=1, radius=2),
                           p_range=(0, 10),
                           path_length=10 * math.pi).translate(spiral_location),
                 "spiral")

camscene = scene.render_scene(camera_position=(0, -3, -50),
                              projection_type=hl.Projections.WEAK,
                              styles={'ripple': hl.Styles.WIREFRAME,
                                      'ripple2': hl.Styles.UNIFORM,
                                      'spiral': hl.Styles.UNIFORM},
                              x_range=(-10, 10),
Ejemplo n.º 12
0
def path_3(path_func, p_range, path_length="auto"):
    return hl.ParaObject3(path_func, region_type='path',
                          region_params={'path_range': p_range,
                                         'path_length': path_length},
                          species="path")