CPlotView:FindPoint
The Find method returns the index of the point in the class data matrix nearest a target coordinate.
index = CPlotView:FindPoint( x, y ) |
x,y is the target coordinate.
index is the index of the nearest point, beginning at 1.
On success, index > 0 is returned.
On failure, 0 is returned.
This method finds the point in the class data matrix that is nearest the specified coordinate. Typically, this method is used to find a point when the index returned by Add is unknown or after the data points have been shuffled.
This method corrects for the fact that the x and y scales may differ. The point returned is geometrically closest to the target point if the points were plotted with the scale equal in both axes.
The following script finds the closest points to an x,y target position:
|
-- create a new CPlotView |
|
-- add a point |
|
-- another point |
|
-- another point |
|
-- target coordinate to match |
|
-- result: n = 2 |