CogMath DistanceSegmentEllipse Method Cognex VisionPro 9.10
Returns the shortest distance from the given line segment to the given ellipse. Also provides the points on each shape that correspond to this shortest distance.

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

public static double DistanceSegmentEllipse(
	CogLineSegment segment,
	CogEllipse ellipse,
	ICogImage image,
	out double segmentX,
	out double segmentY,
	out double ellipseX,
	out double ellipseY
)

Parameters

segment
Type: Cognex.VisionPro CogLineSegment

The line segment.

ellipse
Type: Cognex.VisionPro CogEllipse

The ellipse.

image
Type: Cognex.VisionPro ICogImage

An image that specifies the coordinate space to use.

segmentX
Type: System Double 

The x-coordinate of the nearest point on the line segment.

segmentY
Type: System Double 

The y-coordinate of the nearest point on the line segment.

ellipseX
Type: System Double 

The x-coordinate of the nearest point on the ellipse.

ellipseY
Type: System Double 

The x-coordinate of the nearest point on the ellipse.

Return Value

Type: Double

The shortest distance between the line segment and the ellipse.

If the line segment is within the ellipse, the distance is negative.

If the line segment intersects or touches the ellipse, the distance is zero.

Exceptions

ExceptionCondition
ArgumentException

segment or 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 the line segment segment to ellipse and optionally the points on each shape that correspond to this shortest distance.

The following table describes how the relationship between segment and ellipse affects the out parameters.

ConditionDistance(segmentX,segmentY)(ellipseX,ellipseY)

Non-intersecting

Shortest distance between segment and ellipse.

The nearest point on segment

The nearest point on ellipse

Non-intersecting

The negative of the shortest distance between segment and ellipse.

One of the endpoints on segment

The nearest point to (SegmentX0, SegmentY0) on ellipse

Non-intersecting

The negative of the shortest distance between segment and ellipse.

One of the endpoints on segment

The nearest point to (SegmentX0, SegmentY0) on ellipse

Non-intersecting

The negative of the shortest distance between segment and ellipse.

One of the endpoints on segment

The nearest point to (SegmentX0, SegmentY0) on ellipse

Tangent

0

(0,0)

(0,0)

Intersecting, endpoint on ellipse

0

(0,0)

(0,0)

Straddle

0

(0,0)

(0,0)

Intersecting

0

(0,0)

(0,0)

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

See Also