Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Returns the indices of points within a region
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function kdm_roi, x0, y0, x1, y1 | ||
o = obj_new('idlanroi', x0, y0 ) | ||
interior = o->containspoints( x1, y1 ) | ||
gd = where( interior ne 0, ngd ) | ||
if ngd eq 0 then MESSAGE, "No interior points found", /CONTINUE | ||
obj_destroy, o | ||
return, gd | ||
end | ||
|
||
;; test | ||
data_x = randomu( seed, 10, 10 ) * 10 | ||
data_y = randomu( seed, 10, 10 ) * 10 | ||
plot, data_x, data_y, /nodata | ||
plots, data_x, data_y, psym=2 | ||
|
||
;; circle in the center | ||
x = findgen(100) * (!pi*(2/99.)) | ||
y = sin(x)+5 | ||
x = cos(x)+5 | ||
oplot, x, y | ||
|
||
inside = kdm_roi( x, y, data_x, data_y ) | ||
plots, data_x[inside], data_y[inside], color=253, psym=2 | ||
end |