public class DirectionalLine extends Line2D.Double
(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl/language
License of use: Lesser
General Public License (LGPL) , no warranty
Line2D.Double, Line2D.Float
Modifier and Type | Field and Description |
---|---|
static int |
BACKSIDE
point at the back of the line
|
static int |
COLLINEAR
point collinear with the line
|
static int |
FRONTSIDE
point in front of the line
|
static int |
SPANNING
other line is spanning this line
|
x1, x2, y1, y2
Constructor and Description |
---|
DirectionalLine(double x1,
double y1,
double x2,
double y2)
Creates a new DirectionalLine based on the specified coordinates.
|
Modifier and Type | Method and Description |
---|---|
void |
calcNormal()
Calculates the normal to this line.
|
boolean |
equalsCoordinates(DirectionalLine line)
Returns true if the endpoints of this line match the endpoints of the
specified line.
|
boolean |
equalsCoordinatesIgnoreOrder(DirectionalLine line)
Returns true if the endpoints of this line match the endpoints of the
specified line, ignoring endpoint order (if the first point of this line
is equal to the second point of the specified line, and vice versa,
returns true).
|
void |
flip()
Flips this line so that the end points are reversed (in other words,
(x1,y1) becomes (x2,y2) and vice versa) and the normal is changed to
point the opposite direction.
|
double |
getIntersection(Line2D.Double line)
Returns the fraction of intersection along this line.
|
Point2D.Double |
getIntersectionPoint(Line2D.Double line)
Returns the interection point of this line with the specified line.
|
double |
getLineThickness()
Gets the thickness of the line.
|
double |
getNormalx() |
double |
getNormaly() |
int |
getSide(Line2D.Double line)
Gets the side of this line that the specified line segment is on.
|
int |
getSideThick(double x,
double y)
Gets the side of this line the specified point is on.
|
int |
getSideThin(double x,
double y)
Gets the side of this line the specified point is on.
|
void |
normalize()
Normalizes the normal of this line (make the normal's length 1).
|
void |
setLine(double x1,
double y1,
double x2,
double y2) |
void |
setLine(float x1,
float y1,
float x2,
float y2)
Set the line using floats.
|
void |
setLineThickness(double lineThickness)
Sets the tickness of the line.
|
String |
toString() |
getBounds2D, getP1, getP2, getX1, getX2, getY1, getY2
clone, contains, contains, contains, contains, getBounds, getPathIterator, getPathIterator, intersects, intersects, intersectsLine, intersectsLine, linesIntersect, ptLineDist, ptLineDist, ptLineDist, ptLineDistSq, ptLineDistSq, ptLineDistSq, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW, setLine, setLine
public static final int BACKSIDE
public static final int COLLINEAR
public static final int FRONTSIDE
public static final int SPANNING
public DirectionalLine(double x1, double y1, double x2, double y2)
x1
- Coordinate x1y1
- Coordinate y1x2
- Coordinate x2y2
- Coordinate y2public void calcNormal()
public void normalize()
public void setLine(float x1, float y1, float x2, float y2)
x1
- x1 coordinatey1
- y1 coodinatex2
- x2 coordinatey2
- y2 coordinatepublic void setLine(double x1, double y1, double x2, double y2)
setLine
in class Line2D.Double
Line2D.setLine(double, double, double, double)
public void flip()
public boolean equalsCoordinates(DirectionalLine line)
line
- another linepublic boolean equalsCoordinatesIgnoreOrder(DirectionalLine line)
line
- another linepublic String toString()
toString
in class Object
Object.toString()
public int getSideThick(double x, double y)
x
- coordinate xy
- coordinate ypublic int getSideThin(double x, double y)
x
- coordinate xy
- coordinate ypublic int getSide(Line2D.Double line)
line
- line segmentpublic double getIntersection(Line2D.Double line)
line
- a linepublic Point2D.Double getIntersectionPoint(Line2D.Double line)
line
- a linepublic double getLineThickness()
public void setLineThickness(double lineThickness)
lineThickness
- the lineThickness to setpublic double getNormalx()
public double getNormaly()
Copyright © 2002-2012 Delft University of Technology, the Netherlands. All Rights Reserved.