python - Find points furthest away from each other in array -


i have 5 points x,y coordinates , have allowed x,y offset. can apply offset each point move both positively , negatively. means there 4 possible locations each point, after applying allowed displacements.

import numpy np import matplotlib.pyplot plt  # xy data 5 points xy = [[1929.39695287, 1579.6, 1548.0451124, 1561.47793473, 1053.18163361],       [2020.79329391, 1869.4327316, 1800.71748721, 2112.769, 1840.28]] xy = zip(*xy)  # define xy offset offset = [201.8445, 202.9015]  # create 4 possible offset combinations each of 5 points xy_offset = [] pt in xy:     xy_offset.append([         [pt[0] + offset[0], pt[1] + offset[1]],         [pt[0] + offset[0], pt[1] - offset[1]],         [pt[0] - offset[0], pt[1] + offset[1]],         [pt[0] - offset[0], pt[1] - offset[1]]])  plt.scatter(*zip(*xy), c='k') xy in xy_offset:     plt.scatter(*zip(*xy)) plt.show() 

the original points shown below in black, 4 possible new positions colored (same color 4 offset positions each point):

enter image description here

i need find combination of 5 "new" displaced positions points, such sum of distance between each point , closest 1 maximized.

okay ... approximate solution algorithm ...

  1. compute centroid of existing points.
  2. for each point's 4 choices, choose 1 farthest centroid.
  3. compute total distance; first approximation.
  4. for each point in set, check effect of moving each of other 3 choices. if of gives better total distance, change position.
  5. repeat step 4 until there no further changes.

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -