CogMath DistancePolygonPolygon Method Cognex VisionPro 9.24
Returns the shortest distance between the given polygons. Also provides the points on each polygon that correspond to this shortest distance.

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

public static double DistancePolygonPolygon(
	CogPolygon polygonA,
	CogPolygon polygonB,
	ICogImage image,
	out double polygonAX,
	out double polygonAY,
	out double polygonBX,
	out double polygonBY
)

Parameters

polygonA
Type: Cognex.VisionPro CogPolygon

The first polygon.

polygonB
Type: Cognex.VisionPro CogPolygon

The second polygon.

image
Type: Cognex.VisionPro ICogImage

An image that specifies the coordinate space to use.

polygonAX
Type: System Double 

The x-coordinate of the nearest point on polygonA.

polygonAY
Type: System Double 

The y-coordinate of the nearest point on polygonA.

polygonBX
Type: System Double 

The x-coordinate of the nearest point on polygonB.

polygonBY
Type: System Double 

The y-coordinate of the nearest point on polygonB.

Return Value

Type: Double

The shortest distance from the polygonA and polygonB. If polygonB is inside polygonA, the distance is negative.

Exceptions

ExceptionCondition
ArgumentException

Polygon 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 between the given polygons and optionally the points on each polygon that correspond to this shortest distance. If polygonB is within polygonA (according to FillMode), the distance is negative.

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

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

If more than one pair of points on polygonA and polygonB have the same distance, the returned (polygonAX, polygonAY) and (polygonBX, polygonBY) pair is chosen arbitrarily among them.

See Also