public class Line extends Object implements Cloneable, Serializable
Line2D (which are bounded by (x1,y1) and (x2,y2)
points), Line objects extends toward infinity.
The equation parameters for a Line object can bet set at construction time or using
one of the setLine(...) methods. The y value can be computed for a given
x value using the y(double) method. Method x(double) compute the converse and should
work even if the line is vertical.
Point2D,
Line2D,
Plane,
Serialized Form| Constructor and Description |
|---|
Line()
Construct an initially unitialized line.
|
Line(double slope,
double y0)
Construct a line with the specified slope and offset.
|
| Modifier and Type | Method and Description |
|---|---|
Line |
clone()
Returns a clone of this line.
|
boolean |
equals(Object object)
Compares this object with the specified one for equality.
|
double |
getSlope()
Returns the slope.
|
double |
getX0()
Returns the x value for y==0.
|
double |
getY0()
Returns the y value for x==0.
|
int |
hashCode()
Returns a hash code value for this line.
|
Point2D |
intersectionPoint(Line line)
Returns the intersection point between this line and the specified one.
|
Point2D |
intersectionPoint(Line2D line)
Returns the intersection point between this line and the specified bounded line.
|
Line2D |
isoscelesTriangleBase(Point2D summit,
double sideLength)
Computes the base of a isosceles triangle having the specified summit and side length.
|
Point2D |
nearestColinearPoint(Point2D point)
Returns the nearest point on this line from the specified point.
|
double |
setLine(double[] x,
double[] y)
Given a set of data points
x[0..ndata-1], y[0..ndata-1], fit them to a
straight line y=b+mx in a least-squares senses. |
void |
setLine(double slope,
double y0)
Sets the slope and offset for this line.
|
void |
setLine(Line2D line)
Sets a line colinear with the specified line segment.
|
void |
setLine(Point2D p1,
Point2D p2)
Sets a line through the specified point.
|
String |
toString()
Returns a string representation of this line.
|
void |
translate(double dx,
double dy)
Translates the line.
|
double |
x(double y)
Computes x=f-1(y).
|
double |
y(double x)
Computes y=f(x).
|
public Line()
Double.NaN.public Line(double slope,
double y0)
slope - The slope.y0 - The y value at x==0.setLine(double, double)public void setLine(double slope,
double y0)
slope - The slope.y0 - The y value at x==0.setLine(Point2D, Point2D),
setLine(Line2D),
setLine(double[], double[])public void setLine(Line2D line)
line - The line segment.setLine(Point2D,Point2D)public void setLine(Point2D p1, Point2D p2)
p1 - Coordinate of the first point.p2 - Coordinate of the second point.setLine(Line2D)public double setLine(double[] x,
double[] y)
throws IllegalArgumentException
x[0..ndata-1], y[0..ndata-1], fit them to a
straight line y=b+mx in a least-squares senses.
This method assume that the x values are precise and all uncertainty is in
y.
Reference: Linear Regression Curve Fitting.
x - Vector of x values (independant variable).y - Vector of y values (dependant variable).MismatchedSizeException - if x and y don't have the same length.IllegalArgumentExceptionpublic void translate(double dx,
double dy)
dx - The horizontal translation.dy - The vertical translation.public final double y(double x)
x - The x value.x(double)public final double x(double y)
y - The y value.y(double)public final double getY0()
public final double getX0()
public final double getSlope()
public Point2D intersectionPoint(Line line)
null.line - The line to intersect.null.public Point2D intersectionPoint(Line2D line)
line doesn't reach this line (since Line2D do not extends toward infinities), then this method returns null.line - The bounded line to intersect.null.public Point2D nearestColinearPoint(Point2D point)
point - An arbitrary point.point.public Line2D isoscelesTriangleBase(Point2D summit, double sideLength)
summit is exactly
sideLength.
summit - The summit of the isosceles triangle.sideLength - The length for the two sides of the isosceles triangle.null if the
base can't be computed. If non-null, then the triangle is the figure formed by joining
(x1,y1), (x2,y2) and summit.public String toString()
"y=m*x+b".public boolean equals(Object object)
public int hashCode()
public Line clone()
clone in class ObjectObject.clone()Copyright © 1996–2019 Geotools. All rights reserved.