Top Description Fields Constructors Methods
org.apache.commons.math3.geometry.euclidean.twod

public Class Segment

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.geometry.euclidean.twod.PolygonsSet.ConnectableSegment
Imports
org.apache.commons.math3.geometry.Point, org.apache.commons.math3.util.FastMath

Simple container for a two-points segment.
Since
3.0

Field Summary

Modifier and TypeField and Description
private final Vector2D
end

End point of the segment.

private final Line
line

Line containing the segment.

private final Vector2D
start

Start point of the segment.

Constructor Summary

AccessConstructor and Description
public
Segment(final Vector2D
start point of the segment
start
,
final Vector2D
end point of the segment
end
,
final Line
line containing the segment
line
)

Build a segment.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

distance between the instance and the point
distance
(final Vector2D
to check
p
)

Calculates the shortest distance from a point to this line segment.

public Vector2D

Returns:

end point of the segment
getEnd
()

Get the end point of the segment.

public Line

Returns:

line containing the segment
getLine
()

Get the line containing the segment.

public Vector2D

Returns:

start point of the segment
getStart
()

Get the start point of the segment.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

endback to summary
private final Vector2D end

End point of the segment.

lineback to summary
private final Line line

Line containing the segment.

startback to summary
private final Vector2D start

Start point of the segment.

Constructor Detail

Segmentback to summary
public Segment(final Vector2D start, final Vector2D end, final Line line)

Build a segment.

Parameters
start:Vector2D

start point of the segment

end:Vector2D

end point of the segment

line:Line

line containing the segment

Method Detail

distanceback to summary
public double distance(final Vector2D p)

Calculates the shortest distance from a point to this line segment.

If the perpendicular extension from the point to the line does not cross in the bounds of the line segment, the shortest distance to the two end points will be returned.

Algorithm adapted from: Thread @ Codeguru
Parameters
p:Vector2D

to check

Returns:double

distance between the instance and the point

Since
3.1
getEndback to summary
public Vector2D getEnd()

Get the end point of the segment.

Returns:Vector2D

end point of the segment

getLineback to summary
public Line getLine()

Get the line containing the segment.

Returns:Line

line containing the segment

getStartback to summary
public Vector2D getStart()

Get the start point of the segment.

Returns:Vector2D

start point of the segment