C# Класс AForge.Math.Geometry.LineSegment

The class encapsulates 2D line segment and provides some tool methods related to lines.

The class provides some methods which are related to line segments: distance to point, finding intersection point, etc.

A line segment may be converted to a Line.

Sample usage:

// create a segment LineSegment segment = new LineSegment( new DoublePoint( 0, 0 ), new DoublePoint( 3, 4 ) ); // get segment's length double length = segment.Length; // get intersection point with a line DoublePoint? intersection = segment.GetIntersectionWith( new Line( new DoublePoint( -3, 8 ), new DoublePoint( 0, 4 ) ) );
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
DistanceToPoint ( DoublePoint point ) : double

Calculate Euclidean distance between a point and a finite line segment.

GetIntersectionWith ( Line other ) : DoublePoint?

Finds, provided it exists, the intersection point with the specified Line.

If the line and the segment do not intersect, the method returns . If the line and the segment share multiple points, the method throws an InvalidOperationException.

GetIntersectionWith ( LineSegment other ) : DoublePoint?

Finds, provided it exists, the intersection point with the specified LineSegment.

If the two segments do not intersect, the method returns . If the two segments share multiple points, this throws an InvalidOperationException.

LineSegment ( DoublePoint start, DoublePoint end ) : System

Initializes a new instance of the LineSegment class.

Приватные методы

Метод Описание
LocateProjection ( DoublePoint point ) : ProjectionLocation

Описание методов

DistanceToPoint() публичный Метод

Calculate Euclidean distance between a point and a finite line segment.
public DistanceToPoint ( DoublePoint point ) : double
point DoublePoint The point to calculate the distance to.
Результат double

GetIntersectionWith() публичный Метод

Finds, provided it exists, the intersection point with the specified Line.

If the line and the segment do not intersect, the method returns . If the line and the segment share multiple points, the method throws an InvalidOperationException.

Thrown if this segment is a portion of /// line.
public GetIntersectionWith ( Line other ) : DoublePoint?
other Line to find intersection with.
Результат DoublePoint?

GetIntersectionWith() публичный Метод

Finds, provided it exists, the intersection point with the specified LineSegment.

If the two segments do not intersect, the method returns . If the two segments share multiple points, this throws an InvalidOperationException.

Thrown if the segments overlap - if they have /// multiple points in common.
public GetIntersectionWith ( LineSegment other ) : DoublePoint?
other LineSegment to find intersection with.
Результат DoublePoint?

LineSegment() публичный Метод

Initializes a new instance of the LineSegment class.
Thrown if the two points are the same.
public LineSegment ( DoublePoint start, DoublePoint end ) : System
start DoublePoint Segment's start point.
end DoublePoint Segment's end point.
Результат System