Namespaces

Types in MathNet.Spatial.Euclidean

Type LineSegment2D

Namespace MathNet.Spatial.Euclidean

Parent ValueType

Interfaces IEquatable<LineSegment2D>, IXmlSerializable

This structure represents a line between two points in 2-space. It allows for operations such as computing the length, direction, comparisons, and shifting by a vector.

Constructors

Static Functions

Methods

Properties

Public Constructors

LineSegment2D(Point2D startPoint, Point2D endPoint)

Initializes a new instance of the LineSegment2D struct. Throws an ArgumentException if the startPoint is equal to the endPoint.
Parameters
Point2D startPoint

the starting point of the line segment.

Point2D endPoint

the ending point of the line segment

Public Static Functions

LineSegment2D Parse(string startPointString, string endPointString)

Returns a new Line2D from a pair of strings which represent points. See Parse for details on acceptable formats.
Parameters
string startPointString

The string representation of the first point.

string endPointString

The string representation of the second point.

Return
LineSegment2D

A line segment from the first point to the second point.

Public Methods

Point2D ClosestPointTo(Point2D p)

Returns the closest point on the line to the given point.
Parameters
Point2D p

The point that the returned point is the closest point on the line to

Return
Point2D

The closest point on the line to the provided point

bool Equals(LineSegment2D other, double tolerance)

Returns a value to indicate if a pair of line segments are equal
Parameters
LineSegment2D other

The line segment to compare against.

double tolerance

A tolerance (epsilon) to adjust for floating point error

Return
bool

True if the line segments are equal; otherwise false

bool Equals(LineSegment2D l)

bool Equals(object obj)

int GetHashCode()

Type GetType()

bool IsParallelTo(LineSegment2D other, Angle tolerance)

Checks to determine whether or not two line segments are parallel to each other within a specified angle tolerance
Parameters
LineSegment2D other

The other line to check this one against

Angle tolerance

If the angle between line directions is less than this value, the method returns true

Return
bool

True if the lines are parallel within the angle tolerance, false if they are not

LineSegment2D LineTo(Point2D p)

Returns a new line segment between the closest point on this line segment and a point.
Parameters
Point2D p

the point to create a line to

Return
LineSegment2D

A line segment between the point and the nearest point on this segment.

string ToString()

LineSegment2D TranslateBy(Vector2D vector)

Translates a line according to a provided vector
Parameters
Vector2D vector

A vector to apply

Return
LineSegment2D

A new translated line segment

bool TryIntersect(LineSegment2D other, Nullable`1& intersection, Angle tolerance)

Public Properties

Vector2D Direction get;

Gets a normalized vector in the direction from StartPoint to EndPoint

Point2D EndPoint get; set;

The end point of the line segment

double Length get;

Gets the distance from StartPoint to EndPoint

Point2D StartPoint get; set;

The starting point of the line segment