public class Line2 extends Object implements EuclidConstants
| Modifier and Type | Field and Description |
|---|---|
static Line2 |
XAXIS |
static Line2 |
YAXIS |
C_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
Line2(Real2 from,
Real2 to)
generates vector
|
Line2(Real2 from,
Vector2 v)
generates to
|
| Modifier and Type | Method and Description |
|---|---|
Double |
calculateUnsignedDistanceBetweenLines(Line2 line,
Angle eps)
calculated unsigned distance between parallel lines.
|
boolean |
contains(Real2 point,
double eps,
boolean allowExtension)
does a line contain a point.
|
Real2 |
createPointOnLine(Double dist)
creates point at (signed) distance dist from "from" point
newPoint = from + (dist / line.length) * vector
|
Real2 |
createPointOnLine(Double dist,
int index)
creates point at (signed) distance dist from index point
vector = xy(1-index) <- xy(index)
newPoint = xy(index) + (dist / line.length) * vector
|
void |
flipCoordinates()
swaps to and from coordinates.
|
Angle |
getAngleMadeWith(Line2 line)
convenience method.
|
double |
getDistanceFromPoint(Real2 point)
Deprecated.
use new name (unsignedDistanceFromPoint)
|
Real2 |
getFrom() |
Real2 |
getIntersection(Line2 line1)
get intersection of two lines
see softSurfer algorithm
|
double |
getLambda(Real2 p)
gets multiplier of point from "from"
finds nearest point (pp) on line (so avoids rounding errors)
then finds pp = from + vector * lambda
if pp is within segment , lambda is 0, 1
|
double |
getLength()
get length
|
Real2 |
getMidPoint()
get mid point
|
Real2 |
getNearestPointNew(Real2 point)
may be redundant...
|
Real2 |
getNearestPointOnLine(Real2 point)
get nearest point on infinite line.
|
int |
getSerial(Real2 point,
double eps)
gets serial number of point in line specification
if point is within EPS of "from" returns 0
if point is within EPS of "to" returns 1
else returns -1
|
double |
getSignedDistanceFromPoint(Real2 point)
signed perpendicular distance from point to infinite line.
|
double |
getSlope()
get slope.
|
Real2 |
getTo() |
Vector2 |
getUnitVector()
get unit vector convenience
|
double |
getUnsignedDistanceFromPoint(Real2 point)
perpendicular distance from point to infinite line.
|
Vector2 |
getVector() |
double |
getXIntercept()
"c" in y=m*x+c
|
Real2 |
getXY(int i)
get point at either end.
|
double |
getYIntercept()
* "c" in y=m*x+c
|
boolean |
isAntiParallelTo(Line2 line,
Angle eps) |
boolean |
isHorizontal(Angle eps) |
Boolean |
isParallelOrAntiParallelTo(Line2 line,
Angle eps)
are unsigned lines parallel.
|
Boolean |
isParallelTo(Line2 line,
Angle eps)
are two lines parallel within tolerance.
|
Boolean |
isPerpendicularTo(Line2 line,
Angle angleEps) |
boolean |
isVertical(Angle eps) |
void |
setXY(Real2 xy,
int i)
set point at either end.
|
String |
toString() |
public double getSlope()
public double getYIntercept()
public double getXIntercept()
public Real2 getIntersection(Line2 line1)
line1 - public boolean contains(Real2 point, double eps, boolean allowExtension)
point - eps - distance within which point muct approach lineallowExtension - if true allow point to be "outside" line
segmentpublic void flipCoordinates()
public Vector2 getUnitVector()
public double getDistanceFromPoint(Real2 point)
point - public double getSignedDistanceFromPoint(Real2 point)
point - public double getUnsignedDistanceFromPoint(Real2 point)
point - public Real2 getNearestPointNew(Real2 point)
point - public Real2 getNearestPointOnLine(Real2 point)
point - public Boolean isParallelTo(Line2 line, Angle eps)
line - eps - maximum allowed angle between linespublic boolean isAntiParallelTo(Line2 line, Angle eps)
line - eps - maximum allowed angle between unsigned lines (i.e. << Math.PI/2)public Boolean isParallelOrAntiParallelTo(Line2 line, Angle eps)
line - eps - public Double calculateUnsignedDistanceBetweenLines(Line2 line, Angle eps)
uses distance from this.getXY(0) to nearest point on line.
if lines are not exactly parallel the result has no absolute meaning but is heuristically useful.
line - eps - public Angle getAngleMadeWith(Line2 line)
line - public double getLambda(Real2 p)
p - public Real2 getMidPoint()
public double getLength()
public Real2 getFrom()
public Real2 getTo()
public Real2 getXY(int i)
i - (0/from or 1/to)public void setXY(Real2 xy, int i)
i - (0/from or 1/to)public Vector2 getVector()
public Real2 createPointOnLine(Double dist)
dist - public Real2 createPointOnLine(Double dist, int index)
dist - index - public int getSerial(Real2 point, double eps)
public boolean isHorizontal(Angle eps)
public boolean isVertical(Angle eps)
Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.