Skip to content

Commit

Permalink
Returns the indices of points within a region
Browse files Browse the repository at this point in the history
  • Loading branch information
mankoff committed Nov 11, 2010
1 parent c754e9f commit 4528ae0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions kdm_roi.pro
@@ -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

0 comments on commit 4528ae0

Please sign in to comment.