public class Line extends Object
y = mx + b, where m is the slope, b is the
y-intercept, and y and x are coordinates in the cartesian plane. Java's
floating point arithmetic has built-in support for infinite values as defined
by the IEEE 754 standard. Special methods are used to test for this
condition. See the API documentation for class Double for
details.| Modifier | Constructor and Description |
|---|---|
protected |
Line()
Creates new Line for subclasses only.
|
|
Line(double m,
double b)
Creates new Line.
|
| Modifier and Type | Method and Description |
|---|---|
double |
getb()
Returns the y-intercept of this line.
|
double |
getm()
Returns the slope of this line.
|
double |
getx(double y)
Returns the value of x given y.
|
double |
gety(double x)
Returns the value of y given x.
|
protected void |
setb(double b)
Sets the value of the intercept for this line.
|
protected void |
setm(double m)
Sets the value of the slope for this line.
|
public Line(double m,
double b)
m - the slope.b - the y-intercept.protected Line()
protected void setm(double m)
m - the new slope.protected void setb(double b)
b - the new intercept.public double getm()
Double.isInfinite()
and Double.isNaN() to find out.public double getb()
Double.isInfinite() and Double.isNaN() to
find out.public double getx(double y)
Double.isInfinite() and
Double.isNaN() to find out.y - a value for y along this line.public double gety(double x)
Double.isInfinite() and
Double.isNaN() to find out.x - a value for x along this line.Copyright © 2012–2020 Emory University. All rights reserved.