LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determining if data is inside a boundary

I have an array of polar data (r, theta) for which each data pair I would like to determine if it lies inside or outside of a number of regions which are themselves defined by a boundary of (R, THETA) points. The way that I am thinking of now, and it seems brute force, is to step through all of the r's determine which R it is closest to then compare the theta value to the THETA value. If t>T then the data is outside of the region otherwise it is inside.

 

My array can have 100k data pairs, though, and it seems a inefficient to loop thru all of the points.

 

If you have a better suggestion I'd love to hear it.

 

Thanks.

 

Brian

0 Kudos
Message 1 of 13
(3,512 Views)

It seems like the algorithm you propose may not work for some combinations, but that may depend on the shape of the boundaries.  Are all the regions the same shape and what is the shape?  How many regions are there?  Are any regions contiguous or overlapping with other regions?

 

Please post some typical data (<<100K points!) and some or all of the boundaries.

 

Lynn

0 Kudos
Message 2 of 13
(3,511 Views)

I would interpolate your boundary using the 1D interpolation VI.  You can then figure out r_bound(theta) for each theta value in the data.  Using these points you can determine if r(theta) <= r_bound(theta). 

 

PolarRegion.PNG

Message 3 of 13
(3,492 Views)

Thanks to both that responded. I have used the interpolate function to create the regions. Here is an image of a data sample-black outlines are the rgions, red are data points. There are n-regions but typically 3, that should not overlap and are typically the same shape but not necessary. For now I will only consider equivalent regions, and the regions may be of any continuous shape.  I will look at the posted sample vi.  I have attached a picture below. Although typically the red data points will cover the inner part of the plot.

 

Thanks again.

 

sample image.jpg

0 Kudos
Message 4 of 13
(3,467 Views)

Interesting.

 

It appears that for a given value of theta, you have zero or two values of r between which is interior to the boundary.  Along a few places there may be more than one pair of r values which define the interior (for example between ~43 and 45 degrees from the right horizontal axis).  For those thetas with two values of r apply those values to the In Range and Coerce? function.  If the output is true, the point is in the interior.  The function works on arrays, so you can connect the datapoint array directly to the X input.  Read the detailed help file for information about the limits and comparison modes.

 

Lynn

0 Kudos
Message 5 of 13
(3,458 Views)

Data created with polarregion.vi is fine but data created with my routines produces inconsistencies.

0 Kudos
Message 6 of 13
(3,382 Views)

Attached is a modified version of polarregion.vi. It has the original code for creating the regions and the subsequent routines for determining if the data is in the region or not. I have added 2 sections.  First, the data creation is what I use. Second, I have added my routines for creating the regions. The issue is that when using my routine for creating the regions some data points are misclassified. I am trying to figure out what it is about my routine that makes the difference. I have attached a zip file with what I hope are all of the pertinent files. Any insight that can be provided is appreciated.

 

Thanks.

 

Brian

0 Kudos
Message 7 of 13
(3,364 Views)

Those files do not look quite like I was anticipating.

0 Kudos
Message 8 of 13
(3,360 Views)

I forgot one...here it is.

0 Kudos
Message 9 of 13
(3,356 Views)

here's another data file that shows points in error that are outside of the regions too.

0 Kudos
Message 10 of 13
(3,346 Views)