Lines and Line SegmentsCognex VisionPro

VisionPro supports two related linear shapes: CogLine and CogLineSegment. This topic describes the differences between these two shapes.

Note: Both lines and line segments in VisionPro are directed.

Lines

A line is a straight geometric shape of infinite length. In VisionPro, the following parameterizations for a line are supported:

Table 1. Line Parameterizations
ParameterizationExample

SetXYRotation

You specify a single point through which the line passes along with the angle of the line relative to the selected space. The direction of the line is given by the rotation.

Measurement General Theory Lines Segments lineparameterization XYRotation

SetDistanceRotation

You specify a reference vector from the origin of the selected space. The line is normal to and passes through the end of the vector. The direction of the line is given by the rotation.

Measurement General Theory Lines Segments lineparameterization Set Distance Rotation

SetFromStartXYEndXY

You specify two points through which the line passes. The first point is treated as the reference point. The direction of the line is from the first point (the reference point) to the second point.

Measurement General Theory Lines Segments lineparameterization Set From StartXYEndXY

Line Segments

A line segment is a straight geometric shape of finite length. In VisionPro, the following parameterizations for a line segment are supported:

Table 2. Line Segment Parameterizations
ParameterizationExample

SetStartLengthRotation

You specify the starting point for the segment, its length, and its angle relative to the selected space. The direction of the segment is given by the rotation.

Measurement General Theory Lines Segments segmentparameterization Set Start Length Rotation

SetStartEnd

You specify the two end points of the segment. The direction of the segment is from the first point to the second point.

Measurement General Theory Lines Segments segmentparameterization Set Start End

Lines and Segments Can Behave Differently

The VisionPro dimensioning functions that compute the distance between lines and line segments and other shapes may produce different results depending on whether you supply a line or a line segment, even when the line and line segment are collinear.

Table 3. Line and Line Segment Distance Methods
Shape PairLineLine Segment

Lines and line segments to CogCircle.

CogMath.DistanceLineCircle

Measurement General Theory Lines Segments linetheory distlinecircle

CogMath.DistanceSegmentCircle

Measurement General Theory Lines Segments linetheory distsegmentcircle

Lines and line segments to CogEllipse.

CogMath.DistanceLineEllipse

Measurement General Theory Lines Segments linetheory distlineellipse

CogMath.DistanceSegmentEllipse

Measurement General Theory Lines Segments linetheory distsegmentellipse

Lines and line segments to points.

CogMath.DistancePointLine

Measurement General Theory Lines Segments linetheory distlinepoint

CogMath.DistancePointSegment

Measurement General Theory Lines Segments linetheory distsegmentpoint

Lines and line segments to CogLineSegment.

CogMath.DistanceSegmentLine

Measurement General Theory Lines Segments linetheory distlinesegment

CogMath.DistanceSegmentSegment

Measurement General Theory Lines Segments linetheory distsegmentsegment

Converting Line Segments to Lines

In some cases, you may be using a combination of measurement methods where one method produces a line segment as output while the next method requires a line as input. You can easily convert a line segment into a line using one of two methods: Call the CogLineSegment.CreateLine method to obtain a new line that is collinear with your line segment. Alternatively, if you have an existing line you can call the CogLine.SetFromLineSegment method to set that line to be collinear with a supplied line segment.