Indian LabVIEW Users Group (IndLUG)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find all the points within a certain distance from each other in a 1D array

Solved!
Go to solution

i have all the points(x,y cluster) shown in green in 1D array i want to convert to 2D array, where each row contain the points which are X distance from each other, hence separating as per the location, assume each point in a region is X distance from each other.

Rajhelboy_0-1625480084057.png

 

0 Kudos
Message 1 of 8
(3,796 Views)

I'm assuming you want the distance condition to be a 'less than or equal to', rather than an exact match to distance 'X'.

 

One way would be to start with the first point, find points meeting the above constraint, and loop through the remaining points accordingly.

 

Essentially, for any point (x_i, y_i) you are looking for point (x_k, y_k) that meets the criterion

 

sqrt ((x_k - x_i)^2 + (y_k - y_i)^2) <= X

 

sqrt = square root.

^2 = squared

 

You'll have to figure out the 2d array for yourself, as I'm not sure your data set will guarantee an equal number of points present in each 'group' of points as shown in your picture.

0 Kudos
Message 2 of 8
(3,751 Views)

I would convert your 1D array of XY clusters to a 1D array of complex with x=RE and y=IM.

 

Now all pairwise distances can be easily obtained by the absolute value of their difference.

 

Instead of the distance x in your picture (please call it something else because x is already used for one of the axes! Try e.g. "r"), it might be better to define the maximum distance in each cluster. Do you know how many clusters you expect? Can you guarantee a significant distance between clusters?

 

Usually you'll get much more specific help if you would attach a small VI containing typical data. Please do so.

 

 

Message 3 of 8
(3,747 Views)

Altenbach's is a much more elegant solution, achieving the same operation and result through complex number algebra. Nice one!

0 Kudos
Message 4 of 8
(3,741 Views)

Here's what I had in mind. Some of the constants probably need to be tuned. Make sure you understand every single part!

 

altenbach_0-1625500694818.png

 

0 Kudos
Message 5 of 8
(3,737 Views)

Sorry, I should have attached a vi, here is one of the data set. and about the number of data expected is not predefined, number of points in each region is not equal. and my labview bersion is 2014 could you please downgrade and upload. okey i have converted to complex number still it is not working. as from provided set of data u can see there are 2 lines i need to find in any angle,

0 Kudos
Message 6 of 8
(3,707 Views)

Please find attached Altenbach's VI saved for LV 2014.

 

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 7 of 8
(3,675 Views)
Solution
Accepted by topic author Rajhelboy

Thank you, i got somthing to learn i havent used complex numbers still. but in current situation i cant use them its not only these 2 data (X,Y) in cluster i posted it for simplicity. but here is the sol. i came up with. 

Download All
0 Kudos
Message 8 of 8
(3,601 Views)