public class Line extends Object implements Cloneable, Serializable
The equation parameters for a Line
object can be 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)
computes the converse and should
work even if the line is vertical.
Line2D
which is bounded by (x₁,y₁)
and (x₂,y₂) points, Line
objects extend toward infinity.Plane
,
LinearTransformBuilder
,
Serialized FormDefined in the sis-utility
module
Constructor and Description |
---|
Line()
Constructs an uninitialized line.
|
Line(double slope,
double y0)
Constructs 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 line with the specified object for equality.
|
double |
fit(double[] x,
double[] y)
Given a set of data points x[0 … n-1], y[0 … n-1],
fits them to a straight line y = slope⋅x + y₀ in a
least-squares senses.
|
double |
fit(Iterable<? extends DirectPosition> points)
Given a sequence of points, fits them to a straight line y = slope⋅x +
y₀ in a least-squares senses.
|
int |
hashCode()
Returns a hash code value for this line.
|
void |
setEquation(double slope,
double y0)
Sets this line to the specified slope and offset.
|
void |
setFromPoints(double x1,
double y1,
double x2,
double y2)
Sets a line through the specified points.
|
double |
slope()
Returns the slope.
|
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⁻¹(y).
|
double |
x0()
Returns the x value for y = 0.
|
double |
y(double x)
Computes y = f(x).
|
double |
y0()
Returns the y value for x = 0.
|
public Line()
Double.NaN
.public Line(double slope, double y0)
slope
- The slope.y0
- The y value at x = 0.setEquation(double, double)
public final double x0()
public final double x(double y)
y
- The y value where to evaluate the inverse function.y(double)
public final double y0()
public final double y(double x)
x
- The x value where to evaluate the inverse function.x(double)
public void translate(double dx, double dy)
dx
- The horizontal translation.dy
- The vertical translation.public void setEquation(double slope, double y0)
slope
- The slope.y0
- The y value at x = 0.setFromPoints(double, double, double, double)
,
fit(double[], double[])
public void setFromPoints(double x1, double y1, double x2, double y2)
x1
- Ordinate x of the first point.y1
- Ordinate y of the first point.x2
- Ordinate x of the second point.y2
- Ordinate y of the second point.public double fit(double[] x, double[] y)
x
- Vector of x values (independent variable).y
- Vector of y values (dependent variable).IllegalArgumentException
- if x and y do not have the same length.public double fit(Iterable<? extends DirectPosition> points)
Points shall be two dimensional with ordinate values in the (x,y) order.
Double.NaN
ordinate values are ignored.
points
- The two-dimensional points.MismatchedDimensionException
- if a point is not two-dimensional.public Line clone()
public boolean equals(Object object)
public int hashCode()
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.