Click or drag to resize
Accord.NET (logo)

LineSegment Class

The class encapsulates 2D line segment and provides some tool methods related to lines.
Inheritance Hierarchy
SystemObject
  Accord.Math.GeometryLineSegment

Namespace:  Accord.Math.Geometry
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public sealed class LineSegment
Request Example View Source

The LineSegment type exposes the following members.

Constructors
  NameDescription
Public methodLineSegment
Initializes a new instance of the LineSegment class.
Top
Properties
  NameDescription
Public propertyEnd
End point of the line segment.
Public propertyLength
Get segment's length - Euclidean distance between its Start and End points.
Public propertyStart
Start point of the line segment.
Top
Methods
  NameDescription
Public methodDistanceToPoint
Calculate Euclidean distance between a point and a finite line segment.
Public methodEquals
Check if this instance of LineSegment equals to the specified one.
(Overrides ObjectEquals(Object).)
Public methodGetHashCode
Get hash code for this instance.
(Overrides ObjectGetHashCode.)
Public methodGetIntersectionWith(Line)
Finds, provided it exists, the intersection point with the specified Line.
Public methodGetIntersectionWith(LineSegment)
Finds, provided it exists, the intersection point with the specified LineSegment.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Get string representation of the class.
(Overrides ObjectToString.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Equality operator - checks if two line segments have equal parameters.
Public operatorStatic member(LineSegment to Line)
Converts this LineSegment to a Line by discarding its endpoints and extending it infinitely in both directions.
Public operatorStatic memberInequality
Inequality operator - checks if two lines have different parameters.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

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 Point( 0, 0 ), new Point( 3, 4 ) );
// get segment's length
float length = segment.Length;

// get intersection point with a line
Point? intersection = segment.GetIntersectionWith(
    new Line( new Point( -3, 8 ), new Point( 0, 4 ) ) );
See Also