|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.geometry.xy.XyLine
public class XyLine
A geometric, infinite line in (x, y) space.
This is a "real" line, not a segment. It is infinite, defined by a vector and y-intercept. Vectors are used instead of slopes since vertical lines have undefined slopes.
In order to help prevent weird errors in client code, IllegalStateException is thrown by getSlope(), getXIntercept(), and getYIntercept(). These values may be undefined if the line is horizontal or vertical, and your code should not call them unless you first test isHorizontal() and isVertical().
Copyright 2007 Partner Software, Inc.
| Method Summary | |
|---|---|
static XyLine |
forPoints(XyPoint p1,
XyPoint p2)
Returns the line going through the given points. |
static XyLine |
forSlopeIntercept(double slope,
double intercept)
Returns a line for the given slope and y-intercept. |
static XyLine |
forVector(XyVector vector)
Returns the line going through the origin with the given vector direction. |
static XyLine |
forX(double x)
Returns a vertical line for the given x value. |
static XyLine |
forY(double y)
Returns a horizontal line for the given y value. |
double |
getSlope()
The slope (usually annotated "m"). |
double |
getXIntercept()
The x-intercept. |
double |
getYIntercept()
The y-intercept (usually annotated "b"). |
XyPoint |
intersectionWith(XyLine nother)
Find the intersection of the two lines. |
boolean |
isHorizontal()
Returns true if the line is horizontal (no rise, all run). |
boolean |
isVertical()
Returns true if the line is vertical (all rise, no run). |
double |
solveForX(double y)
Solve for x, given y. |
double |
solveForY(double x)
Solve for y, given x. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static XyLine forX(double x)
public static XyLine forY(double y)
public static XyLine forSlopeIntercept(double slope,
double intercept)
slope - intercept -
public static XyLine forPoints(XyPoint p1,
XyPoint p2)
p1 - p2 -
public static XyLine forVector(XyVector vector)
vector -
public double solveForX(double y)
public double solveForY(double x)
public XyPoint intersectionWith(XyLine nother)
public boolean isHorizontal()
public boolean isVertical()
public double getSlope()
public double getYIntercept()
public double getXIntercept()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||