1

I wanna convert this shape to triangles mesh using shapely in order to be used later as a 3d surface in unity3d, but the result seems is not good, because the triangles mesh cover areas outside this shape.

def get_complex_shape(nb_points = 10):
    nb_shifts = 2
    nb_lines = 0
    shift_parameter = 2
    r = 1
    xy = get_points(0, 0, r, nb_points)
    xy = np.array(xy)
    shifts_indices = np.random.randint(0, nb_points ,nb_shifts) # choose random points
    if(nb_shifts > 0):
        xy[shifts_indices] = get_shifted_points(shifts_indices, nb_points, r + shift_parameter, 0, 0)
    xy = np.append(xy, [xy[0]], axis = 0) # close the circle
    x = xy[:,0]
    y = xy[:,1]
    if(nb_lines < 1): # normal circles
        tck, u = interpolate.splprep([x, y], s=0)
        unew = np.arange(0, 1.01, 0.01) # from 0 to 1.01 with step 0.01 [the number of points]
        out = interpolate.splev(unew, tck) # a circle of 101 points
        out = np.array(out).T
    else: # lines and curves
        out = new_add_random_lines(xy, nb_lines)
    return out
    enter code here

data = get_complex_shape(8)
points = MultiPoint(data)
union_points = cascaded_union(points)
triangles = triangulate(union_points)

This link is for the picture: the blue picture is the polygon that I want to convert it to mesh of triangles, the right picture is the mesh of triangles which cover more than the inner area of the polygon. How could I cover just the inner area of the polygon?

Dea Ead
  • 11
  • 4

0 Answers0