Exemplo n.º 1
0
def legend(loc, length):
    """
    Creates a legend in a given location.
        Usage: legend([x, y, z], length)
    """

    # Defining textures for each axis
    x_model = Texture(Pigment(
        'color',
        [1, 0, 0],
    ), Finish('reflection', 0))
    z_model = Texture(Pigment(
        'color',
        [0, 0, 1],
    ), Finish('reflection', 0))
    y_model = Texture(Pigment(
        'color',
        [0, 1, 0],
    ), Finish('reflection', 0))

    # Create objects
    x_cyl = Cylinder(loc, [loc[0] + length, loc[1], loc[2]], 0.1, x_model)
    x_cone = Cone([loc[0] + length, loc[1], loc[2]], 0.3,
                  [loc[0] + length + 1, loc[1], loc[2]], 0, x_model)

    z_cyl = Cylinder(loc, [loc[0], loc[1], loc[2] + length], 0.1, y_model)
    z_cone = Cone([loc[0], loc[1], loc[2] + length], 0.3,
                  [loc[0], loc[1], loc[2] + length + 1], 0, y_model)

    y_cyl = Cylinder(loc, [loc[0], loc[1] + length, loc[2]], 0.1, z_model)
    y_cone = Cone([loc[0], loc[1] + length, loc[2]], 0.3,
                  [loc[0], loc[1] + length + 1, loc[2]], 0, z_model)

    return [x_cyl, x_cone, y_cyl, y_cone, z_cyl, z_cone]
Exemplo n.º 2
0
def frame(step):
    """ Creates a sphere and 4 boxes, places this in a scene """
    lichtje = LightSource([2, 8, -5], 5.0)
    default_camera = Camera('location', [0, 4, -40], 'look_at', [0, 2, -5])

    stylebox = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                       Finish('phong', 0.6, 'reflection', 0.4))
    boxright = Box([3, -2, -3], [5, 6, 4], stylebox)
    boxleft = Box([-5, -2, -3], [-3, 6, 4], stylebox)
    boxupper = Box([-5, 6, -3], [5, 8, 4], stylebox)
    boxbottom = Box([-5, -4, -3], [5, -2, 4], stylebox)

    styleball = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7))
    centerball = Sphere([0, 2, 0], 3, styleball)

    conetop = Cone([0, 8, 0], 3, [0, 12, 0], 0, stylebox)
    conebottom = Cone([0, -4, 0], 3, [0, -8, 0], 0, stylebox)
    coneleft = Cone([-5, 2, 0], 3, [-11, 2, 0], 0, stylebox)
    coneright = Cone([5, 2, 0], 3, [11, 2, 0], 0, stylebox)

    # Return the Scene object for rendering
    return Scene(default_camera,
                 objects=[
                     lichtje, centerball, boxright, boxleft, boxupper,
                     boxbottom, conetop, conebottom, coneleft, coneright
                 ])
Exemplo n.º 3
0
def frame(step):
    """ Creates a frame of 4 cones, 4 boxes, 1 sphere and a legend """

    # Define textures for different models
    sphere_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0.5))
    box_model = Texture(Pigment('color', [0, 1, 1], ), Finish('reflection', 0))
    cone_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0))

    # Create objects
    sphere = Sphere([0, 0, 0], 3, sphere_model)

    box_1 = Box([-5, -5, -4], [-3, 5, 4], box_model)
    box_2 = Box([3, -5, -4], [5, 5, 4], box_model)
    box_3 = Box([-5, 4, -4], [5, 6, 4], box_model)
    box_4 = Box([-5, -5, -4], [5, -3, 4], box_model)

    cone_1 = Cone([0, 6, 0], 3, [0, 10, 0], 0, cone_model)
    cone_2 = Cone([0, -6, 0], 3, [0, -10, 0], 0, cone_model)
    cone_3 = Cone([-5, 0, 0], 3, [-9, 0, 0], 0, cone_model)
    cone_4 = Cone([5, 0, 0], 3, [9, 0, 0], 0, cone_model)

    light_1 = LightSource([0, 10, -25], 'color', [1, 1, 1])
    light_2 = LightSource([0, 8, -7], 'color', [1, 1, 1])

    xyz_legend = legend([-15, 0, 0], 5)

    camera = Camera('location', [0, 7, -30], 'look_at', [0, 2, 1])

    # Return the Scene object for rendering
    return Scene(camera,
                 objects=[sphere, box_1, box_2, box_3, box_4,
                          cone_1, cone_2, cone_3, cone_4, light_1, light_2] + xyz_legend)
Exemplo n.º 4
0
def legend(start_position, axis_length):
    """ Legend function for calling importable legend"""

    # Reduce the AXIS_LENGTH by the length of the Cone (1) so that
    # the total length is exactly the AXIS_LENGTH
    axis_length -= 1

    # Initialize the Cylinder END-position to a COPY of the start position
    cylinder_coords_end = {
        'x': list(start_position),
        'y': list(start_position),
        'z': list(start_position)
    }

    # Add the AXIS_LENGTHs to the corresponding coordinate
    cylinder_coords_end['x'][0] += axis_length
    cylinder_coords_end['y'][1] += axis_length
    cylinder_coords_end['z'][2] += axis_length

    # creation of the Cylinders

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))
    linex = Cylinder(start_position, cylinder_coords_end['x'], 0.1, style)
    liney = Cylinder(start_position, cylinder_coords_end['y'], 0.1, style)
    linez = Cylinder(start_position, cylinder_coords_end['z'], 0.1, style)

    cylinders = {'x': linex, 'y': liney, 'z': linez}

    # Cone START is the same as the Cylinder END, so we COPY these lists
    cones_coords_start = {
        'x': list(cylinder_coords_end['x']),
        'y': list(cylinder_coords_end['y']),
        'z': list(cylinder_coords_end['z'])
    }

    # Copy the START as END coordinate
    cones_coords_end = {
        'x': list(cones_coords_start['x']),
        'y': list(cones_coords_start['y']),
        'z': list(cones_coords_start['z'])
    }

    # Extend the tip of the cones with length 1
    cones_coords_end['x'][0] += 1
    cones_coords_end['y'][1] += 1
    cones_coords_end['z'][2] += 1

    # Creation of the Cones

    conex = Cone(cones_coords_start['x'], 0.5, cones_coords_end['x'], 0, style)
    coney = Cone(cones_coords_start['y'], 0.5, cones_coords_end['y'], 0, style)
    conez = Cone(cones_coords_start['z'], 0.5, cones_coords_end['z'], 0, style)

    cones = {'x': conex, 'y': coney, 'z': conez}

    # Add ALL objects to a LIST and return
    legend_objects = list(cylinders.values()) + list(cones.values())

    return legend_objects
def frame(step):
    """ Creates the objects and places this in a scene """
    # Creates the lines in each directions
    x_cylinder = Cylinder([-15, 0, 0], [-10, 0, 0], 0.1, Texture(Pigment('color', [1, 0, 0]), Finish('reflection', 1)))
    y_cylinder = Cylinder([-15, 0, 0], [-15, 5, 0], 0.1, Texture(Pigment('color', [0, 0, 1]), Finish('reflection', 1)))
    z_cylinder = Cylinder([-15, 0, 0], [-15, 0, 5], 0.1, Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1)))
    # Creates the arrows of each directions
    x_cone = Cone([-10, 0, 0], 0.3, [-9, 0, 0], 0, Texture(Pigment('color', [1, 0, 0]), Finish('reflection', 1)))
    y_cone = Cone([-15, 5, 0], 0.3, [-15, 6, 0], 0, Texture(Pigment('color', [0, 0, 1]), Finish('reflection', 1)))
    z_cone = Cone([-15, 0, 5], 0.3, [-15, 0, 6], 0, Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1)))
    # Return the Scene object for rendering
    return Scene(models.default_camera,
                 objects=[LightSource([2, 8, -20], 2), x_cylinder, y_cylinder, z_cylinder, x_cone, y_cone, z_cone])
Exemplo n.º 6
0
def frame(step):
    ''' Creates a sphere, boxes and cones and places it all in a scene '''
    colour_purple = Pigment('color', [
        1,
        0,
        1,
    ])
    colour_aquamarine = Pigment(
        'color',
        [0, 1, 1],
    )
    sphere = Sphere([0, 0, 0], 4, colour_purple)
    side_box_1 = Box(
        [4, -7, -4],
        [5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_2 = Box(
        [-4, -7, -4],
        [-5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_3 = Box(
        [5.5, 5.5, -4],
        [-5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_4 = Box(
        [5.5, -5.5, -4],
        [-5.5, -7, 4],
        colour_aquamarine,
    )
    cone_1 = Cone([0, 7, 0], 3.5, [0, 11, 0], 0, colour_purple)
    cone_2 = Cone([0, -7, 0], 3.5, [0, -11, 0], 0, colour_purple)
    cone_3 = Cone([
        5.5,
        0,
    ], 3.5, [
        9.5,
        0,
    ], 0, colour_purple)
    cone_4 = Cone([-5.5, 0, 0], 3.5, [-9.5, 0, 0], 0, colour_purple)
    # Return the Scene object for rendering
    return Scene(models.default_camera,
                 objects=[
                     models.default_light, side_box_1, side_box_2, side_box_3,
                     side_box_4, cone_1, cone_2, cone_3, cone_4, sphere
                 ])
def frame(step):
    lichtje = LightSource([2, 8, -5], 5.0)
    default_camera = Camera('location', [-5, 8, -20], 'look_at', [-5, 0, -5])
    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                       Finish('phong', 0.6, 'reflection', 0.4))

    linex = Cylinder([-15, 0, 0], [-10, 0, 0.5],0.1, style)
    liney = Cylinder([-15, 0, 0], [-15, 5, 0.2],0.1, style)
    linez = Cylinder([-15, 0, 0], [-15, 0.2, 5],0.1, style)


    conex = Cone([-10, 0, 0.5], 0.5,
                [-9, 0, 0.5], 0,
                style)
    coney = Cone([-15, 5, 0], 0.5,
                 [-15, 6, 0], 0,
                 style)
    conez = Cone([-15, 0, 5], 0.5,
                 [-15, 0, 6], 0,
                 style)

    # Return the Scene object for rendering
    return Scene(default_camera,
                 objects=[lichtje,linex,liney,linez,conex,coney,conez])
Exemplo n.º 8
0
def legend(start_position, axis_length):
    """
    Returns the objects of a legend
    :param start_position: the position where the legend is rendered
    :param axis_length: the length of each line+arrow in the x, y and z direction
    :return legend_objects: the objects of a legend
    """

    # Reduce the AXIS_LENGTH by the length of the Cone (1) so that
    # the total length is exactly the AXIS_LENGTH
    axis_length -= 1

    # Initialize the Cylinder END-position to a COPY of the start position
    cylinder_coords_end = {
        'x': list(start_position),
        'y': list(start_position),
        'z': list(start_position)
    }

    # Add the AXIS_LENGTHs to the corresponding coordinate
    cylinder_coords_end['x'][0] += axis_length
    cylinder_coords_end['y'][1] += axis_length
    cylinder_coords_end['z'][2] += axis_length
    ''' CREATE THE CYLINDERS'''
    cylinders = {
        'x':
        Cylinder(start_position, cylinder_coords_end['x'], 0.1,
                 Texture(Pigment('color', [1, 0, 0]), Finish('reflection',
                                                             1))),
        'y':
        Cylinder(start_position, cylinder_coords_end['y'], 0.1,
                 Texture(Pigment('color', [0, 0, 1]), Finish('reflection',
                                                             1))),
        'z':
        Cylinder(start_position, cylinder_coords_end['z'], 0.1,
                 Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1)))
    }

    # Cone START is the same as the Cylinder END, so we COPY these lists
    cones_coords_start = {
        'x': list(cylinder_coords_end['x']),
        'y': list(cylinder_coords_end['y']),
        'z': list(cylinder_coords_end['z'])
    }

    # Copy the START as END coordinate
    cones_coords_end = {
        'x': list(cones_coords_start['x']),
        'y': list(cones_coords_start['y']),
        'z': list(cones_coords_start['z'])
    }

    # Extend the tip of the cones with length 1
    cones_coords_end['x'][0] += 1
    cones_coords_end['y'][1] += 1
    cones_coords_end['z'][2] += 1
    ''' CREATE THE CONES '''
    cones = {
        'x':
        Cone(cones_coords_start['x'], 0.3, cones_coords_end['x'], 0,
             Texture(Pigment('color', [1, 0, 0]), Finish('reflection', 1))),
        'y':
        Cone(cones_coords_start['y'], 0.3, cones_coords_end['y'], 0,
             Texture(Pigment('color', [0, 0, 1]), Finish('reflection', 1))),
        'z':
        Cone(cones_coords_start['z'], 0.3, cones_coords_end['z'], 0,
             Texture(Pigment('color', [0, 1, 0]), Finish('reflection', 1))),
    }

    # Add ALL objects to a LIST and return
    legend_objects = list(cylinders.values()) + list(cones.values())
    return legend_objects
def make_cone(x1, y1, z1, x2, y2, z2):
    """ Creates a pink cone with a base-radius of 3 """
    cone = Cone([x1, y1, z1], 3, [x2, y2, z2], 0, pink)
    return cone
def make_cone(x1, y1, z1, x2, y2, z2):
    """ Creates a pink cone with a base-radius of 3"""
    cone = Cone([x1, y1, z1], 3, [x2, y2, z2], 0, Texture(Pigment('color', [1, 0, 1]), Finish('reflection', 0.4)))
    return cone