Package eu.woolplatform.utils.geom
Class Line
- java.lang.Object
-
- eu.woolplatform.utils.geom.Line
-
public class Line extends Object
This class defines a line. It consists of an origin and a vector. The origin should be considered as an anchor, not as a starting point. The line does not have a start or end.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsPoint(Point point)Returns whether this line contains the specified point.booleanequals(Object obj)PointfindIntersection(Line other)Tries to find an intersection between this line and another line.PointgetOrigin()Returns the origin.VectorgetVector()Returns the vector.inthashCode()booleanisParallel(Line other)Returns whether another line is parallel to this line.voidsetOrigin(Point origin)Sets the origin.voidsetVector(Vector vector)Sets the vector.
-
-
-
Method Detail
-
getOrigin
public Point getOrigin()
Returns the origin.- Returns:
- the origin
-
setOrigin
public void setOrigin(Point origin)
Sets the origin.- Parameters:
origin- the origin
-
getVector
public Vector getVector()
Returns the vector.- Returns:
- the vector
-
setVector
public void setVector(Vector vector)
Sets the vector.- Parameters:
vector- the vector
-
isParallel
public boolean isParallel(Line other)
Returns whether another line is parallel to this line. This is also true if the other line moves in the opposite direction. The other line may or may not overlap this line.- Parameters:
other- the other line- Returns:
- true if the other line is parallel to this line, false otherwise
-
containsPoint
public boolean containsPoint(Point point)
Returns whether this line contains the specified point.- Parameters:
point- the point- Returns:
- true if this line contains the specified point, false otherwise
-
findIntersection
public Point findIntersection(Line other)
Tries to find an intersection between this line and another line. If the lines overlap each other, this method returns the origin of this line. If they are parallel, this method returns null. Otherwise this method returns the intersection.- Parameters:
other- the other line- Returns:
- the intersection or null
-
-