CogMath DistancePointEllipse Method Cognex VisionPro 9.10
Returns the shortest distance from the given point to the given ellipse. Also provides the closest point on the ellipse.

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

public static double DistancePointEllipse(
	double x,
	double y,
	CogEllipse ellipse,
	ICogImage image,
	out double ellipseX,
	out double ellipseY
)

Parameters

x
Type: System Double

The x-coordinate of the point.

y
Type: System Double

The y-coordinate of the point.

ellipse
Type: Cognex.VisionPro CogEllipse

The ellipse.

image
Type: Cognex.VisionPro ICogImage

An image that specifies the coordinate space to use.

ellipseX
Type: System Double 

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

ellipseY
Type: System Double 

The x-coordinate of the another point on the ellipse that is equidistant to (x,y).

Return Value

Type: Double

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

Exceptions

ExceptionCondition
ArgumentException

ellipse 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 ellipse.

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

ConditionDistance(ellipseX,ellipseY)

Point inside

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

The nearest point on ellipse

Point inside

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

One of the equidistant points on ellipse

Point outside

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

The nearest point on ellipse

Point on ellipse

0

(x,y)

Ellipse is a circle, point in center

The radius of the circle.

An arbitrary point on the circle

If you supply a value for the image parameter, then ellipse 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 ellipse, x, and y are presumed to be in the same coordinate space.

See Also