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
    boolean equals​(LinearEquation linearEquation)
    Checks if linearEquation is equal to this.
    float get​(float x)
    Gets the y value at the given x.
    float getSlope()
    Gets the slope.
    float getYIntercept()
    Gets the y-intercept.
    static LinearEquation pointsToLine​(float[] a, float[] b)
    Returns the linear equation from points a and b.
    void setSlope​(float slope)
    Sets the slope.
    void setYIntercept​(float yIntercept)
    Sets the y-intercept.
    java.lang.String toString()
    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 line
      yIntercept - y-intercept of the line
  • Method Details

    • pointsToLine

      public static LinearEquation pointsToLine​(float[] a, float[] b)
      Returns the linear equation from points a and b.
      Parameters:
      a - the first point
      b - 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.
      Specified by:
      get in interface Equation
      Parameters:
      x - the x value
      Returns:
      y the y value of the function
    • toString

      public java.lang.String toString()
      Returns the standard form of the function, y = mx + b.
      Specified by:
      toString in interface Equation
      Overrides:
      toString in class java.lang.Object
      Returns:
      string the standard form of the function
    • equals

      public boolean equals​(LinearEquation linearEquation)
      Checks if linearEquation is equal to this.
      Parameters:
      linearEquation - LinearEquation to set equality
      Returns:
      boolean linearEquation == this