Select given XY array to find all points inside the rectangle defined by XY min max values.
int ocmath_find_xy_in_rect( uint nPts, const double * pX, const double * pY, uint * pIndices, double dxMin, double dyMin, double dxMax, double dyMax )
0 if none found to be inside rect, otherwise the number of points found,
and will always be less than nPts.
-1 if given XY range does not define a valid Rect, like if xmin>=xmax or
ymin>=ymax.
EX1
//Before running, make sure a worksheet is active in current project //the worksheet should has at least 2 columns and without any missing value in the first two columns #include <wks2mat.h> void ocmath_find_xy_in_rect_ex1(double dXMin = -1, double dYMin = -1, double dXMax = 1, double dYMax = 1) { Worksheet wks = Project.ActiveLayer(); Dataset dsX(wks, 0), dsY(wks, 1); vector vX(dsX), vY(dsY); vector<uint> vIndices(dsX.GetSize()); int nPts = ocmath_find_xy_in_rect(dsX.GetSize(), vX, vY, vIndices, dXMin, dYMin, dXMax, dYMax); ocmath_d_copy(nPts, vIndices, vX, vX, vX.GetSize()); ocmath_d_copy(nPts, vIndices, vY, vY, vY.GetSize()); printf("%d data points are found within rect.\n", nPts); vX.SetSize(nPts); vY.SetSize(nPts); dsX = vX; dsY = vY; }
Should trim Missing Value before using this function
wks2mat.h