from scipy.spatial import Delaunay
import numpy as np
import matplotlib.pyplot as plt

def find_points(first_point, second_point, third_point, fourth_point, count):
  """ 
  First point: left bottom
  Second point: left up
  Third point: right up
  fourth_point: right bottom
  suppose the points creates a rectangular
  """
  x_difference = third_point[0] - second_point[0]  
  y_difference = third_point[1] - fourth_point[1]
  points_array = []

  i = first_point[1]
  j = first_point[0]
  x_count = x_difference/count
  y_count = y_difference/count
  
  while i <= y_difference:
    while j <= x_difference:
      points_array.append([j, i])
      
      if j < third_point[0]:
        if i < third_point[1]:
          points_array.append([j+(x_count/2), i+(y_count/2)])

      j += x_count

    i += y_count
    j = first_point[0]
  return points_array

a = find_points([0,0], [0,1], [1,1], [1,0], 3)
points = np.array(a)
print(points)

tri = Delaunay(points)
plt.triplot(points[:,0], points[:,1], tri.simplices)
plt.plot(points[:,0], points[:,1], 'o')

# plt.xlim(-0.5, 1.5); plt.ylim(-0.5, 1.5)
plt.show()
