CPlotView:FindPoint


The Find method returns the index of the point in the class data matrix nearest a target coordinate.

Syntax

index = CPlotView:FindPoint( x, y )

bullet.gif    x,y is the target coordinate.

bullet.gif    index is the index of the nearest point, beginning at 1.

bullet.gif    On success, index > 0 is returned.

bullet.gif    On failure, 0 is returned.

Remarks

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.

Example

The following script finds the closest points to an x,y target position:

V = new_plotview()

-- create a new CPlotView

V:Add( 22.52, 70.5, 3, 12)

-- add a point

V:Add( 23.52, 150.5, 5, 8)

-- another point

V:Add( 18.2, 100, 2.5)

-- another point

n = V:FindPoint( 19, 148)

-- target coordinate to match

Printf("n = %d", n)

-- result: n = 2

Related Topics

CPlotView class, Add


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.