Thanks a lot for you all. Instead of dealing with Ruby (in what I’m a newbie) I’ve been calculating it in my database (in what I’m an insolent but practical ignorant). Instead of solving the problem inside Sketchup I’m looking for a solution outside and when I’m happy I will delve into Ruby code.
Regarding the goal:
This image belongs to 2 of 5 floors in an office. The red cubes represent active desks at 2PM. Active means that the computer has been actively used more than 5 minutes in each 15 minutes segments. So, what I’m trying to calculate is the positive impact in energy reduction for the office by shuffling people around based on metered activity.
My distance calculations where aimed at ordering the locations (like 1,2,3,etc) starting from an arbitrary corner and then numbering spots by closeness. I’ve solved the problem but it is not optimal. Why? Because the closest points between 2 cubes can transport the numbering process step by step to an incoherent numbering result as, for example, I can have like a “snake shaped” area of numbers and close places will be left for the end of the process. So @Aerilius
was right, I could solve my problem but not arrive to my goal. This is a task I’ve been doing manually but I’d like to speed it up, that’s why I want to calculate it. The way I do it manually, that maybe can raise ideas on how to compute it, is working on “patches” in the same way of an imaginary wave entering the office from the rightest corner. In that way, I pick the first spot and then I select the closest one and I work in bands (as an inkjet printer paints the paper).
I’m not engineer nor programmer nor graduated in anything so some subjects go beyond my immediate grasp but I can solve them with a little patience and time. I Imagine that the way to do it would be to locate the closest ones limiting the range to cubes located in “BandA”, then “BandB” and so on so closeness will be decided on a lateral fashion or similar.
Maybe the most reasonable thing to do would be to select the cubes belonging to a suitable patch and then grouping or creating a bounding box per group and limit the search of closest cubes by patches.
I don’t need too much precision and I can work with the center of the cubes without problems.
I attach here an image from our website where I explain the work I do. The image shows the previous location and the suggested optimal one: you can see the difference in area required to be serviced in the office with the optimised distribution. The plot shows real activity but in swapped locations, the dots ordered by affinity in time and intensity of activity by the users.