CogMath DistancePointCircle Method Cognex VisionPro 9.8 SR1
Returns the shortest distance from the given point to the given circle. Also provides the closest point on the circle.

Namespace: Cognex.VisionPro
Assembly: Cognex.VisionPro.Core (in Cognex.VisionPro.Core.dll) Version: 75.0.0.0
Syntax

public static double DistancePointCircle(
	double x,
	double y,
	CogCircle circle,
	ICogImage image,
	out double circleX,
	out double circleY
)

Parameters

x
Type: System Double

The x-coordinate of the point.

y
Type: System Double

The y-coordinate of the point.

circle
Type: Cognex.VisionPro CogCircle

The circle.

image
Type: Cognex.VisionPro ICogImage

An image that specifies the coordinate space to use.

circleX
Type: System Double 

The x-coordinate of the nearest point on the circle. If the point is on the circle, this value is the same as x. If (x,y) is the center of the circle, this value is the x-coordinate of an arbitrary point on the circle.

circleY
Type: System Double 

The y-coordinate of the nearest point on the circle. If the point is on the circle, this value is the same as y. If (x,y) is the center of the circle, this value is the y-coordinate of an arbitrary point on the circle.

Return Value

Type: Double

The shortest distance from the point (x,y) to the circle. If the point is inside the circle, the distance is negative.

Exceptions

ExceptionCondition
ArgumentException

circle is NULL.

CogSpaceTreeInvalidNameSyntaxException

At least one shape's selected space names is not a legal space name.

CogSpaceTreeNotUniqueException

At least one shape's selected space names is a nonqualified space name and more than one instance of it exists in image's coordinate space tree.

CogSpaceTreeNotInTreeException

At least one shape does not exist in image's coordinate space tree.

CogImageNoTreeException

The coordinate space tree is missing from image.

Remarks

Returns the shortest distance from the given point to the given circle.

The following table describes how the relationship between the point (x,y) and circle affects the out parameters.

ConditionDistance(circleX,circleY)

Point inside

The negative of the shortest distance between (x,y) and circle.

The nearest point on circle

Point outside

The shortest distance between (x,y) and circle.

The nearest point on circle

Point on circle

0

(x,y)

Point in center

The radius of the circle.

An arbitrary point on the circle

If you supply a value for the image parameter, then circle is mapped to the selected space of image before the measurement is computed and the result is expressed in that space. x and y are presumed to be expressed in the selected space of image.

If you do not supply a value for image, then circle, x, and y are presumed to be in the same coordinate space.

See Also