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

**Namespace:**
AForge.Math.Geometry

**Assembly:**
AForge.Math (in AForge.Math.dll) Version: 2.2.5.0 (2.2.5.0)

# Syntax

C# |
---|

public sealed class Line |

# Remarks

The class provides some methods which are related to lines: angle between lines, distance to point, finding intersection point, etc.

Generally, the equation of the line is y = Slope * x + Intercept. However, when Slope is an Infinity, would normally be meaningless, and it would be impossible to distinguish the line x = 5 from the line x = -5. Therefore, if Slope is PositiveInfinity or NegativeInfinity, the line's equation is instead x = Intercept.

Sample usage:

CopyC#

// create a line Line line = Line.FromPoints( new Point( 0, 0 ), new Point( 3, 4 ) ); // check if it is vertical or horizontal if ( line.IsVertical || line.IsHorizontal ) { // ... } // get intersection point with another line Point intersection = line.GetIntersectionWith( Line.FromPoints( new Point( 3, 0 ), new Point( 0, 4 ) ) );