public class Line
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
double |
x1 |
double |
x2 |
double |
y1 |
double |
y2 |
| Constructor and Description |
|---|
Line() |
Line(double x1,
double y1,
double x2,
double y2) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
clipToRectangle(Rectangle rectangle)
Clip this line to rectangle.
|
boolean |
equals(Line nother) |
boolean |
equals(java.lang.Object nother) |
Point |
getCenter() |
double |
getLength() |
double |
getSlope() |
double |
getX1() |
double |
getX2() |
double |
getY1() |
double |
getY2() |
Point |
intersect(Line nother)
Finds the intersection point for the two lines.
|
boolean |
isDegenerate() |
boolean |
isHorizontal() |
boolean |
isRightOf(double x,
double y)
Returns true if this line lies to the "right" of the given point, Imagine
yourself walking from x1,y1 to x2, y2.
|
boolean |
isVertical() |
void |
setToMatch(Line nother) |
void |
setX1(double newX) |
void |
setX2(double newX) |
void |
setY1(double newY) |
void |
setY2(double newY) |
double |
solveForX(double y)
Finds the x for the given y.
|
double |
solveForY(double x)
Finds the y for the given x.
|
void |
sortLeftToRight()
Makes it run from left to right (so x1 <= x2)
|
void |
swapEnds()
Swaps ends (x1 and x2, y1 and y2)
|
java.lang.String |
toString() |
public double getX1()
public void setX1(double newX)
public double getY1()
public void setY1(double newY)
public double getX2()
public void setX2(double newX)
public double getY2()
public void setY2(double newY)
public void setToMatch(Line nother)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isDegenerate()
public boolean isVertical()
public boolean isHorizontal()
public double getSlope()
public double getLength()
public boolean equals(Line nother)
public boolean equals(java.lang.Object nother)
equals in class java.lang.Objectpublic Point getCenter()
public double solveForX(double y)
public double solveForY(double x)
public void sortLeftToRight()
public void swapEnds()
public boolean isRightOf(double x,
double y)
public boolean clipToRectangle(Rectangle rectangle)