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 ) |
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 fragment 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 |