scaleConversion function
Scale/Convert Y points from Array values to Pixels values, this is important to plot in the correct position and keep the values set proportions.
References
- "Comparison Between Celsius and Fahrenheit Scales". http://www.pstcc.edu/nbs/WebPhysics/Chapter12.htm. Retrieved 2021-03-01.
Implementation
double scaleConversion(
double ay, double yStart, double yEnd, double yMin, double yMax) {
// http://www.pstcc.edu/nbs/WebPhysics/Chapter12.htm
// (- yEnd + yPoint) / (yEnd - yStart) = (yMin - ay[i]) / (yMax - yMin)
// (- yEnd + yPoint) = (yEnd - yStart) * (yMin - ay[i]) / (yMax - yMin)
// yPoint = yEnd + ((yEnd - yStart) * (yMin - ay[i]) / (yMax - yMin))
return yEnd + ((yEnd - yStart) * (yMin - ay) / (yMax - yMin));
}