          *DEPRECATED* Is a point (or set of points) inside a region?

regInsideRegion(region, x, y)
The return value is a scalar if x and y are scalars or a numpy array if x and y are numpy arrays.

The interfaces described in this help file have been deprecated. CIAO 4.10 includes a new object based interface which should be used instead of these routines. This document is provided for legacy support.

The regInsideRegion routine queries a region to find out if a point (or an array of points) is inside the region or not. 1 is returned for yes, and 0 if no. The input values are a CIAO region variable (as returned from regParse), and the positions to query which can be either be a single X, Y position or two arrays of positions.

The region module is not available by default; see "ahelp region" for information on loading the module.

&pr; from region import *
&pr; reg = regParse("circle(10,10,4)")
&pr; flag = regInsideRegion(reg, 12, 11)
&pr; print(flag)
1

Here we use the regInsideRegion() routine to find out whether the point at (12,11) is inside the circle centered at (10,10) with a radius of 4 pixels; if the routinr returns 1 then it is, otherwise it returns 0.

&pr; import numpy as np
&pr; xc = np.array([10, 16, 12])
&pr; yc = np.array([11, -4, 8])
&pr; flags = regInsideRegion(reg, xc, yc)
&pr; print(flags)
[1 0 1]
&pr; i = np.where(flags == 1)
&pr; xx = xc[i]
&pr; yy = yc[i]
&pr; print(zip(xx, yy))
[(10, 11), (12, 8)]

Here we have found that the points (10,11) and (12,8) are inside the region, but that (16,-4) is not. The where() routine is then used to show how you can extract from the arrays only those points that lie inside the region. If the where() function had been written where( flag == 0 ) then it would have selected those points that lie outside the region.

Changes in CIAO 4.8

The region library (C version) was re-written in CIAO 4.8, so that some routines may give different answers, in particular when handling self-intersecting (non-simple) polygons.

See the bugs page for the region library on the CIAO website for an up-to-date listing of known bugs.

February 2018