CogMath DistanceSegmentSegment Method Cognex VisionPro 9.8 SR1
Returns the shortest distance between the two given segments. Also provides the closest point on each segment.

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

public static double DistanceSegmentSegment(
	CogLineSegment segmentA,
	CogLineSegment segmentB,
	ICogImage image,
	out double segmentAX,
	out double segmentAY,
	out double segmentBX,
	out double segmentBY
)

Parameters

segmentA
Type: Cognex.VisionPro CogLineSegment

The first line segment.

segmentB
Type: Cognex.VisionPro CogLineSegment

The second line segment.

image
Type: Cognex.VisionPro ICogImage

An image that specifies the coordinate space to use.

segmentAX
Type: System Double 

The x-coordinate of the nearest point on segmentA.

segmentAY
Type: System Double 

The y-coordinate of the nearest point on segmentA.

segmentBX
Type: System Double 

The x-coordinate of the nearest point on segmentB.

segmentBY
Type: System Double 

The y-coordinate of the nearest point on segmentB.

Return Value

Type: Double

The shortest distance between the segments or zero if the line segments are coincident or intersecting.

Exceptions

ExceptionCondition
ArgumentException

segmentA or segmentB 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 two line segments and optionally the closest point on each segment.

The following table describes how the relationship between segmentA and segmentB affects the out parameters.

ConditionDistance(segmentAX,segmentAY)(segmentBX,segmentBY)

Parallel, overlapping

The distance between segmentA and segmentB.

A point on segmentA

A point on segmentB

Non-intersecting

The shortest distance between segmentA and segmentB.

The nearest point on segmentA

The nearest point on segmentB

Parallel, not overlapping

The shortest distance between segmentA and segmentB.

The nearest point on segmentA

The nearest point on segmentB

Coincident

0

(0,0)

(0,0)

Intersecting

0

(0,0)

(0,0)

If you supply a value for the image parameter, then segmentA and segmentB are mapped to the selected space of image before the measurement is computed and the result is expressed in that space.

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

See Also