Exemple #1
0
def generate_hallway(t,a_param,b_param):
    """Generate hallway :)"""

    xtf = xt(t,a_param,b_param)

    #points for l_vert
    v1 = xtf + np.array(list(rotate(Point(0,1),t,origin=(0,0)).coords)[0])
    v2 = xtf + np.array(list(rotate(Point(1,1),t,origin=(0,0)).coords)[0])
    v3 = xtf + np.array(list(rotate(Point(1,-10),t,origin=(0,0)).coords)[0])
    v4 = xtf + np.array(list(rotate(Point(0,-10),t,origin=(0,0)).coords)[0])
    #points for l_horiz
    h1 = xtf + np.array(list(rotate(Point(-10,1),t,origin=(0,0)).coords)[0])
    h2 = xtf + np.array(list(rotate(Point(1,1),t,origin=(0,0)).coords)[0])
    h3 = xtf + np.array(list(rotate(Point(1,0),t,origin=(0,0)).coords)[0])
    h4 = xtf + np.array(list(rotate(Point(-10,0),t,origin=(0,0)).coords)[0])

    hallway = Polygon([h1,h2,h3,h4]).union(Polygon([v1,v2,v3,v4]))

    return hallway
Exemple #2
0
def hallway_list(N,a_param,b_param):
    """Takes int N and returns array of rotated hallways"""
    hallways = []
    hallways.append(Polygon([(-10,0),(-10,1),(10,1),(10,0)]))
    #<- angle subdivisions
    for i in range(1, N):
        t = 90 * i/N
        hallways.append(generate_hallway(t,a_param,b_param))

    house = box(-10,-20,10,20)
    hallways.append(house)

    return hallways
Exemple #3
0
def get_carver(hallway_set):
    '''Takes hallway_set and returns polygon object used to smooth inside of sofa'''

    center_points_x = []
    center_points_y = []

    for k in range(1, len(hallway_set) - 1):
        hway_len = len(hallway_set[k].exterior.xy[0])
        center_points_x.append(hallway_set[k].exterior.xy[0][0])
        center_points_y.append(hallway_set[k].exterior.xy[1][0])

    if True:  #polynomial interp
        tpts = [n / N * 90 for n in range(1, N)]

        xtck = interpolate.splrep(tpts, center_points_x, s=0)
        ytck = interpolate.splrep(tpts, center_points_y, s=0)

        tpts = np.linspace(1 / N * 90, (N - 1) / N * 90, 100)

        xcp = list(interpolate.splev(tpts, xtck, der=0))
        ycp = list(interpolate.splev(tpts, ytck, der=0))

        xcp.append(center_points_x[round(len(center_points_x) / 2) - 1])
        ycp.append(-.4)

        carver = Polygon([(xcp[i], ycp[i]) for i in range(len(xcp))])

    if False:  #piecewise lin carver
        center_points_x.append(
            center_points_x[round(len(center_points_x) / 2) - 1])
        center_points_y.append(-.4)
        carver = Polygon([(center_points_x[i], center_points_y[i])
                          for i in range(len(center_points_x))])

    #center_points_x.append(center_points_x[round(len(center_points_x)/2)-1])
    #center_points_y.append(-.4)
    #carver = Polygon([(center_points_x[i],center_points_y[i]) for i in range(len(center_points_x))])

    return carver
Exemple #4
0
def generate_hallway(t, a):
    """Generates a hallway of angle a at x(t) where x is the rotation path"""

    intersection_pt = -cos(a * pi / 180) / sin(a * pi / 180) * 2 * sin(
        a * pi / 360)**2 + sin(a * pi / 180)

    #points for l_vert
    v1 = xt(t) + np.array(
        list(rotate(Point(0, 0), t, origin=(0, 0)).coords)[0])
    v2 = xt(t) + np.array(
        list(rotate(Point(1, intersection_pt), t, origin=(0, 0)).coords)[0])
    v3 = xt(t) + np.array(
        list(rotate(Point(1, -10), t, origin=(0, 0)).coords)[0])
    v4 = xt(t) + np.array(
        list(rotate(Point(0, -10), t, origin=(0, 0)).coords)[0])

    #points for l_horiz
    h1 = xt(t) + np.array(
        list(rotate(Point(0, 0), t, origin=(0, 0)).coords)[0])
    h2 = xt(t) + np.array(
        list(rotate(Point(1, intersection_pt), t, origin=(0, 0)).coords)[0])
    h3 = xt(t) + np.array(
        list(
            rotate(Point(
                cos(a * pi / 180) - 10 * sin(a * pi / 180),
                sin(a * pi / 180) + 10 * cos(a * pi / 180)),
                   t,
                   origin=(0, 0)).coords)[0])
    h4 = xt(t) + np.array(
        list(
            rotate(Point(-10 * sin(a * pi / 180), 10 * cos(a * pi / 180)),
                   t,
                   origin=(0, 0)).coords)[0])

    hallway = Polygon([h1, h2, h3, h4]).union(Polygon([v1, v2, v3, v4]))

    return hallway
Exemple #5
0
def hallway_list(N, a, at):
    """Takes int N and returns array of rotated hallways"""
    hallways = []
    hallways.append(Polygon([(-10, 0), (-10, 1), (10, 1), (10, 0)]))
    hallways[0] = rotate(hallways[0], a - 90, origin=(0, 0))
    #<- angle subdivisions
    for i in range(1, N):
        t = at * i / N
        hallways.append(generate_hallway(t, a))

    #min_x = xt(90) + np.array(list(rotate(Point(1,1),90,origin=(0,0)).coords)[0])
    house = box(-10, -20, 10, 20)
    hallways.append(house)

    return hallways
Exemple #6
0
def hallway_list(N, a, at):
    """Takes int N and returns array of rotated hallways of angle a
    at is a remnant of an old feature which might come back
    Currently at=a and is meaningless"""
    hallways = []
    hallways.append(Polygon([(-10, 0), (-10, 1), (10, 1), (10, 0)]))
    hallways[0] = rotate(hallways[0], a - 90, origin=(0, 0))
    #<- angle subdivisions
    for i in range(0, N + 1):
        t = at * i / N
        hallways.append(generate_hallway(t, a))

    house = box(-10, -20, 10, 20)
    hallways.append(house)

    return hallways
Exemple #7
0
def hallway_intersector(N):
    """WRITE THIS TOMORROW :)"""
    hallways = []
    hallways.append(Polygon([(-10,0),(-10,1),(10,1),(10,0)]))
    #<- angle subdivisions
    for i in range(1, N):
        t = 90 * i/N
        hallways.append(generate_hallway(t))

    final_shape = hallways[0]
    for i in hallways:
        final_shape = final_shape.intersection(i)

    house = box(-10,-20,1,20)

    final_shape = final_shape.intersection(house)

    return final_shape
Exemple #8
0
def get_carver(hallway_set):
    '''Takes hallway_set and returns polygon object
        used to smooth inside of sofa'''

    center_points_x = []
    center_points_y = []

    for k in range(1,len(hallway_set)-1):
        hway_len = len(hallway_set[k].exterior.xy[0])
        center_points_x.append(hallway_set[k].exterior.xy[0][hway_len-3])
        center_points_y.append(hallway_set[k].exterior.xy[1][hway_len-3])

    center_points_x.append(center_points_x[round(len(center_points_x)/2)-1])
    center_points_y.append(-.4)
    carver = Polygon([(center_points_x[i],center_points_y[i]) \
             for i in range(len(center_points_x))])

    return carver
Exemple #9
0
def hallway_intersector(N, a, at):
    """WRITE THIS TOMORROW :)"""
    hallways = []
    hallways.append(Polygon([(-10, 0), (-10, 1), (10, 1), (10, 0)]))
    hallways[0] = rotate(hallways[0], a - 90, origin=(0, 0))
    #<- angle subdivisions
    for i in range(0, N):
        t = at * i / N
        hallways.append(generate_hallway(t, a))

    final_shape = hallways[0]
    for i in hallways:
        final_shape = final_shape.intersection(i)

    house = box(-10, -20, 10, 20)

    final_shape = final_shape.intersection(house)

    return final_shape
Exemple #10
0
def gee_preview_tofile(GEEimage, vis, dimensions, fname=None):
    import ee
    import geopandas as gpd
    from shapely.ops import Polygon
    # WGS84 coordinates
    geom = Polygon(
        GEEimage.getInfo()['properties']['system:footprint']['coordinates'][0])
    # define 1st band projection
    proj = GEEimage.getInfo()['bands'][0]['crs']
    # extract area bounds in the 1st band projection
    area = gpd.GeoSeries(geom, crs='epsg:4326').to_crs(proj)[0].bounds
    GEEurl = GEEimage\
        .visualize(**vis)\
        .getThumbURL({'dimensions':dimensions, 'format': 'jpg'})
    #print (GEEurl)
    if fname is not None:
        geeurl_tofile(GEEurl, fname)
        worldfile_tofile(fname, area, dimensions)
    return {'url': GEEurl, 'width': dimensions[0], 'height': dimensions[1]}
Exemple #11
0
def hallway_intersector(N, a, at):
    """Takes N hallways of angle a and intersects them
    Returns a shapely polygon
    Variable at is a remnant of an old feature which might come back.
    For now, at=a and is meaningless"""
    hallways = []
    hallways.append(Polygon([(-10, 0), (-10, 1), (10, 1), (10, 0)]))
    hallways[0] = rotate(hallways[0], a - 90, origin=(0, 0))
    #<- angle subdivisions
    for i in range(0, N):
        t = at * i / N
        hallways.append(generate_hallway(t, a))

    final_shape = hallways[0]
    for i in hallways:
        final_shape = final_shape.intersection(i)

    house = box(-10, -20, 10, 20)

    final_shape = final_shape.intersection(house)

    return final_shape