LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search for array cluster in another array cluster

Hi

I a working on segmenting lines and I have an input array cluster of lines and an output array cluster which contains the segments. Each line or segment has 3 start points and 3 end points. The inputs and outputs are starting and ending points of lines/clusters. I would like to find out how many segments are formed for each line. The steps I think will help me are the following

1. Separate start and end points of input and output cluster. 

2. Take the start of input cluster and compare it till the same value is found in the output cluster

3. Once the start values are same, find when the end values of input and output cluster become same. (a counter helps to find after how many indices the ends become same)

4. Take the next input start point and compare it with the output cluster after the previous step.

5. Continue

 

I tried searching for the input array cluster in the output array cluster using the array search function in OpenG. But it does not work. Any help would be appreciated.

Thanks

0 Kudos
Message 1 of 7
(2,112 Views)

You might get more help if you post a LV2018 (or earlier) version.. LV2019 is brand new, and not everyone can update immediately.

Message 2 of 7
(2,069 Views)

Hi

 

Thanks for your suggestion. The older version of my try is uploaded. Any help will be highly appreciated.

Thanks

0 Kudos
Message 3 of 7
(2,030 Views)

Hi eddy,

 

why don't you use that simple Search1DArray function?

check.png

You still need to implement the error handling, when the "segment" (aka point) is not found…

 

(Btw. you really should be careful when it comes to comparing floating point numbers!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(2,013 Views)

Maybe you could clarify a few things. I am confused by your description:

  • What is the difference between a line and a segment? (In your VI, everything is labeled as "segments").
  • Is the direction important or can start/end be interchanged for the same line?
  • A line can only have one start and end point (not three). I assume you mean three coordinates.
  • What is the expected result for you default sample data in the VI? Just a count?
  • Can you make a simple drawing explaining the problem (maybe reduced to 2D).
  • In your VI, which is the "input array cluster" and which is "output array cluster". It helps to label things consistently.
  • As has been mentioned, comparing floating point values is dangerous. Where is the data coming from?
  • ...
Message 5 of 7
(1,997 Views)

@GerdW wrote:

Hi eddy,

 

why don't you use that simple Search1DArray function?

check.png

You still need to implement the error handling, when the "segment" (aka point) is not found…

 

(Btw. you really should be careful when it comes to comparing floating point numbers!)


Hi

Thanks for your reply. The code worked for the inputs provided. But when I supplied a larger set of similar inputs the output was not correct. The algorithm which I feel might work is

1. The input start is searched in the output start.

2. If they are same, input end must be searched for in the output end. 

3. Count the loops to get number of segments. (shift register is what I tried)

4. The search for the next input start must start from the next element output start (next element in output start in step 1). 

And as you suggested error handling also needs to be taken care of, but for the time being I shall assume all points are found. Also attached is the larger input set.

Much appreciate your help.

Thanks



0 Kudos
Message 6 of 7
(1,958 Views)

@altenbach wrote:

Maybe you could clarify a few things. I am confused by your description:

  • What is the difference between a line and a segment? (In your VI, everything is labeled as "segments").
  • Is the direction important or can start/end be interchanged for the same line?
  • A line can only have one start and end point (not three). I assume you mean three coordinates.
  • What is the expected result for you default sample data in the VI? Just a count?
  • Can you make a simple drawing explaining the problem (maybe reduced to 2D).
  • In your VI, which is the "input array cluster" and which is "output array cluster". It helps to label things consistently.
  • As has been mentioned, comparing floating point values is dangerous. Where is the data coming from?
  • ...

Hi

Thanks for the reply. Let me try to be more clear.

1. What is the difference between a line and a segment? (In your VI, everything is labeled as "segments").

A segment is obtained when a line is divided into portions. Some lines may not be divided, which means that they appear in the input and output as such.

 

2. Is the direction important or can start/end be interchanged for the same line?

Yes, the direction of lines are important

 

3. A line can only have one start and end point (not three). I assume you mean three coordinates.

Sorry for the misunderstanding. I meant coordinates.

 

4. What is the expected result for you default sample data in the VI? Just a count?

Yes, it is just a count. The size of the count array should be same as the Line-in array cluster. The sum of the elements of the count array must be equal to the size of the Segments-out array cluster.

 

5. Can you make a simple drawing explaining the problem (maybe reduced to 2D).

Yes, a simple drawing in 2D is attached. The black represents the lines which are divided into segments at the red markings. So the Line-in cluster will have start and end coordinates of lines a-b, c-d, e-f and g-h. The Segments-out cluster will have the start and end coordinates of the segments. The segments are x5-x1, x1-x2, x2-b, g-x3, x3-x2, x2-h, c-x4, x4-x5, x5-x6, x6-d, e-x7, x7-x5, x5-x8, x8-f. In the figure x5 and a are same points. The output is expected to be a cluster which counts the number of segments created by each line. 

 

6. In your VI, which is the "input array cluster" and which is "output array cluster". It helps to label things consistently.

I am attaching a new VI, which has Lines-in and the Segments-out. The output is expected to be a cluster which counts the number of segments created by each line. 

 

7. As has been mentioned, comparing floating point values is dangerous. Where is the data coming from?

Although I have not thought about it now, I hope that the numbers will be restricted to a two digit precision point.

 

Hope this helps.

Many thanks

 

Download All
0 Kudos
Message 7 of 7
(1,950 Views)