| java.lang.Object org.geotools.math.Line
Line | public class Line implements Cloneable,Serializable(Code) | | Equation of a line in a two dimensional space (x,y).
A line has an equation of the form y=ax+b.
At the difference of
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
Line.y method. Method
Line.x compute the converse and should work even if the line is vertical.
version: $Id: Line.java 22443 2006-10-27 20:47:22Z desruisseaux $ author: Martin Desruisseaux since: 2.0 See Also: Point2D See Also: Line2D See Also: Plane |
Constructor Summary | |
public | Line() Construct an initially unitialized line. | public | Line(double slope, double y0) Construct a line with the specified slope and offset. |
Method Summary | |
public Object | clone() Returns a clone of this line. | public boolean | equals(Object object) Compare this object with the specified one for equality. | final public double | getSlope() Returns the slope. | final public double | getX0() Returns the x value for y==0. | final public double | getY0() Returns the y value for x==0. | public int | hashCode() Returns a hash code value for this line. | public Point2D | intersectionPoint(Line line) Returns the intersection point between this line and the specified one.
If both lines are parallel, then this method returns
null .
Parameters: line - The line to intersect. | public Point2D | intersectionPoint(Line2D line) Returns the intersection point between this line and the specified bounded line.
If both lines are parallel or if the specified
line doesn't reach
this line (since
Line2D do not extends toward infinities), then this
method returns
null .
Parameters: line - The bounded line to intersect. | public Line2D | isoscelesTriangleBase(Point2D summit, double sideLength) Compute the base of a isosceles triangle having the specified summit and side length.
The base will be colinear with this line. | public Point2D | nearestColinearPoint(Point2D point) Returns the nearest point on this line from the specified point.
Parameters: point - An arbitrary point. | public void | setLine(double slope, double y0) Set the slope and offset for this line. | public void | setLine(Line2D line) Set a line colinear with the specified line segment. | public void | setLine(Point2D p1, Point2D p2) Set a line through the specified point. | public 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. | public String | toString() Returns a string representation of this line. | public void | translate(double dx, double dy) Translate the line. | final public double | x(double y) Compute x=f-1(y).
If the line is horizontal, then this method returns an infinite value.
This method is final for performance reason.
Parameters: y - The y value. | final public double | y(double x) Compute y=f(x).
If the line is vertical, then this method returns an infinite value.
This method is final for performance reason.
Parameters: x - The x value. |
Line | public Line()(Code) | | Construct an initially unitialized line. All methods will returns
Double.NaN .
|
Line | public Line(double slope, double y0)(Code) | | Construct a line with the specified slope and offset.
The linear equation will be y=slope*x+y0.
Parameters: slope - The slope. Parameters: y0 - The y value at x==0. See Also: Line.setLine(double,double) |
clone | public Object clone()(Code) | | Returns a clone of this line.
|
equals | public boolean equals(Object object)(Code) | | Compare this object with the specified one for equality.
|
getSlope | final public double getSlope()(Code) | | Returns the slope.
|
getX0 | final public double getX0()(Code) | | Returns the x value for y==0.
Coordinate (x0,0) is the intersection point with the x axis.
|
getY0 | final public double getY0()(Code) | | Returns the y value for x==0.
Coordinate (0, y0) is the intersection point with the y axis.
|
hashCode | public int hashCode()(Code) | | Returns a hash code value for this line.
|
intersectionPoint | public Point2D intersectionPoint(Line line)(Code) | | Returns the intersection point between this line and the specified one.
If both lines are parallel, then this method returns
null .
Parameters: line - The line to intersect. The intersection point, or null . |
intersectionPoint | public Point2D intersectionPoint(Line2D line)(Code) | | Returns the intersection point between this line and the specified bounded line.
If both lines are parallel or if the specified
line doesn't reach
this line (since
Line2D do not extends toward infinities), then this
method returns
null .
Parameters: line - The bounded line to intersect. The intersection point, or null . |
isoscelesTriangleBase | public Line2D isoscelesTriangleBase(Point2D summit, double sideLength)(Code) | | Compute the base of a isosceles triangle having the specified summit and side length.
The base will be colinear with this line. In other words, this method compute two
points (x1,y1) and (x2,y2) located in
such a way that:
- Both points are on this line.
- The distance between any of the two points and the specified
summit is exactly
sideLength .
Parameters: summit - The summit of the isosceles triangle. Parameters: sideLength - The length for the two sides of the isosceles triangle. The base of the isoscele triangle, colinear with this line, or null if the base can't be computed. If non-null, then the triangle is the figure formedby joining (x1,y1), (x2,y2) and summit . |
nearestColinearPoint | public Point2D nearestColinearPoint(Point2D point)(Code) | | Returns the nearest point on this line from the specified point.
Parameters: point - An arbitrary point. The point on this line which is the nearest of the specified point . |
setLine | public void setLine(Line2D line)(Code) | | Set a line colinear with the specified line segment. The line will continues
toward infinity after the line segment extremities.
Parameters: line - The line segment. See Also: Line.setLine(Point2D,Point2D) |
setLine | public void setLine(Point2D p1, Point2D p2)(Code) | | Set a line through the specified point. The line will continues
toward infinity after the point.
Parameters: p1 - Coordinate of the first point. Parameters: p2 - Coordinate of the second point. See Also: Line.setLine(Line2D) |
setLine | public double setLine(double[] x, double[] y) throws MismatchedSizeException(Code) | | 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. This method assume that the x values are precise
and all uncertainty is in y.
Reference: Linear
Regression Curve Fitting.
Parameters: x - Vector of x values (independant variable). Parameters: y - Vector of y values (dependant variable). Estimation of the correlation coefficient. The closerthis coefficient is to 1, the better the fit. throws: MismatchedSizeException - if x and y don't have the same length. |
toString | public String toString()(Code) | | Returns a string representation of this line. This method returns
the linear equation in the form "y=m*x+b" .
A string representation of this line. |
translate | public void translate(double dx, double dy)(Code) | | Translate the line. The slope stay unchanged.
Parameters: dx - The horizontal translation. Parameters: dy - The vertical translation. |
x | final public double x(double y)(Code) | | Compute x=f-1(y).
If the line is horizontal, then this method returns an infinite value.
This method is final for performance reason.
Parameters: y - The y value. The x value. See Also: Line.y(double) |
y | final public double y(double x)(Code) | | Compute y=f(x).
If the line is vertical, then this method returns an infinite value.
This method is final for performance reason.
Parameters: x - The x value. The y value. See Also: Line.x(double) |
|
|