Guest User

Untitled

a guest
Aug 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. def get_complex_shape(nb_points = 10):
  2. nb_shifts = 2
  3. nb_lines = 0
  4. shift_parameter = 2
  5. r = 1
  6. xy = get_points(0, 0, r, nb_points)
  7. xy = np.array(xy)
  8. shifts_indices = np.random.randint(0, nb_points ,nb_shifts) # choose random points
  9. if(nb_shifts > 0):
  10. xy[shifts_indices] = get_shifted_points(shifts_indices, nb_points, r + shift_parameter, 0, 0)
  11. xy = np.append(xy, [xy[0]], axis = 0) # close the circle
  12. x = xy[:,0]
  13. y = xy[:,1]
  14. if(nb_lines < 1): # normal circles
  15. tck, u = interpolate.splprep([x, y], s=0)
  16. unew = np.arange(0, 1.01, 0.01) # from 0 to 1.01 with step 0.01 [the number of points]
  17. out = interpolate.splev(unew, tck) # a circle of 101 points
  18. out = np.array(out).T
  19. else: # lines and curves
  20. out = new_add_random_lines(xy, nb_lines)
  21. return out
  22. enter code here
  23.  
  24. data = get_complex_shape(8)
  25. points = MultiPoint(data)
  26. union_points = cascaded_union(points)
  27. triangles = triangulate(union_points)
Add Comment
Please, Sign In to add comment