NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
NetTopologySuite.Geometries.LineSegment Class Reference

Represents a line segment defined by two Coordinates. Provides methods to compute various geometric properties and relationships of line segments. This class is designed to be easily mutable (to the extent of having its contained points public). This supports a common pattern of reusing a single LineSegment object as a way of computing segment properties on the segments defined by arrays or lists of Coordinates. More...

Inheritance diagram for NetTopologySuite.Geometries.LineSegment:
NetTopologySuite.Simplify.TaggedLineSegment

Public Member Functions

 LineSegment (Coordinate p0, Coordinate p1)
 Creates an instance of this class using two coordinates More...
 
 LineSegment (LineSegment ls)
 Creates an instance of this class using another instance More...
 
 LineSegment ()
 
 LineSegment (double x0, double y0, double x1, double y1)
 Creates an instance of this class More...
 
Coordinate GetCoordinate (int i)
 
void SetCoordinates (LineSegment ls)
 
void SetCoordinates (Coordinate p0, Coordinate p1)
 
int OrientationIndex (LineSegment seg)
 Determines the orientation of a LineSegment relative to this segment. The concept of orientation is specified as follows: Given two line segments A and L, A is to the left of a segment L if A lies wholly in the closed half-plane lying to the left of L A is to the right of a segment L if A lies wholly in the closed half-plane lying to the right of L otherwise, A has indeterminate orientation relative to L. This happens if A is collinear with L or if A crosses the line determined by L. More...
 
int OrientationIndex (Coordinate p)
 Determines the orientation index of a Coordinate relative to this segment. The orientation index is as defined in CGAlgorithms.ComputeOrientation. /summary> More...
 
void Reverse ()
 Reverses the direction of the line segment. More...
 
void Normalize ()
 Puts the line segment into a normalized form. This is useful for using line segments in maps and indexes when topological equality rather than exact equality is desired. More...
 
double Distance (LineSegment ls)
 Computes the distance between this line segment and another one. More...
 
double Distance (Coordinate p)
 Computes the distance between this line segment and a point. More...
 
double DistancePerpendicular (Coordinate p)
 Computes the perpendicular distance between the (infinite) line defined by this line segment and a point. More...
 
Coordinate PointAlong (double segmentLengthFraction)
 Computes the Coordinate that lies a given fraction along the line defined by this segment. More...
 
Coordinate PointAlongOffset (double segmentLengthFraction, double offsetDistance)
 Computes the Coordinate that lies a given More...
 
double ProjectionFactor (Coordinate p)
 Computes the Projection Factor for the projection of the point p onto this LineSegment. The Projection Factor is the constant r by which the vector for this segment must be multiplied to equal the vector for the projection of p on the line defined by this segment. The projection factor will lie in the range (-inf, +inf), or be NaN if the line segment has zero length. More...
 
double SegmentFraction (Coordinate inputPt)
 Computes the fraction of distance (in [0.0, 1.0]) that the projection of a point occurs along this line segment. If the point is beyond either ends of the line segment, the closest fractional value (0.0 or 1.0) is returned. More...
 
Coordinate Project (Coordinate p)
 Compute the projection of a point onto the line determined by this line segment. Note that the projected point may lie outside the line segment. If this is the case, the projection factor will lie outside the range [0.0, 1.0]. More...
 
LineSegment Project (LineSegment seg)
 Project a line segment onto this line segment and return the resulting line segment. The returned line segment will be a subset of the target line line segment. This subset may be null, if the segments are oriented in such a way that there is no projection. Note that the returned line may have zero length (i.e. the same endpoints). This can happen for instance if the lines are perpendicular to one another. More...
 
Coordinate ClosestPoint (Coordinate p)
 Computes the closest point on this line segment to another point. More...
 
Coordinate[] ClosestPoints (LineSegment line)
 Computes the closest points on a line segment. More...
 
Coordinate Intersection (LineSegment line)
 Computes an intersection point between two segments, if there is one. There may be 0, 1 or many intersection points between two segments. If there are 0, null is returned. If there is 1 or more, a single one is returned (chosen at the discretion of the algorithm). If more information is required about the details of the intersection, the {RobustLineIntersector} class should be used. More...
 
Coordinate LineIntersection (LineSegment line)
 Computes the intersection point of the lines defined by two segments, if there is one. More...
 
ILineString ToGeometry (IGeometryFactory geomFactory)
 Creates a LineString with the same coordinates as this segment More...
 
override bool Equals (object o)
 Returns true if o has the same values for its points. More...
 
int CompareTo (object o)
 Compares this object with the specified object for order. Uses the standard lexicographic ordering for the points in the LineSegment. More...
 
bool EqualsTopologically (LineSegment other)
 Returns true if other is topologically equal to this LineSegment (e.g. irrespective of orientation). More...
 
override string ToString ()
 
override int GetHashCode ()
 Return HashCode. More...
 

Static Public Member Functions

static bool operator== (LineSegment obj1, LineSegment obj2)
 
static bool operator!= (LineSegment obj1, LineSegment obj2)
 

Properties

Coordinate P1 [get, set]
 The end-point More...
 
Coordinate P0 [get, set]
 The start-point More...
 
double Length [get]
 Computes the length of the line segment. More...
 
bool IsHorizontal [get]
 Tests whether the segment is horizontal. More...
 
bool IsVertical [get]
 Tests whether the segment is vertical. More...
 
double Angle [get]
 summary>The midpoint of the segment More...
 
Coordinate MidPoint [get]
 

Detailed Description

Represents a line segment defined by two Coordinates. Provides methods to compute various geometric properties and relationships of line segments. This class is designed to be easily mutable (to the extent of having its contained points public). This supports a common pattern of reusing a single LineSegment object as a way of computing segment properties on the segments defined by arrays or lists of Coordinates.

Constructor & Destructor Documentation

NetTopologySuite.Geometries.LineSegment.LineSegment ( Coordinate  p0,
Coordinate  p1 
)

Creates an instance of this class using two coordinates

Parameters
p0The start-point
p1The end-point
NetTopologySuite.Geometries.LineSegment.LineSegment ( LineSegment  ls)

Creates an instance of this class using another instance

Parameters
ls
NetTopologySuite.Geometries.LineSegment.LineSegment ( )

NetTopologySuite.Geometries.LineSegment.LineSegment ( double  x0,
double  y0,
double  x1,
double  y1 
)

Creates an instance of this class

Parameters
x0
y0
x1
y1

Member Function Documentation

Coordinate NetTopologySuite.Geometries.LineSegment.ClosestPoint ( Coordinate  p)

Computes the closest point on this line segment to another point.

Parameters
pThe point to find the closest point to.
Returns
A Coordinate which is the closest point on the line segment to the point p.
Coordinate [] NetTopologySuite.Geometries.LineSegment.ClosestPoints ( LineSegment  line)

Computes the closest points on a line segment.

Parameters
line
Returns
A pair of Coordinates which are the closest points on the line segments.
int NetTopologySuite.Geometries.LineSegment.CompareTo ( object  o)

Compares this object with the specified object for order. Uses the standard lexicographic ordering for the points in the LineSegment.

Parameters
oThe LineSegment with which this LineSegment is being compared.
Returns
A negative integer, zero, or a positive integer as this LineSegment is less than, equal to, or greater than the specified LineSegment.
double NetTopologySuite.Geometries.LineSegment.Distance ( LineSegment  ls)

Computes the distance between this line segment and another one.

Parameters
ls
Returns
double NetTopologySuite.Geometries.LineSegment.Distance ( Coordinate  p)

Computes the distance between this line segment and a point.

double NetTopologySuite.Geometries.LineSegment.DistancePerpendicular ( Coordinate  p)

Computes the perpendicular distance between the (infinite) line defined by this line segment and a point.

Parameters
p
Returns
override bool NetTopologySuite.Geometries.LineSegment.Equals ( object  o)

Returns true if o has the same values for its points.

Parameters
oA LineSegment with which to do the comparison.
Returns
true if o is a LineSegment with the same values for the x and y ordinates.
bool NetTopologySuite.Geometries.LineSegment.EqualsTopologically ( LineSegment  other)

Returns true if other is topologically equal to this LineSegment (e.g. irrespective of orientation).

Parameters
otherA LineSegment with which to do the comparison.
Returns
true if other is a LineSegment with the same values for the x and y ordinates.
Coordinate NetTopologySuite.Geometries.LineSegment.GetCoordinate ( int  i)

Parameters
i
Returns
override int NetTopologySuite.Geometries.LineSegment.GetHashCode ( )

Return HashCode.

Coordinate NetTopologySuite.Geometries.LineSegment.Intersection ( LineSegment  line)

Computes an intersection point between two segments, if there is one. There may be 0, 1 or many intersection points between two segments. If there are 0, null is returned. If there is 1 or more, a single one is returned (chosen at the discretion of the algorithm). If more information is required about the details of the intersection, the {RobustLineIntersector} class should be used.

Parameters
lineA line segment
Returns
An intersection point, or null if there is none.

RobustLineIntersector

Coordinate NetTopologySuite.Geometries.LineSegment.LineIntersection ( LineSegment  line)

Computes the intersection point of the lines defined by two segments, if there is one.

There may be 0, 1 or an infinite number of intersection points between two lines. If there is a unique intersection point, it is returned. Otherwise, null is returned. If more information is required about the details of the intersection, the RobustLineIntersector class should be used.

Parameters
lineA line segment defining a straight line
Returns
An intersection point, or null if there is none or an infinite number
See also
RobustLineIntersector
void NetTopologySuite.Geometries.LineSegment.Normalize ( )

Puts the line segment into a normalized form. This is useful for using line segments in maps and indexes when topological equality rather than exact equality is desired.

static bool NetTopologySuite.Geometries.LineSegment.operator!= ( LineSegment  obj1,
LineSegment  obj2 
)
static

Parameters
obj1
obj2
Returns
static bool NetTopologySuite.Geometries.LineSegment.operator== ( LineSegment  obj1,
LineSegment  obj2 
)
static

Parameters
obj1
obj2
Returns
int NetTopologySuite.Geometries.LineSegment.OrientationIndex ( LineSegment  seg)

Determines the orientation of a LineSegment relative to this segment. The concept of orientation is specified as follows: Given two line segments A and L, A is to the left of a segment L if A lies wholly in the closed half-plane lying to the left of L A is to the right of a segment L if A lies wholly in the closed half-plane lying to the right of L otherwise, A has indeterminate orientation relative to L. This happens if A is collinear with L or if A crosses the line determined by L.

Parameters
segThe LineSegment to compare.
Returns
1 if seg is to the left of this segment, -1 if seg is to the right of this segment, 0 if seg has indeterminate orientation relative to this segment.
int NetTopologySuite.Geometries.LineSegment.OrientationIndex ( Coordinate  p)

Determines the orientation index of a Coordinate relative to this segment. The orientation index is as defined in CGAlgorithms.ComputeOrientation. /summary>

Parameters
segthe LineSegment to compare
Returns
See also
CGAlgorithms::computeOrientation(Coordinate, Coordinate, Coordinate)
Returns
  • 1 if p is to the left of this segment
  • -1 if p is to the right of this segment
  • 0 if p is collinear with this segment
"
Coordinate NetTopologySuite.Geometries.LineSegment.PointAlong ( double  segmentLengthFraction)

Computes the Coordinate that lies a given fraction along the line defined by this segment.

A fraction of

0.0

returns the start point of the segment; A fraction of

1.0

returns the end point of the segment. If the fraction is < 0.0 or > 1.0 the point returned will lie before the start or beyond the end of the segment.

Parameters
segmentLengthFractionthe fraction of the segment length along the line
Returns
the point at that distance
Coordinate NetTopologySuite.Geometries.LineSegment.PointAlongOffset ( double  segmentLengthFraction,
double  offsetDistance 
)

Computes the Coordinate that lies a given

A fraction along the line defined by this segment and offset from the segment by a given distance. A fraction of

0.0

offsets from the start point of the segment; A fraction of

1.0

offsets from the end point of the segment. The computed point is offset to the left of the line if the offset distance is positive, to the right if negative.

Parameters
segmentLengthFractionthe fraction of the segment length along the line
offsetDistancethe distance the point is offset from the segment

(positive is to the left, negative is to the right)

Returns
the point at that distance and offset
Exceptions
ApplicationExceptionif the segment has zero length
Coordinate NetTopologySuite.Geometries.LineSegment.Project ( Coordinate  p)

Compute the projection of a point onto the line determined by this line segment. Note that the projected point may lie outside the line segment. If this is the case, the projection factor will lie outside the range [0.0, 1.0].

Parameters
p
Returns
LineSegment NetTopologySuite.Geometries.LineSegment.Project ( LineSegment  seg)

Project a line segment onto this line segment and return the resulting line segment. The returned line segment will be a subset of the target line line segment. This subset may be null, if the segments are oriented in such a way that there is no projection. Note that the returned line may have zero length (i.e. the same endpoints). This can happen for instance if the lines are perpendicular to one another.

Parameters
segThe line segment to project.
Returns
The projected line segment, or null if there is no overlap.
double NetTopologySuite.Geometries.LineSegment.ProjectionFactor ( Coordinate  p)

Computes the Projection Factor for the projection of the point p onto this LineSegment. The Projection Factor is the constant r by which the vector for this segment must be multiplied to equal the vector for the projection of p on the line defined by this segment. The projection factor will lie in the range (-inf, +inf), or be NaN if the line segment has zero length.

Parameters
pThe point to compute the factor for
Returns
The projection factor for the point
void NetTopologySuite.Geometries.LineSegment.Reverse ( )

Reverses the direction of the line segment.

double NetTopologySuite.Geometries.LineSegment.SegmentFraction ( Coordinate  inputPt)

Computes the fraction of distance (in [0.0, 1.0]) that the projection of a point occurs along this line segment. If the point is beyond either ends of the line segment, the closest fractional value (0.0 or 1.0) is returned.

Essentially, this is the ProjectionFactor(Coordinate) clamped to the range [0.0, 1.0].

Parameters
inputPtthe point
Returns
the fraction along the line segment the projection of the point occurs
void NetTopologySuite.Geometries.LineSegment.SetCoordinates ( LineSegment  ls)

Parameters
ls
void NetTopologySuite.Geometries.LineSegment.SetCoordinates ( Coordinate  p0,
Coordinate  p1 
)

Parameters
p0
p1
ILineString NetTopologySuite.Geometries.LineSegment.ToGeometry ( IGeometryFactory  geomFactory)

Creates a LineString with the same coordinates as this segment

Parameters
geomFactorythe geometery factory to use
Returns
A LineString with the same geometry as this segment
override string NetTopologySuite.Geometries.LineSegment.ToString ( )

Returns

Property Documentation

double NetTopologySuite.Geometries.LineSegment.Angle
get

summary>The midpoint of the segment

Returns
The angle this segment makes with the x-axis (in radians).
bool NetTopologySuite.Geometries.LineSegment.IsHorizontal
get

Tests whether the segment is horizontal.

Returns
true if the segment is horizontal.
bool NetTopologySuite.Geometries.LineSegment.IsVertical
get

Tests whether the segment is vertical.

Returns
true if the segment is vertical.
double NetTopologySuite.Geometries.LineSegment.Length
get

Computes the length of the line segment.

Returns
The length of the line segment.
Coordinate NetTopologySuite.Geometries.LineSegment.P0
getset

The start-point

Coordinate NetTopologySuite.Geometries.LineSegment.P1
getset

The end-point


The documentation for this class was generated from the following file: