public class GLine2D
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
GLine2D.Fitter |
Modifier and Type | Field and Description |
---|---|
protected double |
dx
A vector representing the slope of the line
|
protected double |
dy
A vector representing the slope of the line
|
(package private) boolean |
normalizedp |
(package private) boolean |
normalizedSlope |
(package private) double[] |
p
A point that the line passes through.
|
(package private) static long |
serialVersionUID |
protected static GLine2D |
XAXIS |
protected static GLine2D |
YAXIS |
Constructor and Description |
---|
GLine2D() |
GLine2D(double[] p1,
double[] p2)
Create a new line through two points.
|
GLine2D(double M,
double b)
Create a new line
|
GLine2D(double dx,
double dy,
double[] p)
Create a new line
|
Modifier and Type | Method and Description |
---|---|
double |
distanceTo(double[] p) |
static GLine2D |
fromRmatrix(Matrix R)
Create a line from the vector from the origin to the line that
is perpendicular to the line.
|
static GLine2D |
fromRTheta(double r,
double theta)
Create a new line given a distance and angle from the origin
that is perpendicular to the line.
|
static GLine2D |
fromThetaPoint(double theta,
double[] p)
Create a line that is at angle theta from the x axis and passes
through point p
|
double |
getB()
Get the y intercept of the line
|
double |
getDistX(double[] p0)
Is point p to the left of the line?
|
double |
getDistY(double[] p0)
What is the vertical distance between p and the line?
|
double |
getDx()
Get component of unit vector
|
double |
getDy()
Get component of unit vector
|
double |
getLineCoordinate(double[] p)
Get the coordinate of a point (on this line), with 0
corresponding to the point on the line that is perpendicular to
a line passing through the origin and the line.
|
double |
getM()
Get the slope of the line
|
double[] |
getPoint()
Get an arbitrary point on the line.
|
double[] |
getPointOfCoordinate(double coord)
The inverse of getLineCoordinate.
|
Matrix |
getR()
The 2x1 vector from the origin to the line that is
perpendicular to the line.
|
double |
getTheta()
Get the angle of the line (the angle between the line and the
X axis.)
|
Matrix |
getU()
The 2x1 unit vector corresponding to the slope of the line.
|
double[] |
intersectionWith(GLine2D l)
Compute the point where two lines intersect, or null if the lines are parallel.
|
static GLine2D |
lsqFit(java.util.List<double[]> points) |
static GLine2D |
lsqFit(java.util.List<double[]> points,
double[] weights) |
static GLine2D |
lsqFitXYW(java.util.List<double[]> xyweight) |
static void |
main(java.lang.String[] args)
Self tests
|
protected void |
normalizeP() |
protected void |
normalizeSlope() |
void |
optimize()
Hint that the object should be optimized for future computation by putting
the internal representation into a more convenient format.
|
GLine2D |
parallelLineThrough(double[] pin)
Return a line parallel to this line that passes through the
specified point.
|
double |
perpendicularDistanceTo(double[] pin)
Compute the perpendicular distance between a point and the
line
|
GLine2D |
perpendicularLine()
A line perpendicular to this line.
|
GLine2D |
perpendicularLineThrough(double[] pin)
The line perpendicular to this line that passes through point
p
|
double[] |
pointOnLineClosestTo(double[] pin) |
(package private) static double |
square(double x) |
java.lang.String |
toString() |
protected static GLine2D YAXIS
protected static GLine2D XAXIS
static final long serialVersionUID
protected double dx
protected double dy
double[] p
boolean normalizedSlope
boolean normalizedp
public GLine2D()
public GLine2D(double dx, double dy, double[] p)
dx
- A change in X corresponding to dydy
- A change in Y corresponding to dxp
- A point that the line passes throughpublic GLine2D(double M, double b)
M
- the slopeb
- the y interceptpublic GLine2D(double[] p1, double[] p2)
public void optimize()
protected void normalizeSlope()
public double getM()
public double getB()
public double getLineCoordinate(double[] p)
public double[] getPointOfCoordinate(double coord)
public static GLine2D fromRmatrix(Matrix R)
R
- a 2x1 matrix [x y]'public static GLine2D fromRTheta(double r, double theta)
public static GLine2D fromThetaPoint(double theta, double[] p)
public GLine2D perpendicularLine()
protected void normalizeP()
public Matrix getR()
public Matrix getU()
public double getTheta()
public GLine2D perpendicularLineThrough(double[] pin)
public GLine2D parallelLineThrough(double[] pin)
public double[] intersectionWith(GLine2D l)
public double[] pointOnLineClosestTo(double[] pin)
public double perpendicularDistanceTo(double[] pin)
public double distanceTo(double[] p)
public java.lang.String toString()
toString
in class java.lang.Object
public double getDistY(double[] p0)
public double getDistX(double[] p0)
public double getDx()
public double getDy()
public double[] getPoint()
public static void main(java.lang.String[] args)
static final double square(double x)
public static GLine2D lsqFit(java.util.List<double[]> points)
public static GLine2D lsqFit(java.util.List<double[]> points, double[] weights)
public static GLine2D lsqFitXYW(java.util.List<double[]> xyweight)