Package com.frcteam3255.utils
Class SN_Lerp
java.lang.Object
com.frcteam3255.utils.SN_Lerp
Linear Interpolation Table for finding the best value based on limited data
points. "Borrowed" from 1706's 2022 code.
How to use:
1. Make list of SN_Point2D's that contain gathered information
2. Create new SN_Lerp with this list of points
3. On the created SN_Lerp, call getOutput() with the desired x value and it will return a linearly interpolated y value between the two closest datapoints
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublegetOutput(double input) Get a linearly interpolated output from the tablegetTable()Get list of pointsdouble[]getX()Get X valuesdouble[]getY()Get Y Valuesstatic doubleinterpolate(double input, SN_Point2D point1, SN_Point2D point2) Interpolate between two SN_Point2Ds
-
Field Details
-
size
public final int size
-
-
Constructor Details
-
SN_Lerp
Create new SN_Lerp- Parameters:
points- List of SN_Point2D's
-
-
Method Details
-
getOutput
public double getOutput(double input) Get a linearly interpolated output from the tableSequentially searches through all values of table. May not perform well with large datasets
- Parameters:
input- X input- Returns:
- Linearly interpolated Y value between the two closest datapoints
-
interpolate
Interpolate between two SN_Point2Ds- Parameters:
input- Desired X valuepoint1- Closest point below desired X valuepoint2- Closest point above desired X value- Returns:
- interpolated Y value
-
getX
public double[] getX()Get X values- Returns:
- X values
-
getY
public double[] getY()Get Y Values- Returns:
- Y Values
-
getTable
Get list of points- Returns:
- list of points
-