Package eu.woolplatform.utils.geom
Class LineSegment
- java.lang.Object
-
- eu.woolplatform.utils.geom.LineSegment
-
public class LineSegment extends Object
This class defines a line segment. It consists of a start point and end point.
-
-
Constructor Summary
Constructors Constructor Description LineSegment(double startX, double startY, double endX, double endY)Constructs a new line segment.LineSegment(Point start, Point end)Constructs a new line segment.LineSegment(Point start, Vector vector)Constructs a new line segment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PointgetEnd()Returns the end point.doublegetLength()Returns the length of this line segment.PointgetStart()Returns the start point.voidoffset(double dx, double dy)Moves this line segment by the specified offset.voidrotate(double angle)Rotates this line segment by the specified number of degrees around the start point.voidsetEnd(Point end)Sets the end point.voidsetStart(Point start)Sets the start point.StringtoString()VectortoVector()Returns the vector from the start point to the end point.
-
-
-
Constructor Detail
-
LineSegment
public LineSegment(Point start, Point end)
Constructs a new line segment.- Parameters:
start- the start pointend- the end point
-
LineSegment
public LineSegment(double startX, double startY, double endX, double endY)Constructs a new line segment.- Parameters:
startX- the X position of the start pointstartY- the Y position of the start pointendX- the X position of the end pointendY- the Y position of the end point
-
-
Method Detail
-
getStart
public Point getStart()
Returns the start point.- Returns:
- the start point
-
setStart
public void setStart(Point start)
Sets the start point.- Parameters:
start- the start point
-
getEnd
public Point getEnd()
Returns the end point.- Returns:
- the end point
-
setEnd
public void setEnd(Point end)
Sets the end point.- Parameters:
end- the end point
-
toVector
public Vector toVector()
Returns the vector from the start point to the end point.- Returns:
- the vector from the start point to the end point
-
getLength
public double getLength()
Returns the length of this line segment.- Returns:
- the length of this line segment
-
rotate
public void rotate(double angle)
Rotates this line segment by the specified number of degrees around the start point.- Parameters:
angle- the angle in degrees
-
offset
public void offset(double dx, double dy)Moves this line segment by the specified offset.- Parameters:
dx- the offset along the X axisdy- the offset along the Y axis
-
-