Class LinearEquation
java.lang.Object
com.aidano7.bison.algebra.equations.LinearEquation
- All Implemented Interfaces:
Equation
public class LinearEquation extends java.lang.Object implements Equation
- Since:
- 3/30/21
This class represents a linear equation. In standard form, a linear equation is written as y = mx + b.
- Author:
- aidano-7
-
Constructor Summary
Constructors Constructor Description LinearEquation(float slope, float yIntercept)Creates a new instance of LinearEquation -
Method Summary
Modifier and Type Method Description booleanequals(LinearEquation linearEquation)Checks if linearEquation is equal to this.floatget(float x)Gets the y value at the given x.floatgetSlope()Gets the slope.floatgetYIntercept()Gets the y-intercept.static LinearEquationpointsToLine(float[] a, float[] b)Returns the linear equation from points a and b.voidsetSlope(float slope)Sets the slope.voidsetYIntercept(float yIntercept)Sets the y-intercept.java.lang.StringtoString()Returns the standard form of the function, y = mx + b.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
LinearEquation
public LinearEquation(float slope, float yIntercept)Creates a new instance of LinearEquation- Parameters:
slope- slope of the lineyIntercept- y-intercept of the line
-
-
Method Details
-
pointsToLine
Returns the linear equation from points a and b.- Parameters:
a- the first pointb- the second point- Returns:
- LinearEquation equation containing points a and b
-
getSlope
public float getSlope()Gets the slope.- Returns:
- slope the slope of the line
-
setSlope
public void setSlope(float slope)Sets the slope.- Parameters:
slope- the new slope of the line.
-
getYIntercept
public float getYIntercept()Gets the y-intercept.- Returns:
- yIntercept the y-intercept of the line
-
setYIntercept
public void setYIntercept(float yIntercept)Sets the y-intercept.- Parameters:
yIntercept- the new y-intercept of the line.
-
get
public float get(float x)Gets the y value at the given x. -
toString
public java.lang.String toString()Returns the standard form of the function, y = mx + b. -
equals
Checks if linearEquation is equal to this.- Parameters:
linearEquation- LinearEquation to set equality- Returns:
- boolean linearEquation == this
-