Maybe another way ... in two major steps
- find corners indices
To find the corners, I first thought of using argmax but the results differ depending on the orientation of the rectangle. So measuring the center then the distance from the center seemed safer to me.

centroid = coords.mean(axis=0)
dist = np.zeros(coords.shape[0])
for i in range(coords.shape[0]):
dist[i]= np.linalg.norm(coords[i] - centroid)
corners =np.argwhere(np.round(dist,7) == np.amax(np.round(dist,7)))
in the example corners are therefore :
- left low corner index = 0
- left upper corner index = 42
- right low corner index = 5
- right high corner index = 47
- compute cross product to find colinear points:
Since we've got corners indices, it's now possible to compute cross product and so find all colinear points.
I saw two options here :
a. compute all cross products = 0
b. stop computation when the first null cross product is found because it's correspond to the delta we are searching
for i in range(left_low_corner+1, coords.shape[0]):
vec_1 = coords[left_high_corner]-coords[left_low_corner]
vec_2 = coords[i]-coords[left_low_corner]
cross_p = np.cross(vec_1,vec_2)
if abs(cross_p[2]) < 0.001:
VD = i
break

When VD is known, it's now easy to retrieve left and right sides indices
side_le_index = np.arange(left_low_corner,left_high_corner+delta_verti,delta_verti)
side_ri_index = np.arange(right_low_corner,right_high_corner+delta_verti,delta_verti)

This also now possible to get the HD step value and therefore indices of vertices of lower and upper sides:
nb_column = int(coords.shape[0]/len(side_le_index))
step = int((right_low_corner+1)/nb_column)
side_lo_index = np.arange(left_low_corner,right_low_corner+step, step)
side_up_index = np.arange(left_high_corner,right_high_corner+step, step)
it may seem a little crooked but it works whatever the orientation of the rectangle and whatever the horizontal and vertical deltas.
If anyone has any tips for improving the code or a more efficient way to approach the problem please let me know!
[[-1.4142 -0. 0. ] [-0.7071 -0.7071 0. ] [ 0. -1.4142 0. ] [ 0.7071 -2.1213 0. ] [ 1.4142 -2.8284 0. ] [ 2.1213 -3.5355 0. ] [-1.1112 0.303 0. ] ...]therefore vertex of index 0 has coordinates [-1.4142 -0. 0. ]. If this is not clear, don't hesitate to tell me so... I will explain again. thank.