Example #1
0
def disc( x,y,z, color=color( 30,10,140 ) ):
  v = pgl.Vector3( x, y, z )
  d = pgl.Disc( 0.4, 5 )
  azimuth, elevation, roll= rdm_orientation()
  rotated_geometry= pgl.EulerRotated(azimuth, elevation, roll, d)
  tr = pgl.Translated( v,rotated_geometry )
  return pgl.Shape( tr, color )
def Unileaflet(length=1., width=1.):
    disc = pgl.Translated((-0.5,0,0), pgl.Disc())
    disc = pgl.Scaled((length, width,1), disc)
    disc = pgl.AxisRotated(axis=(0,1,0), angle=radians(90.), geometry=disc)

    d3 = pgl.AxisRotated(axis=(1,0,0), angle=0., geometry=disc)

    shape = pgl.Group([d3])
    return shape
Example #3
0
def leaflet(length=1., width=1.):
    """
    return 
    ------
    a strawberry leaf composed of three discs
    """
    disc = pgl.Translated((-0.5, 0, 0), pgl.Disc())
    disc = pgl.Scaled((length, width, 1), disc)
    disc = pgl.AxisRotated(axis=(0, 1, 0), angle=radians(90.), geometry=disc)

    d1 = pgl.AxisRotated(axis=(1, 0, 0), angle=-radians(60.), geometry=disc)
    d2 = pgl.AxisRotated(axis=(1, 0, 0), angle=-radians(-60.), geometry=disc)
    d3 = pgl.AxisRotated(axis=(1, 0, 0), angle=0., geometry=disc)

    shape = pgl.Group([d1, d2, d3])
    return shape
def unileaflet(length=1., width=1.):
    """Generates a unileaflet shape

    :param length: length of the shape, defaults to 1.
    :type length: float, optional
    :param width: width of the shape, defaults to 1.
    :type width: float, optional
    :return: the shape
    :rtype: pgl.Group
    """  
    disc = pgl.Translated((-0.5,0,0), pgl.Disc())
    disc = pgl.Scaled((length, width,1), disc)
    disc = pgl.AxisRotated(axis=(0,1,0), angle=radians(90.), geometry=disc)

    d3 = pgl.AxisRotated(axis=(1,0,0), angle=0., geometry=disc)

    shape = pgl.Group([d3])
    return shape
def leaflet(length=1., width=1.):
    """Generate a strawberry leaf

    :param length: length of the leaflet, defaults to 1.
    :type length: float, optional
    :param width: width of the leaflet, defaults to 1.
    :type width: float, optional
    :return: A strawberry leaf composed of three discs
    :rtype: pgl.Group
    """    
    disc = pgl.Translated((-0.5,0,0), pgl.Disc())
    disc = pgl.Scaled((length, width,1), disc)
    disc = pgl.AxisRotated(axis=(0,1,0), angle=radians(90.), geometry=disc)

    d1 = pgl.AxisRotated(axis=(1,0,0), angle=-radians(60.), geometry=disc)
    d2 = pgl.AxisRotated(axis=(1,0,0), angle=-radians(-60.), geometry=disc)
    d3 = pgl.AxisRotated(axis=(1,0,0), angle=0., geometry=disc)

    shape = pgl.Group([d1, d2, d3])
    return shape
Example #6
0
def random_leaves(n_leaves=10,
                  leaf_area=0.1,
                  crown_radius=1,
                  crown_center=(0, 0, 0),
                  inner=True):
    """

    :param n_leaves:
    :param leaf_area:
    :param crown_radius:
    :param crown_center:
    :return:
    """

    positions = random_position(n_leaves, radius=crown_radius, inner=inner)
    orientations = random_orientation(n_leaves)
    center = numpy.array(crown_center)
    pgl_pos = [pgl.Vector3(*(numpy.array(pos) + center)) for pos in positions]
    leaf = pgl.Disc(numpy.sqrt(leaf_area / 0.9 / numpy.pi))
    r_leaves = [
        pgl.EulerRotated(az, el, ro, leaf) for az, el, ro in orientations
    ]
    return [pgl.Translated(pos, l) for pos, l in zip(pgl_pos, r_leaves)]
Example #7
0
def mtg_nenuphar(area=1):
    g = MTG()
    vid = g.add_component(g.root, label='plant', edge_type='/')
    geom = pgl.Disc(numpy.sqrt(area / 0.9 / numpy.pi))
    g.add_child(vid, edge_type='<', label='trunk', area=area, geometry=geom)
    return g