CogMath IntersectSegmentCircle Method Cognex VisionPro 9.8
Returns whether the given circle and line segment intersect. Also provides the points of intersection.

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

public static bool IntersectSegmentCircle(
	CogLineSegment segment,
	CogCircle circle,
	ICogImage image,
	out int numPoints,
	out double x0,
	out double y0,
	out double x1,
	out double y1
)

Parameters

segment
Type: Cognex.VisionPro CogLineSegment

The line segment.

circle
Type: Cognex.VisionPro CogCircle

The circle.

image
Type: Cognex.VisionPro ICogImage

An image that specifies the coordinate space to use.

numPoints
Type: System Int32 

The number of intersection points. If the value is zero, segment and circle do not intersect. If the value is 1, (x0,y0) is the tangent point or the single intersection point. If the value is 2, (x0,y0) and (x1,y1) are the intersection points.

x0
Type: System Double 

The x-coordinate of the first intersection point.

y0
Type: System Double 

The y-coordinate of the first intersection point.

x1
Type: System Double 

The x-coordinate of the second intersection point.

y1
Type: System Double 

The y-coordinate of the second intersection point.

Return Value

Type: Boolean

True if the segment and circle are tangent or intersecting.

Exceptions

ExceptionCondition
ArgumentException

segment or 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 whether circle and line segment segment intersect and optionally the point of intersection.

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

ConditionIntersectednumPoints(x0,y0)(x1,y1)

Non-intersecting

False

0

(0,0)

(0,0)

Non-intersecting

False

0

(0,0)

(0,0)

Tangent

True

1

The tangent point.

(0,0)

Intersecting, endpoint on circle

True

1

The endpoint of the segment that touches the circle.

(0,0)

Straddle

True

1

The intersection point.

(0,0)

Intersecting

True

2

The first intersection point.

The second intersection point.

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

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

See Also