02-10-2011 03:00 PM
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
02-10-2011 03:06 PM
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
02-10-2011 05:15 PM
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).
02-11-2011 07:42 AM
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.
02-11-2011 08:38 AM
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
02-22-2011 01:15 PM
Data created with polarregion.vi is fine but data created with my routines produces inconsistencies.
02-22-2011 01:45 PM
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
02-22-2011 01:54 PM
Those files do not look quite like I was anticipating.
02-22-2011 01:56 PM
I forgot one...here it is.
02-22-2011 02:19 PM
here's another data file that shows points in error that are outside of the regions too.